diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java index faabcc62..06a84e46 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java @@ -36,9 +36,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntitySpawnEvent; -import java.util.HashMap; -import java.util.Map; -import java.util.ArrayList; +import java.util.*; import java.util.stream.Collectors; @Linked @@ -135,12 +133,19 @@ public class Recorder implements Listener { } } + private Set activeTNTs = new HashSet<>(); + + { + activeTNTs.addAll(world.getEntitiesByClass(TNTPrimed.class)); + } + @EventHandler public void onEntitySpawn(EntitySpawnEvent event) { Entity entity = event.getEntity(); if (!(entity instanceof TNTPrimed)) { return; } + activeTNTs.add((TNTPrimed) entity); get((TNTPrimed) entity).spawn((TNTPrimed) entity); } @@ -157,7 +162,7 @@ public class Recorder implements Listener { } private void tick() { - world.getEntitiesByClass(TNTPrimed.class).forEach(tntPrimed -> { + activeTNTs.forEach(tntPrimed -> { get(tntPrimed).tick(tntPrimed); }); } @@ -172,6 +177,7 @@ public class Recorder implements Listener { Region region = tntTraceRecorderMap.get((TNTPrimed) entity); traceRecorder.explode((TNTPrimed) entity, !event.blockList().isEmpty() && region.inRegion(event.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION)); tntTraceRecorderMap.remove(entity); + activeTNTs.remove(entity); tick(); } }