From f887e633adc1a9371ae35b39468cca7a6f124305 Mon Sep 17 00:00:00 2001 From: jojo Date: Sun, 24 Jan 2021 20:07:19 +0100 Subject: [PATCH] Add CommandTNT by Region.buildAreaEnabled() --- .../bausystem/commands/CommandInfo.java | 2 +- .../bausystem/commands/CommandTNT.java | 35 +++++++++++-------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java index 82b2563..c6810f7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java @@ -34,7 +34,7 @@ public class CommandInfo implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { sender.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(BauSystem.getOwnerID()).getUserName()); - sender.sendMessage(BauSystem.PREFIX + "TNT-Schaden: " + (CommandTNT.getTntMode() == CommandTNT.TNTMode.OFF ? "§cAN" : "§aAUS")); + sender.sendMessage(BauSystem.PREFIX + "TNT-Schaden: " + CommandTNT.getTntMode().getName()); sender.sendMessage(BauSystem.PREFIX + "Feuerschaden: " + (CommandFire.getInstance().isOn() ? "§aAUS" : "§cAN")); sender.sendMessage(BauSystem.PREFIX + "Eingefroren: " + (CommandFreeze.getInstance().isOn() ? "§aJA" : "§cNEIN")); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java index 3443dee..23ab3b6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java @@ -93,20 +93,27 @@ public class CommandTNT implements CommandExecutor, Listener { return false; } - if (args.length != 0 && (args[0].equalsIgnoreCase("an") || args[0].equalsIgnoreCase("on"))) { - tntMode = TNTMode.ON; - sendToActionBar(getEnableMessage()); - return false; - } - if (args.length != 0 && (args[0].equalsIgnoreCase("aus") || args[0].equalsIgnoreCase("off"))) { - tntMode = TNTMode.OFF; - sendToActionBar(getDisableMessage()); - return false; - } - if (args.length != 0 && Region.buildAreaEnabled() && (args[0].equalsIgnoreCase("testblock") || args[0].equalsIgnoreCase("tb"))) { - tntMode = TNTMode.ONLY_TB; - sendToActionBar(getTestblockEnableMessage()); - return false; + if (args.length != 0) { + switch (args[0].toLowerCase()) { + case "an": + case "on": + tntMode = TNTMode.ON; + sendToActionBar(getEnableMessage()); + return false; + case "aus": + case "off": + tntMode = TNTMode.OFF; + sendToActionBar(getDisableMessage()); + return false; + case "testblock": + case "tb": + if (!Region.buildAreaEnabled()) break; + tntMode = TNTMode.ONLY_TB; + sendToActionBar(getTestblockEnableMessage()); + return false; + default: + break; + } } switch (tntMode) {