From ae6d5ee6713bd591b2ea725e3e4839085e903217 Mon Sep 17 00:00:00 2001 From: jojo Date: Fri, 22 Jan 2021 13:58:02 +0100 Subject: [PATCH] Fix PR stuff --- .../bausystem/commands/CommandTNT.java | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java index 7726448..94f4d4e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java @@ -31,9 +31,10 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityExplodeEvent; -public class CommandTNT implements CommandExecutor { +public class CommandTNT implements CommandExecutor, Listener { private static TNTMode tntMode = TNTMode.OFF; @@ -58,6 +59,10 @@ public class CommandTNT implements CommandExecutor { } + public CommandTNT() { + Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin()); + } + private String getNoPermMessage() { return "§cDu darfst hier nicht TNT-Schaden (de-)aktivieren"; } @@ -71,11 +76,11 @@ public class CommandTNT implements CommandExecutor { } private String getTestblockEnableMessage() { - return "§aTNT-Schaden beim Testblock aktiviert"; + return "§aTNT-Schaden am Testblock aktiviert"; } private String getDamageMessage() { - return "§cEs ist etwas explodiert und hätte blöcke zerstört"; + return "§cEine Explosion hätte Blöcke im Baubereich zerstört"; } @Override @@ -110,22 +115,25 @@ public class CommandTNT implements CommandExecutor { @EventHandler public void onExplode(EntityExplodeEvent event) { - if (tntMode == TNTMode.ON) return; - if (tntMode == TNTMode.OFF) { - event.blockList().clear(); - } else { - boolean blocksDestroyed = event.blockList().removeIf(block -> { - for (Region region : Region.getRegions()) { - if (region.hasBuildRegion() && region.inBuildRegion(block.getLocation())) { - return true; + switch (tntMode) { + case ON: + break; + case OFF: + event.blockList().clear(); + break; + case ONLY_TB: + boolean blocksDestroyed = event.blockList().removeIf(block -> { + for (Region region : Region.getRegions()) { + if (region.hasBuildRegion() && region.inBuildRegion(block.getLocation())) { + return true; + } } + return false; + }); + if (blocksDestroyed) { + sendToActionBar(getDamageMessage()); } - return false; - }); - if (!blocksDestroyed) { - return; - } - sendToActionBar(getDamageMessage()); + break; } }