diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStone.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStone.java index f04fd5e9..3b7645b6 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStone.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStone.java @@ -48,12 +48,12 @@ public class DesignEndStone { private double maxBlastResistance; public DesignEndStone(Region region) { - this.minX = region.getMinPointBuild().getX(); - this.minY = region.getMinPointBuild().getY(); - this.minZ = region.getMinPointBuild().getZ(); - this.maxX = region.getMaxPointBuild().getX(); - this.maxY = region.getMaxPointBuild().getY(); - this.maxZ = region.getMaxPointBuild().getZ(); + this.minX = region.getBuildArea().getMinPoint(false).getX(); + this.minY = region.getBuildArea().getMinPoint(false).getY(); + this.minZ = region.getBuildArea().getMinPoint(false).getZ(); + this.maxX = region.getBuildArea().getMaxPoint(false).getX(); + this.maxY = region.getBuildArea().getMaxPoint(false).getY(); + this.maxZ = region.getBuildArea().getMaxPoint(false).getZ(); wsOrAs = region.getName().startsWith("ws") || region.getName().startsWith("as"); maxBlastResistance = wsOrAs ? 6.1 : 9.0; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerCommand.java index 503c1b47..b0dcba38 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerCommand.java @@ -39,7 +39,7 @@ public class LoadtimerCommand extends SWCommand { @Register(value = "start", description = {"LOADTIMER_HELP_START_2", "LOADTIMER_HELP_START_3"}) public void start(@Validator Player p, TimerMode mode) { Region r = Region.getRegion(p.getLocation()); - if (r.isGlobal()) return; + if (r.getType().isGlobal()) return; if (!Loadtimer.hasTimer(r)) Loadtimer.createLoadtimer(r, mode == TimerMode.HALF); } @@ -47,7 +47,7 @@ public class LoadtimerCommand extends SWCommand { @Register(value = "stop", description = "LOADTIMER_HELP_STOP") public void stop(@Validator Player p) { Region r = Region.getRegion(p.getLocation()); - if (r.isGlobal()) return; + if (r.getType().isGlobal()) return; if (Loadtimer.hasTimer(r)) Loadtimer.getTimer(r).delete(); } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerGuiItem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerGuiItem.java index f190d9f0..1df6c898 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerGuiItem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerGuiItem.java @@ -46,7 +46,7 @@ public class LoadtimerGuiItem extends BauGuiItem { @Override public ItemStack getItem(Player player) { Region r = Region.getRegion(player.getLocation()); - if (r.isGlobal()) + if (r.getType().isGlobal()) return new SWItem(Material.BOWL, BauSystem.MESSAGE.parse("LOADTIMER_GUI_GLOBAL", player)).getItemStack(); if (Loadtimer.hasTimer(r)) { return new SWItem(Material.BOW, BauSystem.MESSAGE.parse("LOADTIMER_GUI_STOP", player)).getItemStack(); @@ -58,7 +58,7 @@ public class LoadtimerGuiItem extends BauGuiItem { @Override public boolean click(ClickType click, Player p) { Region r = Region.getRegion(p.getLocation()); - if (r.isGlobal()) return false; + if (r.getType().isGlobal()) return false; if (Loadtimer.hasTimer(r)) { p.performCommand("lt stop"); } else { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java index e9183e32..6d5daa3d 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java @@ -31,8 +31,8 @@ import de.steamwar.bausystem.features.util.SelectCommand; import de.steamwar.bausystem.region.Point; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; -import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.ColorMode; +import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.shared.Pair; @@ -220,14 +220,14 @@ public class RegionCommand extends SWCommand { return; } - Point minPoint = region.getMinPoint(RegionType.BUILD, RegionExtensionType.NORMAL); - Point maxPoint = region.getMaxPoint(RegionType.BUILD, RegionExtensionType.NORMAL); + Point minPoint = region.getBuildArea().getMinPoint(false); + Point maxPoint = region.getBuildArea().getMaxPoint(false); switch (option) { case 0: break; case 1: - minPoint = region.getMinPoint(RegionType.BUILD, RegionExtensionType.EXTENSION); - maxPoint = region.getMaxPoint(RegionType.BUILD, RegionExtensionType.EXTENSION); + minPoint = region.getBuildArea().getMinPoint(true); + maxPoint = region.getBuildArea().getMaxPoint(true); break; case 2: Pair selection = WorldEditUtils.getSelection(p); @@ -312,7 +312,7 @@ public class RegionCommand extends SWCommand { public List tabCompletes(CommandSender commandSender, PreviousArguments previousArguments, String s) { Player p = (Player) commandSender; Region region = Region.getRegion(p.getLocation()); - if (region.isGlobal()) { + if (region.getType().isGlobal()) { return Collections.emptyList(); } return region.getPrototype().getSkinMap().keySet().stream().map(c -> c.replace(' ', '_')).collect(Collectors.toList()); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/StorageLib.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/StorageLib.java index 898b68a7..51a35bd7 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/StorageLib.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/StorageLib.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.script.lua.libs; import com.google.gson.*; import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.RegionSystem; import de.steamwar.core.Core; import de.steamwar.linkage.Linked; import de.steamwar.linkage.api.Disable; @@ -74,7 +75,7 @@ public class StorageLib implements LuaLib, Enable, Disable { jsonObject.keySet().forEach(key -> { map.put(key, fromJson(jsonObject.get(key))); }); - Region region = Region.getREGION_MAP().get(regionStorage.getName().substring(0, regionStorage.getName().length() - ".json".length())); + Region region = RegionSystem.INSTANCE.getRegion(regionStorage.getName().substring(0, regionStorage.getName().length() - ".json".length())).orElse(null); REGION_STORAGE.put(region, map); } catch (Exception e) {} } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/shieldprinting/ShieldPrintingCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/shieldprinting/ShieldPrintingCommand.java index 5bb60219..b09259fb 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/shieldprinting/ShieldPrintingCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/shieldprinting/ShieldPrintingCommand.java @@ -54,7 +54,7 @@ public class ShieldPrintingCommand extends SWCommand implements Listener { @Register public void genericCommand(@Validator Player player, ShieldPrintingState shieldPrintingState) { Region region = Region.getRegion(player.getLocation()); - if (region.isGlobal()) { + if (region.getType().isGlobal()) { BauSystem.MESSAGE.send("SHIELD_PRINTING_NO_REGION", player); return; } @@ -90,7 +90,7 @@ public class ShieldPrintingCommand extends SWCommand implements Listener { @Register("stop") public void stopCommand(@Validator Player player) { Region region = Region.getRegion(player.getLocation()); - if (region.isGlobal()) { + if (region.getType().isGlobal()) { BauSystem.MESSAGE.send("SHIELD_PRINTING_NO_REGION", player); return; } @@ -111,7 +111,7 @@ public class ShieldPrintingCommand extends SWCommand implements Listener { return false; } Region region = Region.getRegion(player.getLocation()); - if (region.isGlobal()) { + if (region.getType().isGlobal()) { messageSender.send("SHIELD_PRINTING_NO_REGION", player); return false; } 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 38725cf0..8ac94d2d 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 @@ -63,7 +63,7 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE @Register(description = "TECHHIDER_HELP") public void toggleHider(@Validator Player player) { Region region = Region.getRegion(player.getLocation()); - if (region.isGlobal()) { + if (region.getType().isGlobal()) { BauSystem.MESSAGE.send("TECHHIDER_GLOBAL", player); return; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRepository.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRepository.java index 899ea5f1..e20ec561 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRepository.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRepository.java @@ -1,6 +1,7 @@ package de.steamwar.bausystem.features.tracer; import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.RegionSystem; import lombok.Cleanup; import lombok.SneakyThrows; import org.bukkit.Bukkit; @@ -31,7 +32,8 @@ public class TraceRepository { @Cleanup ObjectInputStream reader = new ObjectInputStream(new GZIPInputStream(new FileInputStream(recordsFile))); UUID uuid = UUID.fromString(reader.readUTF()); - Region region = Region.getREGION_MAP().get(reader.readUTF()); + Region region = RegionSystem.INSTANCE.getRegion(reader.readUTF()).orElse(null); + if (region == null) return null; Date date = (Date) reader.readObject(); int serialisationVersion = reader.readInt(); if (serialisationVersion != SERIALISATION_VERSION) { 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 cad5b633..b18c54d7 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 @@ -64,7 +64,7 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen @Register(description = "XRAY_HELP") public void toggleHider(@Validator Player player) { Region region = Region.getRegion(player.getLocation()); - if (region.isGlobal()) { + if (region.getType().isGlobal()) { BauSystem.MESSAGE.send("XRAY_GLOBAL", player); return; } 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 53959621..6c8dce46 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -96,6 +96,11 @@ public interface Region { return ZERO; } + @Override + public Point getCopyPoint() { + return ZERO; + } + @Override public boolean inRegion(Location location, boolean extension) { return false; @@ -123,6 +128,8 @@ public interface Region { Point getMaxPoint(boolean extension); + Point getCopyPoint(); + boolean inRegion(Location location, boolean extension); Optional copy(boolean extension); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/bossbar/BossBarService.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/bossbar/BossBarService.java index e6ea2c16..7bb57c78 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/bossbar/BossBarService.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/bossbar/BossBarService.java @@ -51,7 +51,7 @@ public class BossBarService implements Listener { .computeIfAbsent(key, k -> { BossBar bossBar = Bukkit.createBossBar("", BarColor.WHITE, BarStyle.SOLID); bossBar.addPlayer(player); - if (region.isGlobal()) { + if (region.getType().isGlobal()) { return new GlobalBossbar(bossBar); } else { return new RegionedBossbar(bossBar, region, player);