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..514f8178 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java @@ -249,4 +249,21 @@ public class TraceRecorder implements Listener { activeTraces.get(region).addRecord(record((TNTPrimed) event.getEntity(), activeTraces.get(region), event.blockList())); } + + //TODO Refactor to use EntityRemoveEvent when its not experimental anymore + + /** + * 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; + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java index e08b40c0..7957b085 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; +import de.steamwar.bausystem.features.tracer.TraceRecorder; import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; @@ -32,6 +33,7 @@ import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; import java.util.concurrent.atomic.AtomicLong; @@ -60,6 +62,7 @@ public class KillAllCommand extends SWCommand { .forEach(entity -> { entity.remove(); count.incrementAndGet(); + if (entity instanceof TNTPrimed) TraceRecorder.instance.removeFromRecording((TNTPrimed) entity); }); SWUtils.actionBar(current -> BauSystem.MESSAGE.parse("OTHER_KILLALL_GLOBAL", current, count.get())); } else { @@ -70,6 +73,7 @@ public class KillAllCommand extends SWCommand { .forEach(entity -> { entity.remove(); count.incrementAndGet(); + if (entity instanceof TNTPrimed) TraceRecorder.instance.removeFromRecording((TNTPrimed) entity); }); RegionUtils.actionBar(region, "OTHER_KILLALL_REGION", count.get()); }