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 0e9e1d0a..5d20aaad 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Recorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Recorder.java @@ -100,7 +100,7 @@ public class Recorder implements Listener { for(TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList())){ record(tnt, trace); } - trace.comitAdd(); + trace.commitAdd(); } } @@ -111,11 +111,17 @@ public class Recorder implements Listener { */ private void record(TNTPrimed tntPrimed, Trace trace){ List history = historyMap.getOrDefault(tntPrimed, new ArrayList<>()); + UUID tntID; - if(historyMap.size() == 0) + if(historyMap.size() == 0){ historyMap.put(tntPrimed, history); + tntID = UUID.randomUUID(); + } + else + tntID = history.get(0).getTntId(); - TNTRecord record = new TNTRecord(tntPrimed, tntPrimed.getFuseTicks() == 0, TPSUtils.currentTick.get() - trace.getStartTime(), history); + + TNTRecord record = new TNTRecord(tntID, tntPrimed, tntPrimed.getFuseTicks() == 0, TPSUtils.currentTick.get() - trace.getStartTime(), history); history.add(record); trace.add(record); 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 2efc01e4..21327f67 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTRecord.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTRecord.java @@ -26,9 +26,16 @@ import org.bukkit.util.Vector; import java.util.List; import java.util.Optional; +import java.util.UUID; @Getter public class TNTRecord { + + /** + * Unique number to identify records being of the same tnt + */ + private final UUID tntId; + /** * Whether this is a record of a tnt explosion or an entity */ @@ -59,7 +66,8 @@ public class TNTRecord { */ private final List history; - public TNTRecord(TNTPrimed tnt, boolean explosion, long ticksSinceStart, List history){ + public TNTRecord(UUID tntId, TNTPrimed tnt, boolean explosion, long ticksSinceStart, List history){ + this.tntId = tntId; this.explosion = explosion; this.ticksSinceStart = ticksSinceStart; fuse = tnt.getFuseTicks(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Trace.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Trace.java index 8c42b732..ef263188 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Trace.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Trace.java @@ -81,7 +81,10 @@ public class Trace { newRecords.add(records); } - protected void comitAdd(){ + /** + * Commits the additions made to this trace and updates active renders of this trace + */ + protected void commitAdd(){ records.addAll(newRecords); for(Player player: serverMap.keySet()){