From 5c13b8bde5219b7e92848506f430a9157f4d6c6c Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 20 May 2024 13:55:30 +0200 Subject: [PATCH] Add basic RegionAPI to PluginBase --- BauSystem_PluginBase/build.gradle | 2 +- .../de/steamwar/bausystem/region/Flag.java | 79 ++++++++ .../bausystem/region/GlobalRegion.java | 174 ++++++++++++++++++ .../de/steamwar/bausystem/region/Point.java | 76 ++++++++ .../de/steamwar/bausystem/region/Region.java | 147 +++++++++++++++ .../bausystem/region/RegionSystem.java | 41 +++++ .../bausystem/region/flags/ChangedMode.java | 56 ++++++ .../bausystem/region/flags/ColorMode.java | 70 +++++++ .../bausystem/region/flags/FireMode.java | 59 ++++++ .../bausystem/region/flags/FreezeMode.java | 60 ++++++ .../bausystem/region/flags/ItemMode.java | 59 ++++++ .../bausystem/region/flags/ProtectMode.java | 59 ++++++ .../bausystem/region/flags/TNTMode.java | 58 ++++++ .../bausystem/region/flags/TestblockMode.java | 61 ++++++ 14 files changed, 1000 insertions(+), 1 deletion(-) create mode 100644 BauSystem_PluginBase/src/de/steamwar/bausystem/region/Flag.java create mode 100644 BauSystem_PluginBase/src/de/steamwar/bausystem/region/GlobalRegion.java create mode 100644 BauSystem_PluginBase/src/de/steamwar/bausystem/region/Point.java create mode 100644 BauSystem_PluginBase/src/de/steamwar/bausystem/region/Region.java create mode 100644 BauSystem_PluginBase/src/de/steamwar/bausystem/region/RegionSystem.java create mode 100644 BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/ChangedMode.java create mode 100644 BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/ColorMode.java create mode 100644 BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/FireMode.java create mode 100644 BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/FreezeMode.java create mode 100644 BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/ItemMode.java create mode 100644 BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/ProtectMode.java create mode 100644 BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/TNTMode.java create mode 100644 BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/TestblockMode.java diff --git a/BauSystem_PluginBase/build.gradle b/BauSystem_PluginBase/build.gradle index 4ff398a4..246d56f6 100644 --- a/BauSystem_PluginBase/build.gradle +++ b/BauSystem_PluginBase/build.gradle @@ -53,7 +53,7 @@ dependencies { // compileOnly swdep('Spigot-1.20') compileOnly swdep('SpigotCore') - // compileOnly swdep('FastAsyncWorldEdit-1.18') + compileOnly swdep('FastAsyncWorldEdit-1.18') // compileOnly swdep('AxiomPaper') // implementation 'org.luaj:luaj-jse:3.0.1' diff --git a/BauSystem_PluginBase/src/de/steamwar/bausystem/region/Flag.java b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/Flag.java new file mode 100644 index 00000000..ddd3c570 --- /dev/null +++ b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/Flag.java @@ -0,0 +1,79 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.region; + +import de.steamwar.bausystem.region.flags.*; +import lombok.Getter; + +import java.util.EnumSet; +import java.util.Set; + +@Getter +public enum Flag { + + COLOR(ColorMode.class, ColorMode.YELLOW), + TNT(TNTMode.class, TNTMode.ONLY_TB), + FIRE(FireMode.class, FireMode.ALLOW), + FREEZE(FreezeMode.class, FreezeMode.INACTIVE), + PROTECT(ProtectMode.class, ProtectMode.ACTIVE), + ITEMS(ItemMode.class, ItemMode.INACTIVE), + TESTBLOCK(TestblockMode.class, TestblockMode.NO_VALUE), + CHANGED(ChangedMode.class, ChangedMode.NO_CHANGE), + ; + + @Getter + private static final Set flags; + + static { + flags = EnumSet.allOf(Flag.class); + } + + private final Class> valueType; + private final Flag.Value defaultValue; + private final Value[] values; + + & Value> Flag(final Class> valueType, final Flag.Value defaultValue) { + this.valueType = valueType; + this.defaultValue = defaultValue; + this.values = defaultValue.getValues(); + } + + public Value getFlagValueOf(final String name) { + return this.defaultValue.getValueOf(name); + } + + @Override + public String toString() { + return this.name().toLowerCase(); + } + + public interface Value & Value> { + + T getValue(); + + T getValueOf(final String name); + + T[] getValues(); + + default String getName() { + return this.getValue().name().toLowerCase(); + } + } +} diff --git a/BauSystem_PluginBase/src/de/steamwar/bausystem/region/GlobalRegion.java b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/GlobalRegion.java new file mode 100644 index 00000000..9f07319c --- /dev/null +++ b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/GlobalRegion.java @@ -0,0 +1,174 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.region; + +import com.sk89q.worldedit.EditSession; +import de.steamwar.sql.SchematicNode; +import org.bukkit.Location; + +import javax.annotation.Nullable; +import java.io.File; +import java.util.Optional; + +public class GlobalRegion implements Region { + + public static final Region GLOBAL_REGION = new GlobalRegion(); + + private GlobalRegion() { + } + + @Override + public RegionType getRegionType() { + return RegionType.GLOBAL; + } + + @Override + public HasFlagResult hasFlag(Flag flag) { + return switch (flag) { + case TNT, FIRE, FREEZE, ITEMS -> HasFlagResult.WRITABLE; + default -> HasFlagResult.NOT_APPLICABLE; + }; + } + + @Override + public void setFlag(Flag flag, Flag.Value value) { + + } + + @Override + public Flag.Value getFlag(Flag flagType) { + return null; + } + + @Override + public Point getMinPoint() { + return new Point(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE); + } + + @Override + public Point getMaxPoint() { + return new Point(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); + } + + @Override + public boolean inRegion(Location location) { + return true; + } + + @Override + public Optional getBuildMinPoint(boolean extension) { + return Optional.empty(); + } + + @Override + public Optional getBuildMaxPoint(boolean extension) { + return Optional.empty(); + } + + @Override + public boolean inBuildRegion(Location location, boolean extension) { + return false; + } + + @Override + public Optional getTestblockMinPoint(boolean extension) { + return Optional.empty(); + } + + @Override + public Optional getTestblockMaxPoint(boolean extension) { + return Optional.empty(); + } + + @Override + public boolean inTestblockRegion(Location location, boolean extension) { + return false; + } + + @Override + public void forEachChunk(ChunkCoordinatesConsumer consumer) { + + } + + @Override + public ChunkCoordinatePredicate getChunkOutsidePredicate() { + return (chunkX, chunkZ) -> false; + } + + @Override + public Optional getBuildChunkOutsidePredicate(boolean extension) { + return Optional.empty(); + } + + @Override + public Optional getTestblockChunkOutsidePredicate(boolean extension) { + return Optional.empty(); + } + + @Override + public Optional getGameModeConfig() { + return Optional.empty(); + } + + @Override + public Optional copy() { + return Optional.empty(); + } + + @Override + public Optional copyBuild(boolean extension) { + return Optional.empty(); + } + + @Override + public Optional copyTestblock(boolean extension) { + return Optional.empty(); + } + + @Override + public void reset() { + } + + @Override + public void resetBuild(@Nullable SchematicNode schematicNode, boolean extension) { + } + + @Override + public void resetBuildWireframe(boolean extension) { + } + + @Override + public void resetTestblock(@Nullable SchematicNode schematicNode, boolean extension) { + } + + @Override + public void remember(EditSession editSession) { + } + + @Override + public boolean undo() { + return false; + } + + @Override + public boolean redo() { + return false; + } +} diff --git a/BauSystem_PluginBase/src/de/steamwar/bausystem/region/Point.java b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/Point.java new file mode 100644 index 00000000..b73d0988 --- /dev/null +++ b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/Point.java @@ -0,0 +1,76 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2021 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.region; + +import com.sk89q.worldedit.math.BlockVector3; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.ToString; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Player; + +@Getter +@ToString +@EqualsAndHashCode +@AllArgsConstructor +public class Point { + + private final int x; + private final int y; + private final int z; + + public static Point fromLocation(final Location location) { + return new Point(location.getBlockX(), location.getBlockY(), location.getBlockZ()); + } + + public static Point fromBlockVector3(final BlockVector3 blockVector3) { + return new Point(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ()); + } + + public Point add(int x, int y, int z) { + return new Point(this.x + x, this.y + y, this.z + z); + } + + public Point subtract(int x, int y, int z) { + return new Point(this.x - x, this.y - y, this.z - z); + } + + public Point divide(int factor) { + return new Point(x / factor, y / factor, z / factor); + } + + public Location toLocation(World world) { + return new Location(world, x, y, z); + } + + public Location toLocation(World world, double dx, double dy, double dz) { + return new Location(world, x + dx, y + dy, z + dz); + } + + public Location toLocation(Player player) { + return new Location(player.getWorld(), x, y, z, player.getLocation().getYaw(), player.getLocation().getPitch()); + } + + public Location toLocation(Player player, double dx, double dy, double dz) { + return new Location(player.getWorld(), x + dx, y + dy, z + dz, player.getLocation().getYaw(), player.getLocation().getPitch()); + } +} \ No newline at end of file diff --git a/BauSystem_PluginBase/src/de/steamwar/bausystem/region/Region.java b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/Region.java new file mode 100644 index 00000000..0d3f80e9 --- /dev/null +++ b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/Region.java @@ -0,0 +1,147 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.region; + +import com.sk89q.worldedit.EditSession; +import de.steamwar.sql.SchematicNode; +import lombok.RequiredArgsConstructor; +import org.bukkit.Location; + +import javax.annotation.Nullable; +import java.io.File; +import java.util.Optional; + +public interface Region { + + RegionSystem REGION_SYSTEM = null; // TODO: Add Loading of Implementation + + static Region get(Location location) { + return REGION_SYSTEM.get(location); + } + + enum HasFlagResult { + NOT_APPLICABLE, + READ_ONLY, + WRITABLE + } + + @RequiredArgsConstructor + enum RegionType { + GLOBAL(false, false, false, true), + WATER(true, false, false, false), + WATER_CONNECTING(true, false, false, false), + LAND(false, true, false, false), + LAND_CONNECTING(false, true, false, false), + WALL(false, false, true, false), + OLD(false, false, false, false), + ; + + public final boolean water; + public final boolean land; + public final boolean wall; + public final boolean global; + } + + interface ChunkCoordinatesConsumer { + void accept(int chunkX, int chunkZ); + } + + interface ChunkCoordinatePredicate { + boolean test(int chunkX, int chunkZ); + } + + RegionType getRegionType(); + + HasFlagResult hasFlag(Flag flag); + + void setFlag(Flag flag, Flag.Value value); + + Flag.Value getFlag(Flag flagType); + + default & Flag.Value> T getFlagValue(Flag flagType) { + Flag.Value value = getFlag(flagType); + if (value == null) return null; + return (T) value.getValue(); + } + + default & Flag.Value> T getFlagValue(Flag flagType, Class type) { + return getFlagValue(flagType); + } + + Point getMinPoint(); + + Point getMaxPoint(); + + boolean inRegion(Location location); + + /** + * Can return {@link Optional#empty()} if {@link #hasFlag(Flag)} returns false for the TestblockFlag + */ + Optional getBuildMinPoint(boolean extension); + + /** + * Can return {@link Optional#empty()} if {@link #hasFlag(Flag)} returns false for the TestblockFlag + */ + Optional getBuildMaxPoint(boolean extension); + + boolean inBuildRegion(Location location, boolean extension); + + /** + * Can return {@link Optional#empty()} if {@link #hasFlag(Flag)} returns false for the TestblockFlag + */ + Optional getTestblockMinPoint(boolean extension); + + /** + * Can return {@link Optional#empty()} if {@link #hasFlag(Flag)} returns false for the TestblockFlag + */ + Optional getTestblockMaxPoint(boolean extension); + + boolean inTestblockRegion(Location location, boolean extension); + + void forEachChunk(ChunkCoordinatesConsumer consumer); + + ChunkCoordinatePredicate getChunkOutsidePredicate(); + + Optional getBuildChunkOutsidePredicate(boolean extension); + + Optional getTestblockChunkOutsidePredicate(boolean extension); + + Optional getGameModeConfig(); + + Optional copy(); + + Optional copyBuild(boolean extension); + + Optional copyTestblock(boolean extension); + + void reset(); + + void resetBuild(@Nullable SchematicNode schematicNode, boolean extension); + + void resetBuildWireframe(boolean extension); + + void resetTestblock(@Nullable SchematicNode schematicNode, boolean extension); + + void remember(EditSession editSession); + + boolean undo(); + + boolean redo(); +} diff --git a/BauSystem_PluginBase/src/de/steamwar/bausystem/region/RegionSystem.java b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/RegionSystem.java new file mode 100644 index 00000000..105d41ba --- /dev/null +++ b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/RegionSystem.java @@ -0,0 +1,41 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.region; + +import org.bukkit.Location; + +import java.util.Optional; +import java.util.stream.Stream; + +public interface RegionSystem { + + void load(); + + void save(); + + Region get(Location location); + + Optional get(String name); + + Stream getRegions(); + + boolean isModular(); + // TODO: Add creating and removing of Regions as well as moving +} diff --git a/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/ChangedMode.java b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/ChangedMode.java new file mode 100644 index 00000000..4c70b95b --- /dev/null +++ b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/ChangedMode.java @@ -0,0 +1,56 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.region.flags; + +import de.steamwar.bausystem.region.Flag; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ChangedMode implements Flag.Value { + + NO_CHANGE, + HAS_CHANGE; + + private static ChangedMode[] values; + + @Override + public ChangedMode[] getValues() { + if (ChangedMode.values == null) { + ChangedMode.values = ChangedMode.values(); //NOSONAR + } + return ChangedMode.values; + } + + @Override + public ChangedMode getValue() { + return this; + } + + @Override + public ChangedMode getValueOf(final String name) { + try { + return ChangedMode.valueOf(name.toUpperCase()); + } catch (IllegalArgumentException e) { + return null; + } + } +} diff --git a/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/ColorMode.java b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/ColorMode.java new file mode 100644 index 00000000..b3a9448f --- /dev/null +++ b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/ColorMode.java @@ -0,0 +1,70 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2021 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.region.flags; + +import de.steamwar.bausystem.region.Flag; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ColorMode implements Flag.Value { + + WHITE, + ORANGE, + MAGENTA, + LIGHT_BLUE, + YELLOW, + LIME, + PINK, + GRAY, + LIGHT_GRAY, + CYAN, + PURPLE, + BLUE, + BROWN, + GREEN, + RED, + BLACK; + + private static ColorMode[] values; + + @Override + public ColorMode[] getValues() { + if (ColorMode.values == null) { + ColorMode.values = ColorMode.values(); //NOSONAR + } + return ColorMode.values; + } + + @Override + public ColorMode getValue() { + return this; + } + + @Override + public ColorMode getValueOf(final String name) { + try { + return ColorMode.valueOf(name.toUpperCase()); + } catch (IllegalArgumentException e) { + return ColorMode.YELLOW; + } + } +} diff --git a/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/FireMode.java b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/FireMode.java new file mode 100644 index 00000000..8443e6a1 --- /dev/null +++ b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/FireMode.java @@ -0,0 +1,59 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2021 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.region.flags; + +import de.steamwar.bausystem.region.Flag; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum FireMode implements Flag.Value { + + ALLOW, + DENY; + + private static FireMode[] values; + + @Override + public FireMode[] getValues() { + if (FireMode.values == null) { + FireMode.values = FireMode.values(); //NOSONAR + } + return FireMode.values; + } + + @Override + public FireMode getValue() { + return this; + } + + @Override + public FireMode getValueOf(final String name) { + try { + return FireMode.valueOf(name.toUpperCase()); + } catch (IllegalArgumentException e) { + if (name.equalsIgnoreCase("false")) { + return FireMode.DENY; + } + return FireMode.ALLOW; + } + } +} \ No newline at end of file diff --git a/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/FreezeMode.java b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/FreezeMode.java new file mode 100644 index 00000000..e8136eb9 --- /dev/null +++ b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/FreezeMode.java @@ -0,0 +1,60 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2021 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.region.flags; + + +import de.steamwar.bausystem.region.Flag; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum FreezeMode implements Flag.Value { + + ACTIVE, + INACTIVE; + + private static FreezeMode[] values; + + @Override + public FreezeMode[] getValues() { + if (FreezeMode.values == null) { + FreezeMode.values = FreezeMode.values(); //NOSONAR + } + return FreezeMode.values; + } + + @Override + public FreezeMode getValue() { + return this; + } + + @Override + public FreezeMode getValueOf(final String name) { + try { + return FreezeMode.valueOf(name.toUpperCase()); + } catch (IllegalArgumentException e) { + if (name.equalsIgnoreCase("false")) { + return FreezeMode.INACTIVE; + } + return FreezeMode.INACTIVE; + } + } +} \ No newline at end of file diff --git a/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/ItemMode.java b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/ItemMode.java new file mode 100644 index 00000000..f0577aff --- /dev/null +++ b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/ItemMode.java @@ -0,0 +1,59 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2021 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.region.flags; + +import de.steamwar.bausystem.region.Flag; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ItemMode implements Flag.Value { + + ACTIVE, + INACTIVE; + + private static ItemMode[] values; + + @Override + public ItemMode[] getValues() { + if (ItemMode.values == null) { + ItemMode.values = ItemMode.values(); //NOSONAR + } + return ItemMode.values; + } + + @Override + public ItemMode getValue() { + return this; + } + + @Override + public ItemMode getValueOf(final String name) { + try { + return ItemMode.valueOf(name.toUpperCase()); + } catch (IllegalArgumentException e) { + if (name.equalsIgnoreCase("false")) { + return ItemMode.INACTIVE; + } + return ItemMode.ACTIVE; + } + } +} diff --git a/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/ProtectMode.java b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/ProtectMode.java new file mode 100644 index 00000000..bb1d4d51 --- /dev/null +++ b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/ProtectMode.java @@ -0,0 +1,59 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2021 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.region.flags; + +import de.steamwar.bausystem.region.Flag; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ProtectMode implements Flag.Value { + + ACTIVE, + INACTIVE; + + private static ProtectMode[] values; + + @Override + public ProtectMode[] getValues() { + if (ProtectMode.values == null) { + ProtectMode.values = ProtectMode.values(); //NOSONAR + } + return ProtectMode.values; + } + + @Override + public ProtectMode getValue() { + return this; + } + + @Override + public ProtectMode getValueOf(final String name) { + try { + return ProtectMode.valueOf(name.toUpperCase()); + } catch (IllegalArgumentException e) { + if (name.equalsIgnoreCase("false")) { + return ProtectMode.INACTIVE; + } + return ProtectMode.ACTIVE; + } + } +} diff --git a/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/TNTMode.java b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/TNTMode.java new file mode 100644 index 00000000..ecc685f1 --- /dev/null +++ b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/TNTMode.java @@ -0,0 +1,58 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2021 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.region.flags; + +import de.steamwar.bausystem.region.Flag; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum TNTMode implements Flag.Value { + + ALLOW, + DENY, + ONLY_TB, + ONLY_BUILD; + + private static TNTMode[] values; + + @Override + public TNTMode[] getValues() { + if (TNTMode.values == null) { + TNTMode.values = TNTMode.values(); //NOSONAR + } + return TNTMode.values; + } + + @Override + public TNTMode getValue() { + return this; + } + + @Override + public TNTMode getValueOf(final String name) { + try { + return TNTMode.valueOf(name.toUpperCase()); + } catch (IllegalArgumentException e) { + return TNTMode.ALLOW; + } + } +} \ No newline at end of file diff --git a/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/TestblockMode.java b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/TestblockMode.java new file mode 100644 index 00000000..9ddee550 --- /dev/null +++ b/BauSystem_PluginBase/src/de/steamwar/bausystem/region/flags/TestblockMode.java @@ -0,0 +1,61 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.region.flags; + +import de.steamwar.bausystem.region.Flag; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum TestblockMode implements Flag.Value { + + NO_VALUE(false, false), + NORTH(false, true), + SOUTH(false, false), + FIXED_NORTH(true, true), + FIXED_SOUTH(true, false); + + private static TestblockMode[] values; + private final boolean fixed; + private final boolean north; + + @Override + public TestblockMode[] getValues() { + if (TestblockMode.values == null) { + TestblockMode.values = TestblockMode.values(); //NOSONAR + } + return TestblockMode.values; + } + + @Override + public TestblockMode getValue() { + return this; + } + + @Override + public TestblockMode getValueOf(final String name) { + try { + return TestblockMode.valueOf(name.toUpperCase()); + } catch (IllegalArgumentException e) { + return null; + } + } +}