From ef19959eb25249f6140a7c9ef3945b90a80627c4 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Mon, 23 Dec 2024 10:45:20 +0100 Subject: [PATCH] Fix some more build errors --- .../BauSystem_Main/src/BauSystem.properties | 1 - .../src/BauSystem_de.properties | 1 - .../bausystem/features/region/TNTCommand.java | 2 +- .../features/region/TestblockCommand.java | 4 +- .../features/util/KillAllCommand.java | 1 - .../util}/RegionSelectionType.java | 2 +- .../features/util/SelectCommand.java | 12 ++---- .../util/items/KillAllBauGuiItem.java | 2 +- .../region/utils/RegionExtensionType.java | 14 +++++++ .../bausystem/region/utils/RegionType.java | 39 +++++++++++++++++++ 10 files changed, 62 insertions(+), 16 deletions(-) rename BauSystem/BauSystem_Main/src/de/steamwar/bausystem/{region/utils => features/util}/RegionSelectionType.java (59%) create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionExtensionType.java create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionType.java diff --git a/BauSystem/BauSystem_Main/src/BauSystem.properties b/BauSystem/BauSystem_Main/src/BauSystem.properties index 20bb5f87..e7bf15eb 100644 --- a/BauSystem/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem/BauSystem_Main/src/BauSystem.properties @@ -940,7 +940,6 @@ SELECT_HELP=§8/§eselect §8[§7RegionsTyp§8] §8- §7Select a region type SELECT_EXTENSION_HELP=§8/§eselect §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Select a region type with or without extension SELECT_GLOBAL_REGION=§cThe global region cannot be selected SELECT_NO_TYPE=§cThis region has no {0} -SELECT_NO_EXTENSION=§cThis region has no extension SELECT_MESSAGE=§7WorldEdit selection set to {0}, {1}, {2} and {3}, {4}, {5} SKULL_HELP=§8/§eskull §8[§eplayer§8] §8-§7 Receive a player head SKULL_INVALID=§cInvalid player name diff --git a/BauSystem/BauSystem_Main/src/BauSystem_de.properties b/BauSystem/BauSystem_Main/src/BauSystem_de.properties index 8af9ba4b..101eba76 100644 --- a/BauSystem/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem/BauSystem_Main/src/BauSystem_de.properties @@ -878,7 +878,6 @@ SELECT_HELP=§8/§eselect §8[§7RegionsTyp§8] §8- §7Wähle einen RegionsTyp SELECT_EXTENSION_HELP=§8/§eselect §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Wähle einen RegionsTyp aus mit oder ohne Extension SELECT_GLOBAL_REGION=§cDie globale Region kannst du nicht auswählen SELECT_NO_TYPE=§cDiese Region hat keinen {0} -SELECT_NO_EXTENSION=§cDiese Region hat keine Ausfahrmaße SELECT_MESSAGE=§7WorldEdit auswahl auf {0}, {1}, {2} und {3}, {4}, {5} gesetzt SKULL_HELP=§8/§eskull §8[§eSpieler§8] §8-§7 Gibt einen SpielerKopf SKULL_INVALID=§cUngültiger Spieler diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTCommand.java index 0aa8a4c9..3c862f4f 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTCommand.java @@ -23,7 +23,7 @@ import de.steamwar.bausystem.BauSystem; 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.flagvalues.TNTMode; +import de.steamwar.bausystem.region.flags.TNTMode; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; 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 a56718c9..987d53db 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,8 +23,8 @@ 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.flags.flagvalues.ColorMode; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.utils.PasteBuilder; @@ -101,7 +101,7 @@ public class TestblockCommand extends SWCommand { .onlyColors(onlyColors) .removeTNT(removeTNT) .removeWater(removeWater) - .color(region.getPlain(Flag.COLOR, ColorMode.class).getColor()); + .color(region.getFlag(Flag.COLOR).orElse(ColorMode.YELLOW).getColor()); region.reset(pasteBuilder, RegionType.TESTBLOCK, regionExtensionType); RegionUtils.message(region, "REGION_TB_DONE"); } catch (SecurityException e) { 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 0812255e..b461939f 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 @@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; -import de.steamwar.bausystem.region.utils.RegionSelectionType; import de.steamwar.command.SWCommand; import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionSelectionType.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/RegionSelectionType.java similarity index 59% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionSelectionType.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/RegionSelectionType.java index 00d54bb2..4103dd42 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionSelectionType.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/RegionSelectionType.java @@ -1,4 +1,4 @@ -package de.steamwar.bausystem.region.utils; +package de.steamwar.bausystem.features.util; public enum RegionSelectionType { LOCAL, diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/SelectCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/SelectCommand.java index 7a11d678..73739e40 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/SelectCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/SelectCommand.java @@ -21,19 +21,15 @@ public class SelectCommand extends SWCommand { public void baurahmenCommand(@Validator Player p, RegionType regionType, @OptionalValue("NORMAL") RegionExtensionType regionExtensionType) { Region region = Region.getRegion(p.getLocation()); - if (region.isGlobal()) { + if (region.getType().isGlobal()) { BauSystem.MESSAGE.send("SELECT_GLOBAL_REGION", p); return; } - if (!region.hasType(regionType)) { + if (!regionType.getHasType().test(region)) { BauSystem.MESSAGE.send("SELECT_NO_TYPE", p, BauSystem.MESSAGE.parse(regionType.getChatValue(), p)); return; } - if (regionExtensionType == RegionExtensionType.EXTENSION && !region.hasExtensionType(regionType)) { - BauSystem.MESSAGE.send("SELECT_NO_EXTENSION", p); - return; - } setSelection(regionType, regionExtensionType, region, p); } @@ -44,8 +40,8 @@ public class SelectCommand extends SWCommand { } private void setSelection(RegionType regionType, RegionExtensionType regionExtensionType, Region region, Player p) { - Point minPoint = region.getMinPoint(regionType, regionExtensionType); - Point maxPoint = region.getMaxPoint(regionType, regionExtensionType); + Point minPoint = regionType.getToMinPoint().apply(region, regionExtensionType.isExtension()); + Point maxPoint = regionType.getToMaxPoint().apply(region, regionExtensionType.isExtension()); FlatteningWrapper.impl.setSelection(p, minPoint, maxPoint); BauSystem.MESSAGE.send("SELECT_MESSAGE", p, minPoint.getX(), minPoint.getY(), minPoint.getZ(), maxPoint.getX(), maxPoint.getY(), maxPoint.getZ()); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/KillAllBauGuiItem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/KillAllBauGuiItem.java index a5f76346..a4dd4882 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/KillAllBauGuiItem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/KillAllBauGuiItem.java @@ -23,7 +23,7 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.util.KillAllCommand; import de.steamwar.bausystem.linkage.specific.BauGuiItem; -import de.steamwar.bausystem.region.utils.RegionSelectionType; +import de.steamwar.bausystem.features.util.RegionSelectionType; import de.steamwar.inventory.SWItem; import de.steamwar.linkage.Linked; import de.steamwar.linkage.LinkedInstance; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionExtensionType.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionExtensionType.java new file mode 100644 index 00000000..b28031f5 --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionExtensionType.java @@ -0,0 +1,14 @@ +package de.steamwar.bausystem.region.utils; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@Getter +public enum RegionExtensionType { + NORMAL(false), + EXTENSION(true), + ; + + private final boolean extension; +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionType.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionType.java new file mode 100644 index 00000000..79d83ff7 --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionType.java @@ -0,0 +1,39 @@ +package de.steamwar.bausystem.region.utils; + +import de.steamwar.bausystem.region.Point; +import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.shared.EnumDisplay; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.function.Predicate; + +@AllArgsConstructor +@Getter +public enum RegionType implements EnumDisplay { + NORMAL("REGION_TYPE_NORMAL", + region -> true, + region -> null, + (region, extension) -> region.getMinPoint(), + (region, extension) -> region.getMaxPoint()), + BUILD("REGION_TYPE_BUILD", + region -> region.getBuildArea().isPresent(), + Region::getBuildArea, + (region, extension) -> region.getBuildArea().getMinPoint(extension), + (region, extension) -> region.getBuildArea().getMaxPoint(extension)), + TESTBLOCK("REGION_TYPE_ONLY_TB", + region -> region.getTestblockArea().isPresent(), + Region::getTestblockArea, + (region, extension) -> region.getTestblockArea().getMinPoint(extension), + (region, extension) -> region.getTestblockArea().getMaxPoint(extension)), + ; + + private String chatValue; + + private Predicate hasType; + private Function toInner; + private BiFunction toMinPoint; + private BiFunction toMaxPoint; +}