From df9c7f122e4448ab36379e2f705191e1f71131bb Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Wed, 30 Jul 2025 18:49:54 +0200 Subject: [PATCH] Reduce to 34 compiler errors --- .../features/backup/BackupCommand.java | 11 ++--- .../features/bau/BauInfoBauGuiItem.java | 7 ++-- .../bausystem/features/bau/InfoCommand.java | 7 ++-- .../features/region/ColorCommand.java | 10 +++-- .../features/region/ItemsCommand.java | 6 +-- .../features/region/RegionCommand.java | 42 +++++++------------ .../features/region/ResetCommand.java | 13 +++--- .../features/region/TestblockCommand.java | 7 ++-- .../features/region/items/FireBauGuiItem.java | 4 +- .../region/items/FreezeBauGuiItem.java | 4 +- .../region/items/ProtectBauGuiItem.java | 4 +- .../features/region/items/TntBauGuiItem.java | 8 ++-- .../features/simulator/data/tnt/TNTPhase.java | 2 +- .../simulator/execute/StabDirection.java | 2 +- .../simulator/execute/StabFinalizer.java | 9 ++-- .../simulator/execute/StabGenerator.java | 10 ++--- .../features/simulator/execute/StabSetup.java | 2 +- .../bausystem/features/team/SkinCommand.java | 4 +- .../team/boundary/BoundaryViewer.java | 6 +-- .../features/util/PistonCalculator.java | 5 +-- .../bausystem/features/warp/WarpListener.java | 8 ++-- .../de/steamwar/bausystem/region/Region.java | 4 ++ .../bausystem/region/RegionUtils.java | 2 +- .../utils/bossbar/RegionedBossbar.java | 2 +- 24 files changed, 84 insertions(+), 95 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java index 919c08cd..f4d610ee 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java @@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.backup; import com.sk89q.worldedit.EditSession; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.flags.ChangedMode; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.utils.PasteBuilder; import de.steamwar.command.SWCommand; @@ -62,7 +63,7 @@ public class BackupCommand extends SWCommand { if (checkGlobalRegion(region, p)) { return; } - if (region.getFlag(Flag.CHANGED).isPresent()) { + if (region.getFlags().get(Flag.CHANGED).isWithDefault(ChangedMode.NO_CHANGE)) { BauSystem.MESSAGE.send("BACKUP_CREATE_NO_CHANGE", p); return; } @@ -86,12 +87,12 @@ public class BackupCommand extends SWCommand { return; } EditSession editSession = new PasteBuilder(new PasteBuilder.FileProvider(backupFile)) - .pastePoint(region.getMinPoint().add(region.getPrototype().getSizeX() / 2, 0, region.getPrototype().getSizeZ() / 2)) - .minPoint(region.getMinPoint()) - .maxPoint(region.getMaxPoint()) + .pastePoint(region.getArea().getMinPoint(false).add(region.getPrototype().getSizeX() / 2, 0, region.getPrototype().getSizeZ() / 2)) + .minPoint(region.getArea().getMinPoint(false)) + .maxPoint(region.getArea().getMaxPoint(false)) .waterLevel(region.getWaterLevel()) .run(); - region.remember(editSession); + region.getHistory().remember(editSession); BauSystem.MESSAGE.send("BACKUP_LOAD", p); } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java index d8ba9171..2940eac0 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java @@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.config.BauServer; import de.steamwar.bausystem.linkage.specific.BauGuiItem; +import de.steamwar.bausystem.region.FlagOptional; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.core.Core; @@ -62,9 +63,9 @@ public class BauInfoBauGuiItem extends BauGuiItem { if (flag == Flag.ITEMS && Core.getVersion() < 19) { continue; } - Flag.Value value = region.get(flag); - if (value != null) { - stringList.add(BauSystem.MESSAGE.parse("BAU_INFO_ITEM_LORE_" + flag.name(), player, BauSystem.MESSAGE.parse(value.getChatValue(), player))); + FlagOptional value = region.getFlags().get(flag); + if (value.isPresent()) { + stringList.add(BauSystem.MESSAGE.parse("BAU_INFO_ITEM_LORE_" + flag.name(), player, BauSystem.MESSAGE.parse(value.getWithDefault().getChatValue(), player))); } } itemStack.setLore(stringList); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java index 2d638888..40ec5d7a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java @@ -3,6 +3,7 @@ package de.steamwar.bausystem.features.bau; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.config.BauServer; +import de.steamwar.bausystem.region.FlagOptional; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.command.SWCommand; @@ -33,9 +34,9 @@ public class InfoCommand extends SWCommand { if (flag == Flag.PROTECT && region.getFloorLevel() == 0) { continue; } - Flag.Value value = region.get(flag); - if (value != null) { - BauSystem.MESSAGE.send("BAU_INFO_COMMAND_FLAG", p, BauSystem.MESSAGE.parse(flag.getChatValue(), p), BauSystem.MESSAGE.parse(value.getChatValue(), p)); + FlagOptional value = region.getFlags().get(flag); + if (value.isPresent()) { + BauSystem.MESSAGE.send("BAU_INFO_COMMAND_FLAG", p, BauSystem.MESSAGE.parse(flag.getChatValue(), p), BauSystem.MESSAGE.parse(value.getWithDefault().getChatValue(), p)); } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java index 34401970..adcd1f97 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java @@ -52,7 +52,9 @@ public class ColorCommand extends SWCommand { @Register(description = "REGION_COLOR_HELP_COLOR_TYPE") public void genericColorSet(@Validator Player p, ColorMode color, ColorizationType colorizationType) { if (colorizationType == ColorizationType.GLOBAL) { - Region.setGlobal(Flag.COLOR, color); + Region.getRegions().forEach(region -> { + region.getFlags().set(Flag.COLOR, color); + }); BauSystem.MESSAGE.send("REGION_COLOR_GLOBAL", p, BauSystem.MESSAGE.parse(color.getChatValue(), p)); return; } @@ -61,13 +63,13 @@ public class ColorCommand extends SWCommand { BauSystem.MESSAGE.send("REGION_COLOR_NO_REGION", p); return; } - region.setFlag(Flag.COLOR, color); + region.getFlags().set(Flag.COLOR, color); try { PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL))) .ignoreAir(true) .onlyColors(true) - .color(color.getColor()); - region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL); + .color(color); + region.getArea().reset(pasteBuilder, false); RegionUtils.message(region, "REGION_REGION_COLORED"); RegionUtils.message(region, "REGION_REGION_COLORED_FAILED"); } catch (SecurityException e) { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsCommand.java index 3003912c..7a8c108a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsCommand.java @@ -55,11 +55,11 @@ public class ItemsCommand extends SWCommand { } private boolean toggle(Region region) { - if (region.isFlag(Flag.ITEMS, ItemMode.ACTIVE)) { - region.setFlag(Flag.ITEMS, ItemMode.INACTIVE); + if (region.getFlags().get(Flag.ITEMS).isWithDefault(ItemMode.ACTIVE)) { + region.getFlags().set(Flag.ITEMS, ItemMode.INACTIVE); return false; } else { - region.setFlag(Flag.ITEMS, ItemMode.ACTIVE); + region.getFlags().set(Flag.ITEMS, ItemMode.ACTIVE); return true; } } 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 6d5daa3d..b1dafb65 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,9 +31,7 @@ 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.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; import de.steamwar.bausystem.utils.FlatteningWrapper; @@ -83,7 +81,7 @@ public class RegionCommand extends SWCommand { Region region = Region.getRegion(p.getLocation()); if (checkGlobalRegion(region, p)) return; - if (region.undo()) { + if (region.getHistory().undo()) { RegionUtils.message(region, "REGION_REGION_UNDID"); } else { BauSystem.MESSAGE.send("REGION_REGION_NOTHING_UNDO", p); @@ -97,7 +95,7 @@ public class RegionCommand extends SWCommand { return; } - if (region.redo()) { + if (region.getHistory().redo()) { RegionUtils.message(region, "REGION_REGION_REDID"); } else { BauSystem.MESSAGE.send("REGION_REGION_NOTHING_REDO", p); @@ -112,8 +110,8 @@ public class RegionCommand extends SWCommand { try { PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL))) .ignoreAir(true) - .color(region.getPlain(Flag.COLOR, ColorMode.class).getColor()); - region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL); + .color(region.getFlags().get(Flag.COLOR).getWithDefault()); + region.getArea().reset(pasteBuilder, true); RegionUtils.message(region, "REGION_REGION_RESTORED"); } catch (SecurityException e) { BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p); @@ -134,8 +132,8 @@ public class RegionCommand extends SWCommand { try { PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node)) .ignoreAir(true) - .color(region.getPlain(Flag.COLOR, ColorMode.class).getColor()); - region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL); + .color(region.getFlags().get(Flag.COLOR).getWithDefault()); + region.getArea().reset(pasteBuilder, true); RegionUtils.message(region, "REGION_REGION_RESTORED"); } catch (SecurityException e) { BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p); @@ -149,11 +147,11 @@ public class RegionCommand extends SWCommand { if (checkGlobalRegion(region, p)) { return; } - if (region.getCopyPoint() == null) { + if (region.getBuildArea().isEmpty()) { BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p); return; } - p.teleport(region.getCopyPoint().toLocation(p, 0.5, 0, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND); + p.teleport(region.getBuildArea().getCopyPoint().toLocation(p, 0.5, 0, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND); BauSystem.MESSAGE.send("REGION_REGION_TP_COPY", p); } @@ -164,11 +162,11 @@ public class RegionCommand extends SWCommand { if (checkGlobalRegion(region, p)) { return; } - if (region.getTestBlockPoint() == null) { + if (region.getTestblockArea().isEmpty()) { BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p); return; } - p.teleport(region.getTestBlockPoint().toLocation(p, 0.5, 0, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND); + p.teleport(region.getTestblockArea().getCopyPoint().toLocation(p, 0.5, 0, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND); BauSystem.MESSAGE.send("REGION_REGION_TP_TEST_BLOCK", p); } @@ -211,14 +209,10 @@ public class RegionCommand extends SWCommand { if (checkGlobalRegion(region, p)) { return; } - if (!region.hasType(RegionType.BUILD)) { + if (region.getBuildArea().isEmpty()) { BauSystem.MESSAGE.send("REGION_REGION_NO_BUILD", p); return; } - if (region.getCopyPoint() == null) { - BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p); - return; - } Point minPoint = region.getBuildArea().getMinPoint(false); Point maxPoint = region.getBuildArea().getMaxPoint(false); @@ -238,7 +232,7 @@ public class RegionCommand extends SWCommand { break; } - Clipboard clipboard = FlatteningWrapper.impl.copy(minPoint, maxPoint, region.getCopyPoint()); + Clipboard clipboard = FlatteningWrapper.impl.copy(minPoint, maxPoint, region.getBuildArea().getCopyPoint()); WorldEdit.getInstance() .getSessionManager() .get(BukkitAdapter.adapt(p)) @@ -252,14 +246,10 @@ public class RegionCommand extends SWCommand { if (checkGlobalRegion(region, p)) { return; } - if (!region.hasType(RegionType.BUILD)) { + if (region.getBuildArea().isEmpty()) { BauSystem.MESSAGE.send("REGION_REGION_NO_BUILD", p); return; } - if (region.getCopyPoint() == null) { - BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p); - return; - } ClipboardHolder clipboardHolder = WorldEdit.getInstance() .getSessionManager() @@ -287,13 +277,13 @@ public class RegionCommand extends SWCommand { } try (EditSession e = WorldEditUtils.getEditSession(p)) { - Operations.completeBlindly(clipboardHolder.createPaste(e).ignoreAirBlocks(ignoreAir).to(toBlockVector3(region.getCopyPoint())).build()); + Operations.completeBlindly(clipboardHolder.createPaste(e).ignoreAirBlocks(ignoreAir).to(toBlockVector3(region.getBuildArea().getCopyPoint())).build()); WorldEditUtils.addToPlayer(p, e); if (selectPasted) { Clipboard clipboard = clipboardHolder.getClipboards().get(0); - BlockVector3 minPointSelection = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()).add(toBlockVector3(region.getCopyPoint())); - BlockVector3 maxPointSelection = clipboard.getRegion().getMaximumPoint().subtract(clipboard.getOrigin()).add(toBlockVector3(region.getCopyPoint())); + BlockVector3 minPointSelection = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()).add(toBlockVector3(region.getBuildArea().getCopyPoint())); + BlockVector3 maxPointSelection = clipboard.getRegion().getMaximumPoint().subtract(clipboard.getOrigin()).add(toBlockVector3(region.getBuildArea().getCopyPoint())); FlatteningWrapper.impl.setSelection(p, Point.fromBlockVector3(minPointSelection), Point.fromBlockVector3(maxPointSelection)); } BauSystem.MESSAGE.send("REGION_REGION_PASTE_DONE", p); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java index cc12f7b8..e494ac7d 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java @@ -24,9 +24,8 @@ import de.steamwar.bausystem.config.BauServer; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionSystem; 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.utils.RegionExtensionType; +import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.utils.PasteBuilder; import de.steamwar.command.SWCommand; @@ -56,10 +55,10 @@ public class ResetCommand extends SWCommand { if (region == null) return; try { PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL))) - .color(region.getPlain(Flag.COLOR, ColorMode.class).getColor()); - region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL); + .color(region.getFlags().get(Flag.COLOR).getWithDefault()); + region.getArea().reset(pasteBuilder, false); for (Flag value : Flag.getResetFlags()) { - region.set(value, value.getDefaultValue()); + region.getFlags().set(value, value.getDefaultValue()); } RegionUtils.message(region, "REGION_RESET_RESETED"); } catch (SecurityException e) { @@ -88,8 +87,8 @@ public class ResetCommand extends SWCommand { } try { PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node)) - .color(region.getPlain(Flag.COLOR, ColorMode.class).getColor()); - region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL); + .color(region.getFlags().get(Flag.COLOR).getWithDefault()); + region.getArea().reset(pasteBuilder, true); RegionUtils.message(region, "REGION_RESET_RESETED"); } catch (SecurityException e) { BauSystem.MESSAGE.send("REGION_RESET_ERROR", p); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TestblockCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TestblockCommand.java index 987d53db..ca307e6d 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TestblockCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TestblockCommand.java @@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.config.BauServer; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; -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; @@ -101,8 +100,8 @@ public class TestblockCommand extends SWCommand { .onlyColors(onlyColors) .removeTNT(removeTNT) .removeWater(removeWater) - .color(region.getFlag(Flag.COLOR).orElse(ColorMode.YELLOW).getColor()); - region.reset(pasteBuilder, RegionType.TESTBLOCK, regionExtensionType); + .color(region.getFlags().get(Flag.COLOR).getWithDefault()); + region.getTestblockArea().reset(pasteBuilder, regionExtensionType == RegionExtensionType.EXTENSION); RegionUtils.message(region, "REGION_TB_DONE"); } catch (SecurityException e) { BauSystem.MESSAGE.send("REGION_TB_ERROR", p); @@ -155,7 +154,7 @@ public class TestblockCommand extends SWCommand { private Region regionCheck(Player player) { Region region = Region.getRegion(player.getLocation()); - if (!region.hasType(RegionType.TESTBLOCK)) { + if (region.getTestblockArea().isEmpty()) { BauSystem.MESSAGE.send("REGION_TB_NO_REGION", player); return null; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FireBauGuiItem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FireBauGuiItem.java index 4a69b708..e41be46b 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FireBauGuiItem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FireBauGuiItem.java @@ -42,10 +42,10 @@ public class FireBauGuiItem extends BauGuiItem { @Override public ItemStack getItem(Player player) { Region region = Region.getRegion(player.getLocation()); - if (!region.hasFlag(Flag.FIRE).isApplicable()) { + if (!region.getFlags().has(Flag.FIRE).isApplicable()) { return new SWItem(Material.BARRIER, "").getItemStack(); } - if (region.isFlag(Flag.FIRE, FireMode.ALLOW)) { + if (region.getFlags().get(Flag.FIRE).isWithDefault(FireMode.ALLOW)) { return new SWItem(Material.FIRE_CHARGE, BauSystem.MESSAGE.parse("REGION_ITEM_FIRE_ALLOW", player)).getItemStack(); } else { return new SWItem(Material.FIREWORK_STAR, BauSystem.MESSAGE.parse("REGION_ITEM_FIRE_DISALLOW", player)).getItemStack(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FreezeBauGuiItem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FreezeBauGuiItem.java index 0fecdfa8..13f1f9eb 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FreezeBauGuiItem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FreezeBauGuiItem.java @@ -42,10 +42,10 @@ public class FreezeBauGuiItem extends BauGuiItem { @Override public ItemStack getItem(Player player) { Region region = Region.getRegion(player.getLocation()); - if (!region.hasFlag(Flag.FREEZE).isApplicable()) { + if (!region.getFlags().has(Flag.FREEZE).isApplicable()) { return new SWItem(Material.BARRIER, "").getItemStack(); } - if (region.isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { + if (region.getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) { return new SWItem(Material.GUNPOWDER, BauSystem.MESSAGE.parse("REGION_ITEM_FREEZE_ALLOW", player)).getItemStack(); } else { return new SWItem(Material.REDSTONE, BauSystem.MESSAGE.parse("REGION_ITEM_FREEZE_DISALLOW", player)).getItemStack(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ProtectBauGuiItem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ProtectBauGuiItem.java index 5453414e..75bf4eb0 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ProtectBauGuiItem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ProtectBauGuiItem.java @@ -43,10 +43,10 @@ public class ProtectBauGuiItem extends BauGuiItem { @Override public ItemStack getItem(Player player) { Region region = Region.getRegion(player.getLocation()); - if (!region.hasFlag(Flag.PROTECT).isApplicable()) { + if (!region.getFlags().has(Flag.PROTECT).isApplicable()) { return new SWItem(Material.BARRIER, "").getItemStack(); } - if (region.isFlag(Flag.PROTECT, ProtectMode.ACTIVE)) { + if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.ACTIVE)) { return SWUtils.setCustomModelData(new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_ALLOW", player)), 1).getItemStack(); } else { return SWUtils.setCustomModelData(new SWItem(Material.STONE, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_DISALLOW", player)), 1).getItemStack(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TntBauGuiItem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TntBauGuiItem.java index 77969ff8..c633c569 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TntBauGuiItem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TntBauGuiItem.java @@ -43,7 +43,7 @@ public class TntBauGuiItem extends BauGuiItem { @Override public ItemStack getItem(Player player) { - switch (Region.getRegion(player.getLocation()).getPlain(Flag.TNT, TNTMode.class)) { + switch (Region.getRegion(player.getLocation()).getFlags().get(Flag.TNT).getWithDefault()) { case DENY: return new SWItem(Material.MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_OFF", player)).getItemStack(); case ONLY_TB: @@ -58,12 +58,12 @@ public class TntBauGuiItem extends BauGuiItem { @Override public boolean click(ClickType click, Player p) { if (click == ClickType.LEFT) { - switch (Region.getRegion(p.getLocation()).getPlain(Flag.TNT, TNTMode.class)) { + switch (Region.getRegion(p.getLocation()).getFlags().get(Flag.TNT).getWithDefault()) { case DENY: updateTntMode(TNTMode.ALLOW, p); break; case ALLOW: - if (Region.getRegion(p.getLocation()).hasType(RegionType.BUILD) && Region.getRegion(p.getLocation()).hasType(RegionType.TESTBLOCK)) { + if (!Region.getRegion(p.getLocation()).getBuildArea().isEmpty() && !Region.getRegion(p.getLocation()).getTestblockArea().isEmpty()) { updateTntMode(TNTMode.ONLY_TB, p); break; } @@ -77,7 +77,7 @@ public class TntBauGuiItem extends BauGuiItem { updateTntMode(TNTMode.ALLOW, p); p.closeInventory(); })); - if (Region.getRegion(p.getLocation()).hasType(RegionType.BUILD) && Region.getRegion(p.getLocation()).hasType(RegionType.TESTBLOCK)) { + if (!Region.getRegion(p.getLocation()).getBuildArea().isEmpty() && !Region.getRegion(p.getLocation()).getTestblockArea().isEmpty()) { selector.setItem(3, new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_SELECTOR_ONLY_TB", p), clickType -> { updateTntMode(TNTMode.ONLY_TB, p); p.closeInventory(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/tnt/TNTPhase.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/tnt/TNTPhase.java index 20fe8d41..0ac9d0e9 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/tnt/TNTPhase.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/tnt/TNTPhase.java @@ -64,7 +64,7 @@ public final class TNTPhase extends SimulatorPhase { @Override public void accept(World world) { Location location = position.toLocation(world); - if (Region.getRegion(location).getFlag(Flag.FREEZE).isPresent()) return; + if (Region.getRegion(location).getFlags().get(Flag.FREEZE).isPresent()) return; TNTPrimed tnt = world.spawn(location, TNTPrimed.class); if (!xJump) tnt.setVelocity(tnt.getVelocity().setX(0)); if (!yJump) tnt.setVelocity(tnt.getVelocity().setY(0)); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/StabDirection.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/StabDirection.java index 4be5284b..9adeaaaf 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/StabDirection.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/StabDirection.java @@ -45,7 +45,7 @@ public class StabDirection extends StabStep { @Override protected void start() { try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) { - e.setBlocks((com.sk89q.worldedit.regions.Region) new CuboidRegion(data.region.getMinPointTestblockExtension().toBlockVector3(), data.region.getMaxPointTestblockExtension().toBlockVector3()), Objects.requireNonNull(BlockTypes.AIR).getDefaultState().toBaseBlock()); + e.setBlocks((com.sk89q.worldedit.regions.Region) new CuboidRegion(data.region.getTestblockArea().getMinPoint(true).toBlockVector3(), data.region.getTestblockArea().getMaxPoint(true).toBlockVector3()), Objects.requireNonNull(BlockTypes.AIR).getDefaultState().toBaseBlock()); } Trace trace = TraceRecorder.instance.startRecording(data.region); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/StabFinalizer.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/StabFinalizer.java index 79148cc3..daa8876a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/StabFinalizer.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/StabFinalizer.java @@ -20,10 +20,7 @@ package de.steamwar.bausystem.features.simulator.execute; import de.steamwar.bausystem.features.tracer.TraceRecorder; -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.utils.PasteBuilder; import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar; @@ -38,10 +35,10 @@ public class StabFinalizer extends StabStep { try { PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard); PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider); - if (data.region.hasFlag(Flag.COLOR).isReadable()) { - pasteBuilder.color(data.region.getFlag(Flag.COLOR).get().getColor()); + if (data.region.getFlags().has(Flag.COLOR).isReadable()) { + pasteBuilder.color(data.region.getFlags().get(Flag.COLOR).getWithDefault()); } - data.region.reset(pasteBuilder, RegionType.TESTBLOCK, RegionExtensionType.EXTENSION); + data.region.getTestblockArea().reset(pasteBuilder, true); } catch (SecurityException e) { stop(); throw e; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/StabGenerator.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/StabGenerator.java index a53e0093..3a598c1e 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/StabGenerator.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/StabGenerator.java @@ -22,8 +22,6 @@ package de.steamwar.bausystem.features.simulator.execute; import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase; import de.steamwar.bausystem.region.Region; 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.utils.PasteBuilder; import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar; import org.bukkit.Bukkit; @@ -55,7 +53,7 @@ public class StabGenerator extends StabStep implements Listener { public void onEntityExplode(EntityExplodeEvent event) { if (Region.getRegion(event.getEntity().getLocation()) == data.region) { event.blockList().forEach(block -> { - if (!data.region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) + if (!data.region.getTestblockArea().inRegion(block.getLocation(), true)) return; int component = data.direction.component.apply(block.getLocation().toVector()); destroyedBlocksPerSlice.computeIfAbsent(component, __ -> new HashSet<>()) @@ -73,10 +71,10 @@ public class StabGenerator extends StabStep implements Listener { try { PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard); PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider); - if (data.region.hasFlag(Flag.COLOR).isReadable()) { - pasteBuilder.color(data.region.getFlag(Flag.COLOR).get().getColor()); + if (data.region.getFlags().has(Flag.COLOR).isReadable()) { + pasteBuilder.color(data.region.getFlags().get(Flag.COLOR).getWithDefault()); } - data.region.reset(pasteBuilder, RegionType.TESTBLOCK, RegionExtensionType.EXTENSION); + data.region.getTestblockArea().reset(pasteBuilder, true); } catch (SecurityException e) { stop(); throw e; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/StabSetup.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/StabSetup.java index 9662a638..78f89d8a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/StabSetup.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/execute/StabSetup.java @@ -72,7 +72,7 @@ public class StabSetup extends StabStep { if (TraceRecorder.instance.isAutoTraceEnabledInRegion(data.region)) { TraceRecorder.instance.removeAutoTraceRegion(data.region); } - data.clipboard = FlatteningWrapper.impl.copy(data.region.getMinPointTestblockExtension(), data.region.getMaxPointTestblockExtension(), data.region.getTestBlockPoint()); + data.clipboard = FlatteningWrapper.impl.copy(data.region.getTestblockArea().getMinPoint(true), data.region.getTestblockArea().getMaxPoint(true), data.region.getTestblockArea().getCopyPoint()); new StabDirection(data); } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/team/SkinCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/team/SkinCommand.java index ae466066..b2c2bc8c 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/team/SkinCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/team/SkinCommand.java @@ -89,9 +89,9 @@ public class SkinCommand extends SWCommand { return; } - Region.copy(region.getMinPoint(), region.getMaxPoint(), arenaFile); + Region.copy(region.getArea().getMinPoint(false), region.getArea().getMaxPoint(false), arenaFile); if (testblockFile != null) { - Region.copy(region.getMinPointTestblock(), region.getMaxPointTestblock(), testblockFile); + Region.copy(region.getTestblockArea().getMinPoint(false), region.getTestblockArea().getMaxPoint(false), testblockFile); } YAPIONObject yapionObject = new YAPIONObject(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/team/boundary/BoundaryViewer.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/team/boundary/BoundaryViewer.java index f6636c4f..3994eee8 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/team/boundary/BoundaryViewer.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/team/boundary/BoundaryViewer.java @@ -53,11 +53,11 @@ public class BoundaryViewer implements Listener { } private void showRegion(Region region, Player player) { - drawCuboid(player, TrickyParticleWrapper.impl.getVillagerHappy(), region.getMinPoint(), region.getMaxPoint()); - if (region.getTestblockArea().isPresent()) { + drawCuboid(player, TrickyParticleWrapper.impl.getVillagerHappy(), region.getArea().getMinPoint(false), region.getArea().getMaxPoint(false)); + if (!region.getTestblockArea().isEmpty()) { drawCuboid(player, Particle.END_ROD, region.getTestblockArea().getMinPoint(true), region.getTestblockArea().getMaxPoint(true)); } - if (region.getBuildArea().isPresent()) { + if (!region.getBuildArea().isEmpty()) { drawCuboid(player, Particle.END_ROD, region.getBuildArea().getMinPoint(true), region.getBuildArea().getMaxPoint(true)); } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculator.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculator.java index 9aaf4a15..ddc98cd5 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculator.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculator.java @@ -21,10 +21,7 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.entity.CWireframe; -import de.steamwar.entity.REntity; -import de.steamwar.entity.REntityServer; -import de.steamwar.entity.RTextDisplay; +import de.steamwar.entity.*; import de.steamwar.linkage.Linked; import de.steamwar.linkage.MinVersion; import org.bukkit.Bukkit; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java index 8940b1ee..655b36f9 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java @@ -91,11 +91,11 @@ public class WarpListener implements Listener { locations.put(warp.getName(), warp.getLocation()); }); Region region = Region.getRegion(p.getLocation()); - if (region.getCopyPoint() != null) { - locations.put("Copy", region.getCopyPoint().toLocation(p).add(0.5, 0, 0.5)); + if (region.getBuildArea().getCopyPoint() != null) { + locations.put("Copy", region.getBuildArea().getCopyPoint().toLocation(p).add(0.5, 0, 0.5)); } - if (region.getTestBlockPoint() != null) { - locations.put("TestBlock", region.getTestBlockPoint().toLocation(p).add(0.5, 0, 0.5)); + if (region.getTestblockArea().getCopyPoint() != null) { + locations.put("TestBlock", region.getTestblockArea().getCopyPoint().toLocation(p).add(0.5, 0, 0.5)); } } 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 447a4fd5..e2d37c2a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -28,9 +28,13 @@ import java.io.File; import java.util.Optional; import java.util.UUID; import java.util.function.BiConsumer; +import java.util.stream.Stream; public interface Region { + static Stream getRegions() { + return RegionSystem.INSTANCE.getRegions(); + } static Region getRegion(Location location) { return RegionSystem.INSTANCE.get(location); } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionUtils.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionUtils.java index 1559025b..be9b0887 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionUtils.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionUtils.java @@ -41,7 +41,7 @@ public class RegionUtils { public void forEachInRegion(Region region, Consumer consumer) { Bukkit.getOnlinePlayers() .stream() - .filter(player -> region.inRegion(player.getLocation())) + .filter(player -> region.getArea().inRegion(player.getLocation(), false)) .filter(player -> !region.getType().isGlobal() || Region.getRegion(player.getLocation()).getType().isGlobal()) .forEach(consumer); } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/bossbar/RegionedBossbar.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/bossbar/RegionedBossbar.java index 843c8500..0df1ca4c 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/bossbar/RegionedBossbar.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/bossbar/RegionedBossbar.java @@ -118,7 +118,7 @@ public class RegionedBossbar implements BauSystemBossbar, Listener { @EventHandler public void onPlayerMove(PlayerMoveEvent event) { if (event.getPlayer() != player) return; - if (region.inRegion(event.getTo())) { + if (region.getArea().inRegion(event.getTo(), false)) { bossBar.addPlayer(player); } else { bossBar.removePlayer(player);