From 43cca3376ebef1fc7d79db0edd68ad594b1149ea Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 11 Jul 2025 21:36:50 +0200 Subject: [PATCH] Fix some more issues --- .../features/autostart/AutostartListener.java | 2 +- .../features/script/event/EventListener.java | 4 +- .../features/techhider/TechHiderCommand.java | 6 +-- .../features/util/KillAllCommand.java | 2 +- .../features/world/BauScoreboard.java | 5 +- .../bausystem/features/xray/XrayCommand.java | 4 +- .../de/steamwar/bausystem/region/Point.java | 2 + .../de/steamwar/bausystem/region/Region.java | 53 ++++++++++++++++++- 8 files changed, 65 insertions(+), 13 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java index 3e477955..59e4fd3a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java @@ -109,7 +109,7 @@ public class AutostartListener implements Listener { BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO_REGION", player); return; } - if (region.getTestblockArea().isPresent()) { + if (region.getTestblockArea().isEmpty()) { BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO_REGION", player); return; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/EventListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/EventListener.java index 958d13a4..54ddac4e 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/EventListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/EventListener.java @@ -153,7 +153,7 @@ public class EventListener implements Listener { for (Player player : Bukkit.getOnlinePlayers()) { if(!Permission.BUILD.hasPermission(player)) continue; - if (tntRegion.inRegion(player.getLocation())) { + if (tntRegion.getArea().inRegion(player.getLocation(), false)) { ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTSpawn, LuaValue.NIL, event); } } @@ -175,7 +175,7 @@ public class EventListener implements Listener { for (Player player : Bukkit.getOnlinePlayers()) { if(!Permission.BUILD.hasPermission(player)) continue; - if (tntRegion.inRegion(player.getLocation())) { + if (tntRegion.getArea().inRegion(player.getLocation(), false)) { ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplode, table, event); if (inBuild) { ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplodeInBuild, table, event); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java index 8ac94d2d..08ab82d8 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java @@ -85,8 +85,8 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE Set hiddenBlocks = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlocks"))); Set hiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities"))); - TechHider current = new TechHider((TechHider.LocationEvaluator) (p, cX, cY) -> { - if (rg.buildChunkOutside(cX, cY)) return true; + TechHider current = new TechHider((p, cX, cY) -> { + if (rg.getBuildArea().isChunkOutside(cX, cY)) return true; return !hidden.get(rg).contains(p); }, Material.valueOf(obfuscateWith.toUpperCase()), hiddenBlocks.stream().map(String::toUpperCase).map(Material::valueOf).collect(Collectors.toSet()), hiddenBlockEntities); current.enable(); @@ -105,7 +105,7 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE hidden.get(region).add(player); BauSystem.MESSAGE.sendPrefixless("TECHHIDER_ON", player, ChatMessageType.ACTION_BAR); } - region.forEachChunk((x, z) -> { + region.getBuildArea().forEachChunk((x, z) -> { CraftbukkitWrapper.impl.sendChunk(player, x, z); }); } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java index b461939f..d82448a0 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java @@ -62,7 +62,7 @@ public class KillAllCommand extends SWCommand { WORLD.getEntities() .stream() .filter(e -> !(e instanceof Player)) - .filter(e -> region.inRegion(e.getLocation())) + .filter(e -> region.getArea().inRegion(e.getLocation(), false)) .forEach(entity -> { entity.remove(); count.incrementAndGet(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java index 38aa4039..b53f48c8 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java @@ -1,6 +1,7 @@ package de.steamwar.bausystem.features.world; import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.flags.ColorMode; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.linkage.Linked; @@ -101,8 +102,8 @@ public class BauScoreboard implements Listener { Region region = Region.getRegion(player.getLocation()); if (region.getType().isGlobal()) return "§eSteam§8War"; String colorCode = "§e"; - if (region.hasFlag(Flag.COLOR).isReadable()) { - colorCode = "§" + region.getFlag(Flag.COLOR).get().getColor().getColorCode(); + if (region.getFlags().has(Flag.COLOR).isReadable()) { + colorCode = "§" + region.getFlags().get(Flag.COLOR).orElse(ColorMode.PINK).getColorCode(); } return colorCode + "■ §eSteam§8War " + colorCode + "■"; // ■ } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java index b18c54d7..c077d839 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java @@ -103,7 +103,7 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen hidden.get(region).add(player); BauSystem.MESSAGE.sendPrefixless("XRAY_ON", player, ChatMessageType.ACTION_BAR); } - region.forEachChunk((x, z) -> { + region.getBuildArea().forEachChunk((x, z) -> { CraftbukkitWrapper.impl.sendChunk(player, x, z); }); } @@ -149,7 +149,7 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen private TechHider createXray(Region rg, Set obfuscate) { TechHider current = new TechHider((TechHider.LocationEvaluator) (p, cX, cY) -> { - if (rg.buildChunkOutside(cX, cY)) return true; + if (rg.getBuildArea().isChunkOutside(cX, cY)) return true; return !hidden.get(rg).contains(p); }, Material.STRUCTURE_VOID, obfuscate, new HashSet<>()); current.enable(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Point.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Point.java index 3dad7a51..da8b68c5 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Point.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Point.java @@ -34,6 +34,8 @@ import org.bukkit.entity.Player; @AllArgsConstructor public class Point { + public static final Point ZERO = new Point(0, 0, 0); + private final int x; private final int y; private final int z; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java index d28430a2..447a4fd5 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -46,9 +46,9 @@ public interface Region { Area getArea(); - Optional getBuildArea(); + Area getBuildArea(); - Optional getTestblockArea(); + Area getTestblockArea(); Optional getGameModeConfig(); @@ -56,6 +56,55 @@ public interface Region { interface Area { + Area EMPTY = new Area() { + @Override + public boolean isEmpty() { + return true; + } + + @Override + public Point getMinPoint(boolean extension) { + return Point.ZERO; + } + + @Override + public Point getMaxPoint(boolean extension) { + return Point.ZERO; + } + + @Override + public Point getCopyPoint() { + return Point.ZERO; + } + + @Override + public boolean inRegion(Location location, boolean extension) { + return false; + } + + @Override + public EditSession copy(boolean extension) { + return null; + } + + @Override + public void reset(@Nullable SchematicNode schematicNode, boolean extension) { + } + + @Override + public void forEachChunk(BiConsumer executor) { + } + + @Override + public boolean isChunkOutside(int chunkX, int chunkZ) { + return false; + } + }; + + default boolean isEmpty() { + return false; + } + Point getMinPoint(boolean extension); Point getMaxPoint(boolean extension);