From fb73fa6fce56777919f75864295265af28e81e2c Mon Sep 17 00:00:00 2001 From: jojo Date: Sat, 6 Feb 2021 17:08:01 +0100 Subject: [PATCH 1/3] Add CommandTNT with extension explode message --- .../steamwar/bausystem/commands/CommandTNT.java | 8 ++++++++ .../src/de/steamwar/bausystem/world/Region.java | 15 ++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java index 84a9a5f..6c556e9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java @@ -75,6 +75,10 @@ public class CommandTNT implements CommandExecutor, Listener { return "§cEine Explosion hätte Blöcke im Baubereich zerstört"; } + private String getDamageExtensionMessage() { + return "§cEine Explosion hätte Blöcke im Ausfahrbereich zerstört"; + } + @Override public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { if (!(sender instanceof Player)) return false; @@ -149,6 +153,10 @@ public class CommandTNT implements CommandExecutor, Listener { RegionToggleCommand.actionBar(region, getDamageMessage()); return true; } + if (region.hasBuildRegion() && region.inBuildRegionExtension(block.getLocation())) { + RegionToggleCommand.actionBar(region, getDamageExtensionMessage()); + return true; + } return false; }); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java index 101eeba..0f3d682 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java @@ -162,6 +162,10 @@ public class Region { return prototype.buildArea.inRegion(this, l); } + public boolean inBuildRegionExtension(Location l) { + return prototype.buildArea.inRegionExtension(this, l); + } + public void fastreset(){ prototype.fastreset(this); } @@ -212,11 +216,6 @@ public class Region { return false; } - @Override - public boolean inBuildRegion(Location l) { - return false; - } - @Override public boolean hasTestblock() { return false; @@ -288,6 +287,12 @@ public class Region { inRange(l.getZ(), region.minZ + offsetZ, sizeZ); } + public boolean inRegionExtension(Region region, Location l) { + return inRange(l.getX(), region.minX + offsetX - extensionAxisX + 1, sizeX + extensionAxisX * 2 - 1) && + inRange(l.getY(), region.minY + offsetY, sizeY + extensionPositiveY - 1) && + inRange(l.getZ(), region.minZ + offsetZ - extensionNegativeZ + 1, sizeZ + extensionNegativeZ - 1 + extensionPositiveZ); + } + public void fastreset(Region region){ File file = new File(schematic); int x = region.minX + offsetX + sizeX/2; From f151c6e69a5c91710ace70c27be643bc71a4f8f3 Mon Sep 17 00:00:00 2001 From: jojo Date: Sat, 6 Feb 2021 21:44:00 +0100 Subject: [PATCH 2/3] Simplify CommandTNT methods --- .../bausystem/commands/CommandTNT.java | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java index 6c556e9..e3914ca 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java @@ -55,10 +55,6 @@ public class CommandTNT implements CommandExecutor, Listener { Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin()); } - private String getNoPermMessage() { - return "§cDu darfst hier nicht TNT-Schaden (de-)aktivieren"; - } - private String getEnableMessage() { return "§aTNT-Schaden aktiviert"; } @@ -71,21 +67,13 @@ public class CommandTNT implements CommandExecutor, Listener { return "§aTNT-Schaden außerhalb Baurahmen aktiviert"; } - private String getDamageMessage() { - return "§cEine Explosion hätte Blöcke im Baubereich zerstört"; - } - - private String getDamageExtensionMessage() { - return "§cEine Explosion hätte Blöcke im Ausfahrbereich zerstört"; - } - @Override public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { if (!(sender instanceof Player)) return false; Player player = (Player) sender; if (Welt.noPermission(player, Permission.world)) { - player.sendMessage(BauSystem.PREFIX + getNoPermMessage()); + player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht TNT-Schaden (de-)aktivieren"); return false; } @@ -150,11 +138,11 @@ public class CommandTNT implements CommandExecutor, Listener { if (region.getTntMode() == TNTMode.OFF) return true; if (region.getTntMode() == TNTMode.ON) return false; if (region.hasBuildRegion() && region.inBuildRegion(block.getLocation())) { - RegionToggleCommand.actionBar(region, getDamageMessage()); + RegionToggleCommand.actionBar(region, "§cEine Explosion hätte Blöcke im Baubereich zerstört"); return true; } if (region.hasBuildRegion() && region.inBuildRegionExtension(block.getLocation())) { - RegionToggleCommand.actionBar(region, getDamageExtensionMessage()); + RegionToggleCommand.actionBar(region, "§cEine Explosion hätte Blöcke im Ausfahrbereich zerstört"); return true; } return false; From fc44167ea0bda4bdddd80876330c6d4f401c6a65 Mon Sep 17 00:00:00 2001 From: jojo Date: Sat, 6 Feb 2021 21:47:48 +0100 Subject: [PATCH 3/3] Add tnt message with OFF mode --- .../src/de/steamwar/bausystem/commands/CommandTNT.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java index e3914ca..d528f37 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java @@ -135,7 +135,6 @@ public class CommandTNT implements CommandExecutor, Listener { public void onExplode(EntityExplodeEvent event) { event.blockList().removeIf(block -> { Region region = Region.getRegion(block.getLocation()); - if (region.getTntMode() == TNTMode.OFF) return true; if (region.getTntMode() == TNTMode.ON) return false; if (region.hasBuildRegion() && region.inBuildRegion(block.getLocation())) { RegionToggleCommand.actionBar(region, "§cEine Explosion hätte Blöcke im Baubereich zerstört"); @@ -145,7 +144,7 @@ public class CommandTNT implements CommandExecutor, Listener { RegionToggleCommand.actionBar(region, "§cEine Explosion hätte Blöcke im Ausfahrbereich zerstört"); return true; } - return false; + return region.getTntMode() == TNTMode.OFF; }); }