From 81bbc84fd86b8672ce7ef86d18e2ce019386c091 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 1 Jan 2021 13:20:28 +0100 Subject: [PATCH] Fix post clear behaviour --- .../bausystem/tracer/record/RecordStateMachine.java | 5 +++++ .../src/de/steamwar/bausystem/tracer/record/Recorder.java | 7 +++++++ .../src/de/steamwar/bausystem/tracer/show/Record.java | 4 ++++ .../de/steamwar/bausystem/tracer/show/StoredRecords.java | 3 +++ 4 files changed, 19 insertions(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/RecordStateMachine.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/RecordStateMachine.java index 7a1e25e..6a755b8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/RecordStateMachine.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/RecordStateMachine.java @@ -86,4 +86,9 @@ public class RecordStateMachine { if (recorder == null) return 0; return recorder.getStartTime(); } + + public static void postClear(){ + if (recorder == null) return; + recorder.postClear(); + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/Recorder.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/Recorder.java index f330d81..171afd0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/Recorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/Recorder.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.tracer.record; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.tracer.show.Record; +import de.steamwar.bausystem.tracer.show.StoredRecords; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.TNTPrimed; @@ -63,6 +64,12 @@ public class Recorder implements Listener { return record.getStartTime(); } + void postClear() { + record.clear(); + recordMap.clear(); + StoredRecords.add(record); + } + private void run() { world.getEntitiesByClass(TNTPrimed.class).forEach(tntPrimed -> get(tntPrimed).add(tntPrimed)); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/Record.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/Record.java index 8f97814..1fdbd50 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/Record.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/Record.java @@ -55,6 +55,10 @@ public class Record { return record; } + public void clear(){ + tnt.clear(); + } + public static class TNTRecord { private final List positions = new ArrayList<>(41); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/StoredRecords.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/StoredRecords.java index a7ce3c5..b0a377e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/StoredRecords.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/StoredRecords.java @@ -19,6 +19,8 @@ package de.steamwar.bausystem.tracer.show; +import de.steamwar.bausystem.tracer.record.RecordStateMachine; + import java.util.ArrayList; import java.util.List; @@ -37,6 +39,7 @@ public class StoredRecords { public static void clear() { records.clear(); TraceShowManager.clear(); + RecordStateMachine.postClear(); } }