From fb73fa6fce56777919f75864295265af28e81e2c Mon Sep 17 00:00:00 2001 From: jojo Date: Sat, 6 Feb 2021 17:08:01 +0100 Subject: [PATCH] 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;