From 95132a17d32b36f29502e1e9844cfbf14d279272 Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Sun, 28 Apr 2024 11:01:37 +0200 Subject: [PATCH 1/8] Fixed tnt point tss wrong --- .../de/steamwar/bausystem/features/tracer/TraceRecorder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java index a252f208..44c26333 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java @@ -168,7 +168,7 @@ public class TraceRecorder implements Listener { } boolean afterFirstExplosion = wrappedTrace.isExplosionRecorded(); - TNTPoint record = new TNTPoint(tntID, tntPrimed, isExplosion, afterFirstExplosion, TPSUtils.currentTick.get() - wrappedTrace.getStartTick(), history, destroyedBlocks); + TNTPoint record = new TNTPoint(tntID, tntPrimed, isExplosion, afterFirstExplosion, TPSUtils.currentRealTick.get() - wrappedTrace.getStartTick(), history, destroyedBlocks); history.add(record); return record; From 7fa31704f41412035e65e001d25c781cb1b31b16 Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Sun, 28 Apr 2024 11:17:09 +0200 Subject: [PATCH 2/8] Added non toggle methods for auto tracer to recorder --- .../features/tracer/TraceRecorder.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java index 44c26333..0e30436d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java @@ -88,6 +88,14 @@ public class TraceRecorder implements Listener { } } + public void addAutoTraceRegion(Region region) { + autoTraceRegions.add(region); + } + + public void removeAutoTraceRegion(Region region) { + autoTraceRegions.remove(region); + } + /** * Makes checks for whether auto traces finished */ @@ -137,6 +145,7 @@ public class TraceRecorder implements Listener { TraceRecordingWrapper wrappedTrace = activeTraces.get(region); for (TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList())) { TNTPoint record = record(tnt, wrappedTrace, Collections.emptyList()); + if (record == null) continue; wrappedTrace.addRecord(record); } wrappedTrace.commitRecorded(); @@ -153,6 +162,12 @@ public class TraceRecorder implements Listener { */ private TNTPoint record(TNTPrimed tntPrimed, TraceRecordingWrapper wrappedTrace, List destroyedBlocks) { List history = historyMap.getOrDefault(tntPrimed, new ArrayList<>()); + // Failsave for tnt entering unloaded chunks + if (history.size() > 0 && history.get(history.size() - 1).getFuse() == tntPrimed.getFuseTicks()) { + removeFromRecording(tntPrimed); + return null; + } + int tntID; if (history.size() == 0) { @@ -249,4 +264,19 @@ public class TraceRecorder implements Listener { activeTraces.get(region).addRecord(record((TNTPrimed) event.getEntity(), activeTraces.get(region), event.blockList())); } + + /** + * Methode to be used if a tnt should be removed for internal or technical reasons + * + * @param tnt tnt to remove + * @return whether the tnt was tracked beforehand or not + */ + public boolean removeFromRecording(TNTPrimed tnt) { + Region region = tntSpawnRegion.getOrDefault(tnt, null); + if (region == null) return false; + trackedTNT.get(region).remove(tnt); + tntSpawnRegion.remove(tnt); + historyMap.remove(tnt); + return true; + } } From 2aec97304dbfed6a7b083f1ee15e1152efd0efa9 Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Sun, 28 Apr 2024 11:18:41 +0200 Subject: [PATCH 3/8] Made -- to - --- .../src/de/steamwar/bausystem/features/tracer/TraceCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java index 01e833db..de849670 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java @@ -248,7 +248,7 @@ public class TraceCommand extends SWCommand { @Override public ViewFlag map(CommandSender commandSender, String[] previousArguments, String s) { for (ViewFlag flag : ViewFlag.flags) { - if (s.equals("--" + flag.name)) { + if (s.equals("-" + flag.name)) { return flag; } From 4568ceee365a5872595b4cb7defc75e09c3c6ab9 Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Sun, 28 Apr 2024 11:59:42 +0200 Subject: [PATCH 4/8] Changed auto trace toggle to setable --- .../bausystem/features/tracer/TraceCommand.java | 12 +++++++----- .../bausystem/features/tracer/TraceRecorder.java | 14 -------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java index de849670..e312cb08 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java @@ -58,16 +58,18 @@ public class TraceCommand extends SWCommand { Region region = Region.getRegion(player.getLocation()); TraceRecorder.instance.stopRecording(region); BauSystem.MESSAGE.send("TRACE_MESSAGE_STOP", player); + + if (TraceRecorder.instance.isAutoTraceEnabledInRegion(region)) { + TraceRecorder.instance.removeAutoTraceRegion(region); + BauSystem.MESSAGE.send("TRACE_MESSAGE_AUTO_STOP", player); + } } @Register(value = "auto", description = "TRACE_COMMAND_HELP_AUTO") public void auto(@Validator Player player) { Region region = Region.getRegion(player.getLocation()); - if (TraceRecorder.instance.toggleAutoTrace(region)) { - BauSystem.MESSAGE.send("TRACE_MESSAGE_AUTO_START", player); - } else { - BauSystem.MESSAGE.send("TRACE_MESSAGE_AUTO_STOP", player); - } + TraceRecorder.instance.addAutoTraceRegion(region); + BauSystem.MESSAGE.send("TRACE_MESSAGE_AUTO_START", player); } @Register(value = "show", description = "TRACE_COMMAND_HELP_SHOW") diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java index 0e30436d..86af2d6b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java @@ -74,20 +74,6 @@ public class TraceRecorder implements Listener { }, 0, 1); } - /** - * Toggles auto trace for the given region - * - * @param region - */ - public boolean toggleAutoTrace(Region region) { - if (!autoTraceRegions.remove(region)) { - autoTraceRegions.add(region); - return true; - } else { - return false; - } - } - public void addAutoTraceRegion(Region region) { autoTraceRegions.add(region); } From add259788dd00be488307fdf18d30a79107b9170 Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Sun, 28 Apr 2024 12:02:03 +0200 Subject: [PATCH 5/8] Fixed stop message --- .../de/steamwar/bausystem/features/tracer/TraceCommand.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java index e312cb08..9ae8b7f1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java @@ -57,11 +57,13 @@ public class TraceCommand extends SWCommand { public void stop(@Validator Player player) { Region region = Region.getRegion(player.getLocation()); TraceRecorder.instance.stopRecording(region); - BauSystem.MESSAGE.send("TRACE_MESSAGE_STOP", player); + if (TraceRecorder.instance.isAutoTraceEnabledInRegion(region)) { TraceRecorder.instance.removeAutoTraceRegion(region); BauSystem.MESSAGE.send("TRACE_MESSAGE_AUTO_STOP", player); + } else { + BauSystem.MESSAGE.send("TRACE_MESSAGE_STOP", player); } } From 0c91261d55cf8f0679b4c97b465c9d5b3d27609a Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Sun, 28 Apr 2024 12:09:14 +0200 Subject: [PATCH 6/8] Inlined failsave --- .../features/tracer/TraceRecorder.java | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java index 86af2d6b..b8fa3664 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java @@ -150,7 +150,12 @@ public class TraceRecorder implements Listener { List history = historyMap.getOrDefault(tntPrimed, new ArrayList<>()); // Failsave for tnt entering unloaded chunks if (history.size() > 0 && history.get(history.size() - 1).getFuse() == tntPrimed.getFuseTicks()) { - removeFromRecording(tntPrimed); + Region region = tntSpawnRegion.get(tntPrimed); + if (region == null) return null; + trackedTNT.get(region).remove(tntPrimed); + tntSpawnRegion.remove(tntPrimed); + historyMap.remove(tntPrimed); + tntSpawnRegion.remove(tntPrimed); return null; } @@ -249,20 +254,6 @@ public class TraceRecorder implements Listener { tntSpawnRegion.remove((TNTPrimed) event.getEntity()); activeTraces.get(region).addRecord(record((TNTPrimed) event.getEntity(), activeTraces.get(region), event.blockList())); - } - - /** - * Methode to be used if a tnt should be removed for internal or technical reasons - * - * @param tnt tnt to remove - * @return whether the tnt was tracked beforehand or not - */ - public boolean removeFromRecording(TNTPrimed tnt) { - Region region = tntSpawnRegion.getOrDefault(tnt, null); - if (region == null) return false; - trackedTNT.get(region).remove(tnt); - tntSpawnRegion.remove(tnt); - historyMap.remove(tnt); - return true; + tntSpawnRegion.remove((TNTPrimed) event.getEntity()); } } From 7502270b96e59ffc5b0739bc45267b39b2d7c404 Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Sun, 28 Apr 2024 12:10:33 +0200 Subject: [PATCH 7/8] Fixed killall interaction --- .../de/steamwar/bausystem/features/tracer/TraceRecorder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java index b8fa3664..9c5b3a41 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java @@ -149,7 +149,7 @@ public class TraceRecorder implements Listener { private TNTPoint record(TNTPrimed tntPrimed, TraceRecordingWrapper wrappedTrace, List destroyedBlocks) { List history = historyMap.getOrDefault(tntPrimed, new ArrayList<>()); // Failsave for tnt entering unloaded chunks - if (history.size() > 0 && history.get(history.size() - 1).getFuse() == tntPrimed.getFuseTicks()) { + if (tntPrimed.isDead() || history.size() > 0 && history.get(history.size() - 1).getFuse() == tntPrimed.getFuseTicks() &&) { Region region = tntSpawnRegion.get(tntPrimed); if (region == null) return null; trackedTNT.get(region).remove(tntPrimed); From a36bae3a8d9e92faa594a197953d2d78cc6ecc64 Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Sun, 28 Apr 2024 12:11:22 +0200 Subject: [PATCH 8/8] ... --- .../de/steamwar/bausystem/features/tracer/TraceRecorder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java index 9c5b3a41..1d6d40a3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java @@ -149,7 +149,7 @@ public class TraceRecorder implements Listener { private TNTPoint record(TNTPrimed tntPrimed, TraceRecordingWrapper wrappedTrace, List destroyedBlocks) { List history = historyMap.getOrDefault(tntPrimed, new ArrayList<>()); // Failsave for tnt entering unloaded chunks - if (tntPrimed.isDead() || history.size() > 0 && history.get(history.size() - 1).getFuse() == tntPrimed.getFuseTicks() &&) { + if (tntPrimed.isDead() || history.size() > 0 && history.get(history.size() - 1).getFuse() == tntPrimed.getFuseTicks()) { Region region = tntSpawnRegion.get(tntPrimed); if (region == null) return null; trackedTNT.get(region).remove(tntPrimed);