diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/SimulatorExecutor.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/SimulatorExecutor.java index 893161f4..39c2e60b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/SimulatorExecutor.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/SimulatorExecutor.java @@ -23,12 +23,12 @@ import de.steamwar.bausystem.features.simulator.data.Simulator; import de.steamwar.bausystem.features.simulator.data.SimulatorElement; import de.steamwar.bausystem.features.simulator.data.SimulatorGroup; import de.steamwar.bausystem.features.tpslimit.TPSUtils; -import de.steamwar.bausystem.features.tracer.record.Recorder; -import de.steamwar.bausystem.features.tracer.record.SingleTraceRecorder; +import de.steamwar.bausystem.features.tracer.TraceRecorder; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.utils.TickEndEvent; import de.steamwar.bausystem.utils.TickStartEvent; import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; import de.steamwar.linkage.MinVersion; import org.bukkit.Bukkit; import org.bukkit.World; @@ -46,6 +46,8 @@ public class SimulatorExecutor implements Listener { private static Set currentlyRunning = new HashSet<>(); private static Map>> tickStartActions = new HashMap<>(); private static Map> tickEndActions = new HashMap<>(); + @LinkedInstance + private static TraceRecorder recorder; public static boolean run(Simulator simulator) { if (currentlyRunning.contains(simulator)) return false; @@ -69,6 +71,20 @@ public class SimulatorExecutor implements Listener { @Override public void accept(World world) { currentlyRunning.remove(simulator); + + if (simulator.isAutoTrace()) { + simulator.getGroups() + .stream() + .map(SimulatorGroup::getElements) + .flatMap(List::stream) + .map(SimulatorElement::getPosition) + .map(pos -> pos.toLocation(WORLD)) + .map(Region::getRegion) + .distinct() + .forEach(region -> { + recorder.stopRecording(region); + }); + } } }); @@ -82,9 +98,7 @@ public class SimulatorExecutor implements Listener { .map(Region::getRegion) .distinct() .forEach(region -> { - if (Recorder.INSTANCE.isDisabled(region)) { - Recorder.INSTANCE.set(region, new SingleTraceRecorder(region)); - } + recorder.startRecording(region); }); } return true; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java index 2554e3fa..39664b91 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java @@ -41,7 +41,7 @@ import java.util.stream.Stream; public class TraceCommand extends SWCommand { @LinkedInstance - public Recorder recorder; + public TraceRecorder traceRecorder; @LinkedInstance public TraceManager manager; @@ -52,21 +52,21 @@ public class TraceCommand extends SWCommand { @Register(value = "start", description = "TRACE_COMMAND_HELP_START") public void start(@Validator Player player) { Region region = Region.getRegion(player.getLocation()); - recorder.startRecording(region); + traceRecorder.startRecording(region); BauSystem.MESSAGE.send("TRACE_MESSAGE_START", player); } @Register(value = "stop", description = "TRACE_COMMAND_HELP_STOP") public void stop(@Validator Player player) { Region region = Region.getRegion(player.getLocation()); - recorder.stopRecording(region); + traceRecorder.stopRecording(region); BauSystem.MESSAGE.send("TRACE_MESSAGE_STOP", player); } @Register(value = "auto", description = "TRACE_COMMAND_HELP_SHOW") public void auto(@Validator Player player) { Region region = Region.getRegion(player.getLocation()); - recorder.toggleAutoTrace(region); + traceRecorder.toggleAutoTrace(region); } @Register(value = "show", description = "TRACE_COMMAND_HELP_SHOW") diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Recorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java similarity index 99% rename from BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Recorder.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java index 29a8786b..f79945b3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Recorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java @@ -35,7 +35,7 @@ import org.bukkit.event.entity.EntitySpawnEvent; import java.util.*; @Linked -public class Recorder implements Listener { +public class TraceRecorder implements Listener { /** * Linked instance of TraceManager @@ -78,7 +78,7 @@ public class Recorder implements Listener { */ private final Set autoTraceRegions = new HashSet<>(); - public Recorder() { + public TraceRecorder() { BauSystem.runTaskTimer(BauSystem.getInstance(), () -> { record(); checkForAutoTraceFinish();