Fix trimming of replays not actually removing any packets (fixes #113)
The init method of the Squash filter has never been called therefore it had never registered its packets and was never able to properly function.
This commit is contained in:
@@ -36,6 +36,7 @@ import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
|||||||
import de.johni0702.minecraft.gui.utils.Colors;
|
import de.johni0702.minecraft.gui.utils.Colors;
|
||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.lwjgl.util.ReadableDimension;
|
import org.lwjgl.util.ReadableDimension;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -123,7 +124,8 @@ public class GuiReplayEditor extends GuiScreen {
|
|||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(File inputFile, PacketStream.FilterInfo...filters) {
|
@SafeVarargs
|
||||||
|
public final void save(File inputFile, Pair<PacketStream.FilterInfo, JsonObject>... filters) {
|
||||||
save(Utils.fileNameToReplayName(inputFile.getName()), (outputFile) -> {
|
save(Utils.fileNameToReplayName(inputFile.getName()), (outputFile) -> {
|
||||||
Studio studio = new ReplayStudio();
|
Studio studio = new ReplayStudio();
|
||||||
File tmpDir = null;
|
File tmpDir = null;
|
||||||
@@ -146,7 +148,10 @@ public class GuiReplayEditor extends GuiScreen {
|
|||||||
PacketStream stream = studio.createReplayStream(in, true);
|
PacketStream stream = studio.createReplayStream(in, true);
|
||||||
|
|
||||||
stream.addFilter(new ProgressFilter(metaData.getDuration()));
|
stream.addFilter(new ProgressFilter(metaData.getDuration()));
|
||||||
for (PacketStream.FilterInfo info : filters) {
|
for (Pair<PacketStream.FilterInfo, JsonObject> pair : filters) {
|
||||||
|
PacketStream.FilterInfo info = pair.getLeft();
|
||||||
|
JsonObject config = pair.getRight();
|
||||||
|
info.getFilter().init(studio, config);
|
||||||
stream.addFilter(info.getFilter(), info.getFrom(), info.getTo());
|
stream.addFilter(info.getFilter(), info.getFrom(), info.getTo());
|
||||||
LOGGER.debug("Added filter {}", info);
|
LOGGER.debug("Added filter {}", info);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import net.minecraft.client.resources.I18n;
|
|||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
import org.apache.commons.io.IOCase;
|
import org.apache.commons.io.IOCase;
|
||||||
import org.apache.commons.io.filefilter.SuffixFileFilter;
|
import org.apache.commons.io.filefilter.SuffixFileFilter;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.lwjgl.util.Dimension;
|
import org.lwjgl.util.Dimension;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -133,12 +134,11 @@ public class GuiTrimPanel extends GuiPanel {
|
|||||||
ChangeTimestampFilter ctf = new ChangeTimestampFilter();
|
ChangeTimestampFilter ctf = new ChangeTimestampFilter();
|
||||||
JsonObject config = new JsonObject();
|
JsonObject config = new JsonObject();
|
||||||
config.addProperty("offset", -start);
|
config.addProperty("offset", -start);
|
||||||
ctf.init(null, config);
|
|
||||||
// Pass filters to save dialog
|
// Pass filters to save dialog
|
||||||
gui.save(inputReplays.getSelectedValue(),
|
gui.save(inputReplays.getSelectedValue(),
|
||||||
new PacketStream.FilterInfo(new SquashFilter(), -1, start),
|
Pair.of(new PacketStream.FilterInfo(new SquashFilter(), -1, start), new JsonObject()),
|
||||||
new PacketStream.FilterInfo(ctf, start, end),
|
Pair.of(new PacketStream.FilterInfo(ctf, start, end), config),
|
||||||
new PacketStream.FilterInfo(new RemoveFilter(), end, -1)
|
Pair.of(new PacketStream.FilterInfo(new RemoveFilter(), end, -1), new JsonObject())
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user