From ad8cd863388ba27d5c825dd8df692398d84874de Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 3 Oct 2022 17:22:45 +0200 Subject: [PATCH] Add SingleTraceRecorder Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 1 + BauSystem_Main/src/BauSystem_de.properties | 1 + .../features/simulator/TNTSimulator.java | 4 +- .../features/tracer/TraceCommand.java | 12 +++-- .../tracer/record/AutoTraceRecorder.java | 3 ++ .../tracer/record/SingleTraceRecorder.java | 46 +++++++++++++++++++ 6 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SingleTraceRecorder.java diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 34c1d0db..d7574fa7 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -682,6 +682,7 @@ TPSLIMIT_INVALID_FROZEN = §c and '0' # Trace TRACE_RECORD=§aon TRACE_IDLE=§coff +TRACE_IDLE_SINGLE=§esingle TRACE_IDLE_AUTO_EXPLODE=§eauto §8(§7explode§8) TRACE_IDLE_AUTO_IGNITE=§eauto §8(§7ignite§8) TRACE_MESSAGE_AUTO_IDLE_EXPLODE = §aAuto-Tracer explode started diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index d9804ad9..b9373877 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -662,6 +662,7 @@ TPSLIMIT_INVALID_FROZEN = §c und '0' # Trace TRACE_RECORD=§aan TRACE_IDLE=§caus +TRACE_IDLE_SINGLE=§esingle TRACE_IDLE_AUTO_EXPLODE=§eauto §8(§7explode§8) TRACE_IDLE_AUTO_IGNITE=§eauto §8(§7ignite§8) TRACE_MESSAGE_AUTO_IDLE_EXPLODE = §aAuto-Tracer explode gestartet diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java index 045fb75b..4a92058a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java @@ -27,8 +27,8 @@ import de.steamwar.bausystem.features.simulator.show.SimulatorEntityShowMode; import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement; import de.steamwar.bausystem.features.simulator.tnt.TNTElement; import de.steamwar.bausystem.features.simulator.tnt.TNTGroup; -import de.steamwar.bausystem.features.tracer.record.AutoExplodeTraceRecorder; import de.steamwar.bausystem.features.tracer.record.Recorder; +import de.steamwar.bausystem.features.tracer.record.SingleTraceRecorder; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.shared.Pair; import lombok.Getter; @@ -238,7 +238,7 @@ public class TNTSimulator { } }); if (needsAutoTrace.get()) { - Recorder.INSTANCE.set(region, new AutoExplodeTraceRecorder()); + Recorder.INSTANCE.set(region, new SingleTraceRecorder(region)); } AtomicInteger maxTick = new AtomicInteger(0); 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 6278649d..bc6f5abf 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java @@ -22,10 +22,7 @@ package de.steamwar.bausystem.features.tracer; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.tracer.gui.TraceGui; -import de.steamwar.bausystem.features.tracer.record.AutoExplodeTraceRecorder; -import de.steamwar.bausystem.features.tracer.record.AutoIgniteTraceRecorder; -import de.steamwar.bausystem.features.tracer.record.Recorder; -import de.steamwar.bausystem.features.tracer.record.SimpleTraceRecorder; +import de.steamwar.bausystem.features.tracer.record.*; import de.steamwar.bausystem.features.tracer.show.ShowModeParameter; import de.steamwar.bausystem.features.tracer.show.ShowModeParameterType; import de.steamwar.bausystem.features.tracer.show.StoredRecords; @@ -65,6 +62,13 @@ public class TraceCommand extends SWCommand { BauSystem.MESSAGE.send("TRACE_MESSAGE_START", p); } + @Register(value = {"single"}, description = "TRACE_COMMAND_HELP_SINGLE") + public void singleCommand(@Validator Player p) { + Region region = Region.getRegion(p.getLocation()); + recorder.set(region, new SingleTraceRecorder(region)); + BauSystem.MESSAGE.send("TRACE_MESSAGE_SINGLE", p); + } + @Register(value = {"stop"}, description = "TRACE_COMMAND_HELP_STOP") public void stopCommand(@Validator Player p) { Region region = Region.getRegion(p.getLocation()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java index 55d43d03..4d43a30e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java @@ -45,6 +45,8 @@ public abstract class AutoTraceRecorder implements TraceRecorder { protected abstract String getInactivityMessage(); protected abstract boolean shouldStartRecording(StartType startType); + protected void stoppedRecording() { + } @Override public final String scoreboard(Player player) { @@ -108,6 +110,7 @@ public abstract class AutoTraceRecorder implements TraceRecorder { recording = false; recordMap.clear(); record = null; + stoppedRecording(); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SingleTraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SingleTraceRecorder.java new file mode 100644 index 00000000..6df0716f --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SingleTraceRecorder.java @@ -0,0 +1,46 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.tracer.record; + +import de.steamwar.bausystem.region.Region; + +public class SingleTraceRecorder extends AutoTraceRecorder { + + private Region region; + + public SingleTraceRecorder(Region region) { + this.region = region; + } + + @Override + protected String getInactivityMessage() { + return "TRACE_IDLE_SINGLE"; + } + + @Override + protected boolean shouldStartRecording(StartType startType) { + return startType == StartType.EXPLODE; + } + + @Override + protected void stoppedRecording() { + Recorder.INSTANCE.remove(region); + } +}