From 8d6014cd010d7af0887581eae9ee5009990cfdc2 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 11 Jun 2022 20:57:47 +0200 Subject: [PATCH] Update stuff Signed-off-by: yoyosource --- .../features/simulator/SimulatorCommand.java | 2 +- .../features/simulator/TNTSimulator.java | 21 ++++++++++++++++++- .../simulator/TNTSimulatorListener.java | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCommand.java index ec7d535f..49dda986 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCommand.java @@ -83,7 +83,7 @@ public class SimulatorCommand extends SWCommand { BauSystem.MESSAGE.send("SIMULATOR_NOT_EXISTS", p); return; } - tntSimulator.start(); + tntSimulator.start(p); } @Mapper("simulators") 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 e0d10819..c38fcb62 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java @@ -28,6 +28,9 @@ 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.RecordStateMachine; +import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.flags.Flag; +import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode; import de.steamwar.bausystem.shared.Pair; import lombok.Getter; import org.bukkit.Bukkit; @@ -209,7 +212,23 @@ public class TNTSimulator { }); } - public void start() { + public void start(Player p) { + for (SimulatorElement element : tntElementList) { + if (element instanceof TNTElement) { + if (Region.getRegion(element.getPosition().toLocation(SimulatorStorage.WORLD)).get(Flag.FREEZE) == FreezeMode.ACTIVE) { + BauSystem.MESSAGE.send("SIMULATOR_REGION_FREEZED", p); + return; + } + } else if (element instanceof TNTGroup) { + for (TNTElement tntElement : ((TNTGroup) element).getElements()) { + if (Region.getRegion(tntElement.getPosition().toLocation(SimulatorStorage.WORLD)).get(Flag.FREEZE) == FreezeMode.ACTIVE) { + BauSystem.MESSAGE.send("SIMULATOR_REGION_FREEZED", p); + return; + } + } + } + } + Map>>> result = new HashMap<>(); for (SimulatorElement element : tntElementList) { element.locations(result); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulatorListener.java index 12e7f57f..6a85a082 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulatorListener.java @@ -139,7 +139,7 @@ public class TNTSimulatorListener implements Listener { if (simulator == null) { return; } - simulator.start(); + simulator.start(event.getPlayer()); break; case RIGHT_CLICK_BLOCK: case RIGHT_CLICK_AIR: