diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Recorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Recorder.java index 698c06b1..30ff7d73 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Recorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Recorder.java @@ -24,6 +24,7 @@ import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.bausystem.region.Region; import de.steamwar.linkage.Linked; import de.steamwar.linkage.LinkedInstance; +import org.bukkit.block.Block; import org.bukkit.entity.TNTPrimed; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -138,7 +139,7 @@ public class Recorder implements Listener { Trace trace = activeTraces.get(region); for(TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList())){ - record(tnt, trace); + record(tnt, trace, Collections.emptyList()); } trace.commitAdd(); } @@ -149,7 +150,7 @@ public class Recorder implements Listener { * @param tntPrimed tnt exploding * @param trace trace to record the tnt for */ - private void record(TNTPrimed tntPrimed, Trace trace){ + private void record(TNTPrimed tntPrimed, Trace trace, List destroyedBlocks){ List history = historyMap.getOrDefault(tntPrimed, new ArrayList<>()); UUID tntID; @@ -165,7 +166,7 @@ public class Recorder implements Listener { noExplosionRecorded.remove(trace); boolean afterFirstExplosion = noExplosionRecorded.contains(trace); - TNTRecord record = new TNTRecord(tntID, tntPrimed, isExplosion, afterFirstExplosion, TPSUtils.currentTick.get() - trace.getStartTime(), history); + TNTRecord record = new TNTRecord(tntID, tntPrimed, isExplosion, afterFirstExplosion, TPSUtils.currentTick.get() - trace.getStartTime(), history, destroyedBlocks); history.add(record); trace.add(record); @@ -198,7 +199,7 @@ public class Recorder implements Listener { * Unregisters TNTs from beeing traced on explode * @param event */ - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onTNTExplode(EntityExplodeEvent event){ if(!(event.getEntity() instanceof TNTPrimed)) return; @@ -207,6 +208,6 @@ public class Recorder implements Listener { trackedTNT.get(region).remove((TNTPrimed) event.getEntity()); tntSpawnRegion.remove((TNTPrimed) event.getEntity()); - record((TNTPrimed) event.getEntity(), activeTraces.get(region)); + record((TNTPrimed) event.getEntity(), activeTraces.get(region), event.blockList()); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTRecord.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTRecord.java index a0063704..ee22eaeb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTRecord.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTRecord.java @@ -19,8 +19,12 @@ package de.steamwar.bausystem.features.tracer; +import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.utils.RegionExtensionType; +import de.steamwar.bausystem.region.utils.RegionType; import lombok.Getter; import org.bukkit.Location; +import org.bukkit.block.Block; import org.bukkit.entity.TNTPrimed; import org.bukkit.util.Vector; @@ -51,6 +55,16 @@ public class TNTRecord { */ private final boolean afterFirstExplosion; + /** + * Whether this record has destroyed blocks in build area + */ + private final boolean destroyedBuildArea; + + /** + * Whether this record has destroyed blocks in testblock area + */ + private final boolean destroyedTestBlock; + /** * Tick offset, from this record being taken to the start of the trace */ @@ -76,7 +90,7 @@ public class TNTRecord { */ private final List history; - public TNTRecord(UUID tntId, TNTPrimed tnt, boolean explosion, boolean afterFirstExplosion, long ticksSinceStart, List history){ + public TNTRecord(UUID tntId, TNTPrimed tnt, boolean explosion, boolean afterFirstExplosion, long ticksSinceStart, List history, List destroyedBlocks){ this.tntId = tntId; this.explosion = explosion; this.inWater = tnt.isInWater(); @@ -86,6 +100,18 @@ public class TNTRecord { location = tnt.getLocation(); velocity = tnt.getVelocity(); this.history = history; + + boolean buildDestroy = false; + boolean testblockDestroy = false; + for(Block destroyedBlock: destroyedBlocks){ + if (Region.getRegion(destroyedBlock.getLocation()).inRegion(destroyedBlock.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION)) + buildDestroy = true; + if (Region.getRegion(destroyedBlock.getLocation()).inRegion(destroyedBlock.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) + buildDestroy = true; + } + + destroyedBuildArea = buildDestroy; + destroyedTestBlock = testblockDestroy; } public Optional getNext(){ diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/ViewFlag.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/ViewFlag.java index d11bacec..0f865349 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/ViewFlag.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/ViewFlag.java @@ -70,6 +70,42 @@ public abstract class ViewFlag { public void modify(REntityServer server, List entities) {} }; + public static ViewFlag SOURCE = new ViewFlag(true, false, "source") { + @Override + public List filter(List records) { + return records.stream() + .filter(record -> record.getFuse() == 80) + .collect(Collectors.toList()); + } + + @Override + public void modify(REntityServer server, List entities) {} + }; + + public static ViewFlag BUILD_DESTROY_ONLY = new ViewFlag(true, false, "build-destroy-only") { + @Override + public List filter(List records) { + return records.stream() + .filter(record -> record.getHistory().get(record.getHistory().size() - 1).isDestroyedBuildArea()) + .collect(Collectors.toList()); + } + + @Override + public void modify(REntityServer server, List entities) {} + }; + + public static ViewFlag TESTBLOCK_DESTROY_ONLY = new ViewFlag(true, false, "testblock-destroy-only") { + @Override + public List filter(List records) { + return records.stream() + .filter(record -> record.getHistory().get(record.getHistory().size() - 1).isDestroyedTestBlock()) + .collect(Collectors.toList()); + } + + @Override + public void modify(REntityServer server, List entities) {} + }; + public static ViewFlag ADVANCED = new ViewFlag(true, false, "advanced") { @Override public List filter(List records) {return records;}