From 0c91261d55cf8f0679b4c97b465c9d5b3d27609a Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Sun, 28 Apr 2024 12:09:14 +0200 Subject: [PATCH] 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()); } }