From 96daa2c861ad69a2fbb2792379dcb4ed3981bd05 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 4 Oct 2024 19:55:58 +0200 Subject: [PATCH 01/56] Update some part of Region --- .../bausystem/utils/FlatteningWrapper15.java | 2 +- .../features/backup/BackupCommand.java | 5 - .../features/countingwand/Countingwand.java | 2 +- .../countingwand/CountingwandListener.java | 2 +- .../killchecker/KillcheckerVisualizer.java | 2 +- .../features/observer/ObserverTracer.java | 2 +- .../features/region/RegionCommand.java | 2 +- .../region/items/ColorBauGuiItem.java | 2 +- .../features/script/lua/libs/LuaLib.java | 2 +- .../script/lua/libs/WorldEditLib.java | 2 +- .../features/slaves/laufbau/Cuboid.java | 2 +- .../laufbau/states/CreatingLaufState.java | 2 +- .../laufbau/states/ProcessingTracesState.java | 2 +- .../team/boundary/BoundaryViewer.java | 2 +- .../features/util/SelectCommand.java | 4 +- .../worldedit/ColorReplaceCommand.java | 2 +- .../de/steamwar/bausystem/region/Color.java | 39 ----- .../de/steamwar/bausystem/region/Region.java | 1 + .../region/flags/flagvalues/ColorMode.java | 2 +- .../steamwar/bausystem/regionnew/Color.java | 39 +++++ .../bausystem/regionnew/FlagStorage.java | 29 ++++ .../{region => regionnew}/Point.java | 26 +-- .../steamwar/bausystem/regionnew/Region.java | 81 +++++++++ .../bausystem/regionnew/RegionFlagPolicy.java | 34 ++++ .../bausystem/regionnew/RegionSide.java | 25 +++ .../bausystem/regionnew/RegionSystem.java | 40 +++++ .../bausystem/regionnew/RegionType.java | 32 ++++ .../regionnew/flags/ChangedMode.java | 57 ++++++ .../bausystem/regionnew/flags/ColorMode.java | 71 ++++++++ .../bausystem/regionnew/flags/FireMode.java | 59 +++++++ .../bausystem/regionnew/flags/Flag.java | 102 +++++++++++ .../bausystem/regionnew/flags/FreezeMode.java | 60 +++++++ .../bausystem/regionnew/flags/ItemMode.java | 59 +++++++ .../regionnew/flags/NoGravityMode.java | 59 +++++++ .../regionnew/flags/ProtectMode.java | 59 +++++++ .../bausystem/regionnew/flags/TNTMode.java | 58 +++++++ .../regionnew/flags/TestblockMode.java | 61 +++++++ .../bausystem/utils/FlatteningWrapper.java | 2 +- .../bausystem/utils/PasteBuilder.java | 4 +- .../BauSystem_RegionFixed/build.gradle.kts | 47 +++++ .../bausystem/regionnew/FixedFlagStorage.java | 55 ++++++ .../regionnew/FixedGlobalRegion.java | 164 ++++++++++++++++++ .../bausystem/regionnew/FixedRegion.java | 148 ++++++++++++++++ .../regionnew/FixedRegionSystem.java | 70 ++++++++ BauSystem/build.gradle.kts | 1 + settings.gradle.kts | 3 +- 46 files changed, 1445 insertions(+), 79 deletions(-) delete mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Color.java create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Color.java create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/FlagStorage.java rename BauSystem/BauSystem_Main/src/de/steamwar/bausystem/{region => regionnew}/Point.java (67%) create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Region.java create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionFlagPolicy.java create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionSide.java create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionSystem.java create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionType.java create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ChangedMode.java create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ColorMode.java create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/FireMode.java create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/Flag.java create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/FreezeMode.java create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ItemMode.java create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/NoGravityMode.java create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ProtectMode.java create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/TNTMode.java create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/TestblockMode.java create mode 100644 BauSystem/BauSystem_RegionFixed/build.gradle.kts create mode 100644 BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedFlagStorage.java create mode 100644 BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedGlobalRegion.java create mode 100644 BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedRegion.java create mode 100644 BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedRegionSystem.java diff --git a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/FlatteningWrapper15.java b/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/FlatteningWrapper15.java index 266326e0..69872f57 100644 --- a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/FlatteningWrapper15.java +++ b/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/FlatteningWrapper15.java @@ -42,7 +42,7 @@ import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockTypes; -import de.steamwar.bausystem.region.Point; +import de.steamwar.bausystem.regionnew.Point; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; 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 b7911275..6abe927a 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 @@ -21,17 +21,12 @@ package de.steamwar.bausystem.features.backup; import com.sk89q.worldedit.EditSession; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.region.Color; import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.bausystem.region.flags.flagvalues.ColorMode; import de.steamwar.bausystem.region.tags.Tag; import de.steamwar.bausystem.utils.PasteBuilder; import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommandUtils; import de.steamwar.command.TypeMapper; -import de.steamwar.command.TypeValidator; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; import de.steamwar.linkage.Linked; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/Countingwand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/Countingwand.java index fb9316b9..6c667ba7 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/Countingwand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/Countingwand.java @@ -20,7 +20,7 @@ package de.steamwar.bausystem.features.countingwand; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.region.Point; +import de.steamwar.bausystem.regionnew.Point; import de.steamwar.bausystem.shared.Pair; import de.steamwar.bausystem.utils.ItemUtils; import de.steamwar.inventory.SWItem; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandListener.java index 7233670a..9d811f28 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandListener.java @@ -19,7 +19,7 @@ package de.steamwar.bausystem.features.countingwand; -import de.steamwar.bausystem.region.Point; +import de.steamwar.bausystem.regionnew.Point; import de.steamwar.linkage.Linked; import org.bukkit.FluidCollisionMode; import org.bukkit.event.EventHandler; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerVisualizer.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerVisualizer.java index 04822aa8..d7145f37 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerVisualizer.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerVisualizer.java @@ -20,7 +20,7 @@ package de.steamwar.bausystem.features.killchecker; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.region.Point; +import de.steamwar.bausystem.regionnew.Point; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java index c1e08fcf..e4aedd0a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java @@ -20,7 +20,7 @@ package de.steamwar.bausystem.features.observer; import de.steamwar.Reflection; -import de.steamwar.bausystem.region.Point; +import de.steamwar.bausystem.regionnew.Point; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Particle; 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 6d8d6f4d..e7cedc22 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 @@ -28,7 +28,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.session.ClipboardHolder; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.util.SelectCommand; -import de.steamwar.bausystem.region.Point; +import de.steamwar.bausystem.regionnew.Point; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.flags.Flag; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java index a38c397f..b886e756 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java @@ -22,7 +22,7 @@ package de.steamwar.bausystem.features.region.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.linkage.specific.BauGuiItem; -import de.steamwar.bausystem.region.Color; +import de.steamwar.bausystem.regionnew.Color; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.ColorMode; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/LuaLib.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/LuaLib.java index a4af0d3a..a86542df 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/LuaLib.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/LuaLib.java @@ -19,7 +19,7 @@ package de.steamwar.bausystem.features.script.lua.libs; -import de.steamwar.bausystem.region.Point; +import de.steamwar.bausystem.regionnew.Point; import lombok.AllArgsConstructor; import org.bukkit.entity.Player; import org.luaj.vm2.*; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/WorldEditLib.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/WorldEditLib.java index 87d1f9fb..7f0cac4d 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/WorldEditLib.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/WorldEditLib.java @@ -22,7 +22,7 @@ package de.steamwar.bausystem.features.script.lua.libs; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.bukkit.BukkitPlayer; import com.sk89q.worldedit.math.BlockVector3; -import de.steamwar.bausystem.region.Point; +import de.steamwar.bausystem.regionnew.Point; import de.steamwar.bausystem.utils.FlatteningWrapper; import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/Cuboid.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/Cuboid.java index c31653a5..e5699aaa 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/Cuboid.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/Cuboid.java @@ -19,7 +19,7 @@ package de.steamwar.bausystem.features.slaves.laufbau; -import de.steamwar.bausystem.region.Point; +import de.steamwar.bausystem.regionnew.Point; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingLaufState.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingLaufState.java index e4ed312b..369ca0d9 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingLaufState.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingLaufState.java @@ -27,7 +27,7 @@ import com.sk89q.worldedit.world.block.BlockTypes; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.bausystem.region.Point; +import de.steamwar.bausystem.regionnew.Point; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java index 94eb6549..04c43fd3 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java @@ -26,7 +26,7 @@ import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; import de.steamwar.bausystem.features.tracer.TNTPoint; import de.steamwar.bausystem.features.tracer.Trace; import de.steamwar.bausystem.features.tracer.TraceManager; -import de.steamwar.bausystem.region.Point; +import de.steamwar.bausystem.regionnew.Point; import de.steamwar.bausystem.utils.FlatteningWrapper; import org.bukkit.Location; import org.bukkit.World; 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 51bef65c..808e6398 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 @@ -20,7 +20,7 @@ package de.steamwar.bausystem.features.team.boundary; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.region.Point; +import de.steamwar.bausystem.regionnew.Point; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.core.TrickyParticleWrapper; 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 e9c2c09a..4f1df1af 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 @@ -1,14 +1,12 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.region.Point; +import de.steamwar.bausystem.regionnew.Point; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.utils.FlatteningWrapper; import de.steamwar.command.SWCommand; -import de.steamwar.command.TypeValidator; import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java index 6b6659ba..3df0755c 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java @@ -28,7 +28,7 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import de.steamwar.bausystem.features.world.WorldEditListener; import de.steamwar.bausystem.features.worldedit.utils.SpecialReplace; -import de.steamwar.bausystem.region.Color; +import de.steamwar.bausystem.regionnew.Color; import de.steamwar.bausystem.shared.Pair; import de.steamwar.bausystem.utils.WorldEditUtils; import de.steamwar.command.PreviousArguments; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Color.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Color.java deleted file mode 100644 index a50c7cb0..00000000 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Color.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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; - -public enum Color { - WHITE, - ORANGE, - MAGENTA, - LIGHT_BLUE, - YELLOW, - LIME, - PINK, - GRAY, - LIGHT_GRAY, - CYAN, - PURPLE, - BLUE, - BROWN, - GREEN, - RED, - BLACK; -} 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 c6f8b5c7..bf8477e9 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -28,6 +28,7 @@ import de.steamwar.bausystem.region.flags.flagvalues.TNTMode; import de.steamwar.bausystem.region.tags.Tag; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; +import de.steamwar.bausystem.regionnew.Point; import de.steamwar.bausystem.shared.SizedStack; import de.steamwar.bausystem.utils.FlatteningWrapper; import de.steamwar.bausystem.utils.PasteBuilder; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ColorMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ColorMode.java index 6902a2fb..6159c959 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ColorMode.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ColorMode.java @@ -19,7 +19,7 @@ package de.steamwar.bausystem.region.flags.flagvalues; -import de.steamwar.bausystem.region.Color; +import de.steamwar.bausystem.regionnew.Color; import de.steamwar.bausystem.region.flags.Flag; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Color.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Color.java new file mode 100644 index 00000000..6292fbe1 --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Color.java @@ -0,0 +1,39 @@ +/* + * 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.regionnew; + +public enum Color { + WHITE, + ORANGE, + MAGENTA, + LIGHT_BLUE, + YELLOW, + LIME, + PINK, + GRAY, + LIGHT_GRAY, + CYAN, + PURPLE, + BLUE, + BROWN, + GREEN, + RED, + BLACK; +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/FlagStorage.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/FlagStorage.java new file mode 100644 index 00000000..57a9523c --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/FlagStorage.java @@ -0,0 +1,29 @@ +/* + * 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.regionnew; + +import de.steamwar.bausystem.regionnew.flags.Flag; + +public interface FlagStorage { + + & Flag.Value> boolean set(Flag flag, Flag.Value value); + + & Flag.Value> Flag.Value get(Flag flag); +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Point.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Point.java similarity index 67% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Point.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Point.java index 6f8c5929..a9f3534c 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Point.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Point.java @@ -1,23 +1,23 @@ /* - * This file is a part of the SteamWar software. + * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * 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 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. + * 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 . + * 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; +package de.steamwar.bausystem.regionnew; import com.sk89q.worldedit.math.BlockVector3; import lombok.AllArgsConstructor; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Region.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Region.java new file mode 100644 index 00000000..8c3a61eb --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Region.java @@ -0,0 +1,81 @@ +/* + * 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.regionnew; + +import com.sk89q.worldedit.EditSession; +import de.steamwar.bausystem.regionnew.flags.Flag; +import de.steamwar.sql.SchematicNode; +import lombok.NonNull; +import org.bukkit.Location; + +import javax.annotation.Nullable; +import java.io.File; +import java.util.Optional; + +public interface Region { + + RegionType getType(); + + & Flag.Value> RegionFlagPolicy hasFlag(@NonNull Flag flag); + + & Flag.Value> boolean setFlag(@NonNull Flag flag, Flag.Value value); + + & Flag.Value> Optional> getFlag(@NonNull Flag flag); + + Point getMinPoint(); + + Point getMaxPoint(); + + boolean inRegion(Location location); + + Optional getBuildMinPoint(boolean extension); + + Optional getBuildMaxPoint(boolean extension); + + boolean inBuildRegion(boolean extension); + + Optional getTestblockMinPoint(boolean extension); + + Optional getTestblockMaxPoint(boolean extension); + + boolean inTestblockRegion(boolean extension); + + // TODO: Add forEachChunk and getChunkOutsidePredicate + + Optional getGameModeConfig(); + + Optional copy(); + + Optional copyBuild(); + + Optional copyTestblock(); + + void reset(); + + void resetBuild(@Nullable SchematicNode schematicNode, boolean extension); + + void resetTestblock(@Nullable SchematicNode schematicNode, boolean extension); + + void remember(EditSession editSession); + + boolean undo(); + + boolean redo(); +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionFlagPolicy.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionFlagPolicy.java new file mode 100644 index 00000000..7878a79a --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionFlagPolicy.java @@ -0,0 +1,34 @@ +/* + * 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.regionnew; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@Getter +public enum RegionFlagPolicy { + NOT_APPLICABLE(false, false), + READ_ONLY(true, false), + WRITABLE(true, true); + + private final boolean readable; + private final boolean writable; +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionSide.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionSide.java new file mode 100644 index 00000000..6834e300 --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionSide.java @@ -0,0 +1,25 @@ +/* + * 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.regionnew; + +public enum RegionSide { + NORTH, + SOUTH +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionSystem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionSystem.java new file mode 100644 index 00000000..b5e8d63b --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionSystem.java @@ -0,0 +1,40 @@ +/* + * 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.regionnew; + +import org.bukkit.Location; + +import java.util.Optional; +import java.util.stream.Stream; + +public interface RegionSystem { + + void load(); + void save(); + + Region getGlobalRegion(); + + Region get(Location location); + Optional getRegion(String name); + + Stream getRegions(); + + boolean isModular(); +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionType.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionType.java new file mode 100644 index 00000000..ff91fcd5 --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionType.java @@ -0,0 +1,32 @@ +/* + * 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.regionnew; + +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +public enum RegionType { + + GLOBAL(true), + NORMAL(false), + ; + + private final boolean global; +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ChangedMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ChangedMode.java new file mode 100644 index 00000000..85e70f01 --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ChangedMode.java @@ -0,0 +1,57 @@ +/* + * 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.regionnew.flags; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ChangedMode implements Flag.Value { + + NO_CHANGE("FLAG_CHANGED_NO_CHANGE", false), + HAS_CHANGE("FLAG_CHANGED_HAS_CHANGE", true); + + private static ChangedMode[] values; + private final String chatValue; + private final Boolean changed; + + @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 NO_CHANGE; + } + } +} \ No newline at end of file diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ColorMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ColorMode.java new file mode 100644 index 00000000..229301c3 --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ColorMode.java @@ -0,0 +1,71 @@ +/* + * 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.regionnew.flags; + +import de.steamwar.bausystem.regionnew.Color; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ColorMode implements Flag.Value { + WHITE("FLAG_COLOR_WHITE", Color.WHITE), + ORANGE("FLAG_COLOR_ORANGE", Color.ORANGE), + MAGENTA("FLAG_COLOR_MAGENTA", Color.MAGENTA), + LIGHT_BLUE("FLAG_COLOR_LIGHT_BLUE", Color.LIGHT_BLUE), + YELLOW("FLAG_COLOR_YELLOW", Color.YELLOW), + LIME("FLAG_COLOR_LIME", Color.LIME), + PINK("FLAG_COLOR_PINK", Color.PINK), + GRAY("FLAG_COLOR_GRAY", Color.GRAY), + LIGHT_GRAY("FLAG_COLOR_LIGHT_GRAY", Color.LIGHT_GRAY), + CYAN("FLAG_COLOR_CYAN", Color.CYAN), + PURPLE("FLAG_COLOR_PURPLE", Color.PURPLE), + BLUE("FLAG_COLOR_BLUE", Color.BLUE), + BROWN("FLAG_COLOR_BROWN", Color.BROWN), + GREEN("FLAG_COLOR_GREEN", Color.GREEN), + RED("FLAG_COLOR_RED", Color.RED), + BLACK("FLAG_COLOR_BLACK", Color.BLACK); + + private static ColorMode[] values; + private final String chatValue; + private final Color color; + + @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/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/FireMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/FireMode.java new file mode 100644 index 00000000..f628bd47 --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/FireMode.java @@ -0,0 +1,59 @@ +/* + * 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.regionnew.flags; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum FireMode implements Flag.Value { + + ALLOW("FLAG_FIRE_ALLOW"), + DENY("FLAG_FIRE_DENY"); + + private static FireMode[] values; + private final String chatValue; + + @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/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/Flag.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/Flag.java new file mode 100644 index 00000000..d915c216 --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/Flag.java @@ -0,0 +1,102 @@ +/* + * 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.regionnew.flags; + +import de.steamwar.bausystem.shared.EnumDisplay; +import lombok.Getter; + +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; + +public class Flag & Flag.Value> implements EnumDisplay { + + public static final Flag COLOR = new Flag<>("COLOR", "FLAG_COLOR", ColorMode.class, ColorMode.YELLOW); + public static final Flag TNT = new Flag<>("TNT", "FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB); + public static final Flag FIRE = new Flag<>("FIRE", "FLAG_FIRE", FireMode.class, FireMode.ALLOW); + public static final Flag FREEZE = new Flag<>("FREEZE", "FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE); + public static final Flag PROTECT = new Flag<>("PROTECT", "FLAG_PROTECT", ProtectMode.class, ProtectMode.ACTIVE); + public static final Flag ITEMS = new Flag<>("ITEMS", "FLAG_ITEMS", ItemMode.class, ItemMode.INACTIVE); + public static final Flag NO_GRAVITY = new Flag<>("NO_GRAVITY", "FLAG_NO_GRAVITY", NoGravityMode.class, NoGravityMode.INACTIVE); + public static final Flag TESTBLOCK = new Flag<>("TESTBLOCK", "FLAG_TESTBLOCK", TestblockMode.class, TestblockMode.NO_VALUE); + public static final Flag CHANGED = new Flag<>("CHANGED", "FLAG_CHANGED", ChangedMode.class, ChangedMode.NO_CHANGE); + + @Getter + private static final Set flags = new HashSet<>(); + + private static AtomicInteger counter = new AtomicInteger(0); + + private String name; + private int ordinal; + + @Getter + private String chatValue; + + @Getter + private final Class> valueType; + + @Getter + private final Flag.Value defaultValue; + + @Getter + private final Flag.Value[] values; + + private Flag(String name, String chatValue, Class> valueType, Value defaultValue) { + flags.add(this); + + this.name = name; + this.ordinal = counter.getAndIncrement(); + this.chatValue = chatValue; + + this.valueType = valueType; + this.defaultValue = defaultValue; + this.values = defaultValue.getValues(); + } + + public String name() { + return name; + } + + public int ordinal() { + return ordinal; + } + + public boolean oneOff(Flag... flags) { + for (Flag flag : flags) { + if (flag == this) { + return true; + } + } + return false; + } + + public interface Value & Flag.Value> extends EnumDisplay { + + T getValue(); + + T getValueOf(final String name); + + T[] getValues(); + + default String getName() { + return this.getValue().name().toLowerCase(); + } + } +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/FreezeMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/FreezeMode.java new file mode 100644 index 00000000..f3da631c --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/FreezeMode.java @@ -0,0 +1,60 @@ +/* + * 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.regionnew.flags; + + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum FreezeMode implements Flag.Value { + + ACTIVE("FLAG_FREEZE_ACTIVE"), + INACTIVE("FLAG_FREEZE_INACTIVE"); + + private static FreezeMode[] values; + private final String chatValue; + + @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/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ItemMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ItemMode.java new file mode 100644 index 00000000..7d29899c --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ItemMode.java @@ -0,0 +1,59 @@ +/* + * 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.regionnew.flags; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ItemMode implements Flag.Value { + + ACTIVE("FLAG_ITEMS_ACTIVE"), + INACTIVE("FLAG_ITEMS_INACTIVE"); + + private static ItemMode[] values; + private final String chatValue; + + @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/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/NoGravityMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/NoGravityMode.java new file mode 100644 index 00000000..68e9fa6b --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/NoGravityMode.java @@ -0,0 +1,59 @@ +/* + * 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.regionnew.flags; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum NoGravityMode implements Flag.Value { + + ACTIVE("FLAG_NO_GRAVITY_ACTIVE"), + INACTIVE("FLAG_NO_GRAVITY_INACTIVE"); + + private static NoGravityMode[] values; + private final String chatValue; + + @Override + public NoGravityMode[] getValues() { + if (NoGravityMode.values == null) { + NoGravityMode.values = NoGravityMode.values(); //NOSONAR + } + return NoGravityMode.values; + } + + @Override + public NoGravityMode getValue() { + return this; + } + + @Override + public NoGravityMode getValueOf(final String name) { + try { + return NoGravityMode.valueOf(name.toUpperCase()); + } catch (IllegalArgumentException e) { + if (name.equalsIgnoreCase("false")) { + return NoGravityMode.INACTIVE; + } + return NoGravityMode.ACTIVE; + } + } +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ProtectMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ProtectMode.java new file mode 100644 index 00000000..2f510daa --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ProtectMode.java @@ -0,0 +1,59 @@ +/* + * 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.regionnew.flags; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ProtectMode implements Flag.Value { + + ACTIVE("FLAG_PROTECT_ACTIVE"), + INACTIVE("FLAG_PROTECT_INACTIVE"); + + private static ProtectMode[] values; + private final String chatValue; + + @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/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/TNTMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/TNTMode.java new file mode 100644 index 00000000..e483a81b --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/TNTMode.java @@ -0,0 +1,58 @@ +/* + * 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.regionnew.flags; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum TNTMode implements Flag.Value { + + ALLOW("FLAG_TNT_ALLOW"), + DENY("FLAG_TNT_DENY"), + ONLY_TB("FLAG_TNT_ONLY_TB"), + ONLY_BUILD("FLAG_TNT_ONLY_BUILD"); + + private static TNTMode[] values; + private final String chatValue; + + @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/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/TestblockMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/TestblockMode.java new file mode 100644 index 00000000..d6d8075c --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/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.regionnew.flags; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum TestblockMode implements Flag.Value { + + NO_VALUE("FLAG_TESTBLOCK_NO_VALUE", false, false), + NORTH("FLAG_TESTBLOCK_NORTH", false, true), + SOUTH("FLAG_TESTBLOCK_SOUTH", false, false), + FIXED_NORTH("FLAG_TESTBLOCK_NORTH", true, true), + FIXED_SOUTH("FLAG_TESTBLOCK_SOUTH", true, false); + + private static TestblockMode[] values; + private final String chatValue; + 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 NO_VALUE; + } + } +} \ No newline at end of file diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/FlatteningWrapper.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/FlatteningWrapper.java index 3cd96295..12b7a78a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/FlatteningWrapper.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/FlatteningWrapper.java @@ -22,7 +22,7 @@ package de.steamwar.bausystem.utils; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.extent.clipboard.Clipboard; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.region.Point; +import de.steamwar.bausystem.regionnew.Point; import de.steamwar.core.VersionDependent; import org.bukkit.Material; import org.bukkit.World; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PasteBuilder.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PasteBuilder.java index a4a74e17..8c3813ac 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PasteBuilder.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PasteBuilder.java @@ -26,8 +26,8 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; -import de.steamwar.bausystem.region.Color; -import de.steamwar.bausystem.region.Point; +import de.steamwar.bausystem.regionnew.Color; +import de.steamwar.bausystem.regionnew.Point; import de.steamwar.sql.SchematicData; import de.steamwar.sql.SchematicNode; import lombok.Getter; diff --git a/BauSystem/BauSystem_RegionFixed/build.gradle.kts b/BauSystem/BauSystem_RegionFixed/build.gradle.kts new file mode 100644 index 00000000..bb84c063 --- /dev/null +++ b/BauSystem/BauSystem_RegionFixed/build.gradle.kts @@ -0,0 +1,47 @@ +/* + * 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 . + */ + +plugins { + steamwar.java +} + +tasks.compileJava { + options.isWarnings = false +} + +java { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 +} + +dependencies { + compileOnly(project(":BauSystem:BauSystem_Main")) + compileOnly(project(":SpigotCore")) + + compileOnly(libs.spigotapi) + compileOnly(libs.axiom) + compileOnly(libs.authlib) + compileOnly(libs.viaapi) + + compileOnly(libs.nms20) + compileOnly(libs.fawe18) + + implementation(libs.luaj) + implementation(files("$projectDir/../libs/YAPION-SNAPSHOT.jar")) +} diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedFlagStorage.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedFlagStorage.java new file mode 100644 index 00000000..1af55086 --- /dev/null +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedFlagStorage.java @@ -0,0 +1,55 @@ +/* + * 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.regionnew; + +import de.steamwar.bausystem.regionnew.flags.Flag; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; + +public class FixedFlagStorage implements FlagStorage { + + private Map, Flag.Value> flagMap = new HashMap<>(); + + public static FlagStorage createFromRegion(Region region) { + FlagStorage flagStorage = new FixedFlagStorage(); + Flag.getFlags().forEach(flag -> { + if (region.hasFlag(flag).isReadable()) { + flagStorage.set(flag, flag.getDefaultValue()); + } + }); + return flagStorage; + } + + public static FlagStorage createFromFile(File file) { + throw new IllegalStateException("Not implemented yet"); + } + + @Override + public & Flag.Value> boolean set(Flag flag, Flag.Value value) { + return flagMap.put(flag, value) != value; + } + + @Override + public & Flag.Value> Flag.Value get(Flag flag) { + return (Flag.Value) flagMap.get(flag); + } +} diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedGlobalRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedGlobalRegion.java new file mode 100644 index 00000000..8288a057 --- /dev/null +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedGlobalRegion.java @@ -0,0 +1,164 @@ +/* + * 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.regionnew; + +import com.sk89q.worldedit.EditSession; +import de.steamwar.bausystem.regionnew.flags.Flag; +import de.steamwar.sql.SchematicNode; +import lombok.NonNull; +import org.bukkit.Location; + +import javax.annotation.Nullable; +import java.io.File; +import java.util.Optional; + +public final class FixedGlobalRegion implements Region { + + public static final FixedGlobalRegion INSTANCE = new FixedGlobalRegion(); + + private static final Point MIN_POINT = new Point(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE); + private static final Point MAX_POINT = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); + private final FlagStorage FLAG_STORAGE = FixedFlagStorage.createFromRegion(this); // TODO: Update to either File or Region creation! + + private FixedGlobalRegion() { + } + + @Override + public RegionType getType() { + return RegionType.GLOBAL; + } + + @Override + public & Flag.Value> RegionFlagPolicy hasFlag(@NonNull Flag flag) { + if (flag.oneOff(Flag.TNT, Flag.FIRE, Flag.FREEZE, Flag.ITEMS)) { + return RegionFlagPolicy.WRITABLE; + } + return RegionFlagPolicy.NOT_APPLICABLE; + } + + @Override + public & Flag.Value> boolean setFlag(@NonNull Flag flag, Flag.Value value) { + return hasFlag(flag).isWritable() && FLAG_STORAGE.set(flag, value); + } + + @Override + public & Flag.Value> Optional> getFlag(@NonNull Flag flag) { + if (hasFlag(flag).isReadable()) { + return Optional.of(FLAG_STORAGE.get(flag)); + } else { + return Optional.empty(); + } + } + + @Override + public Point getMinPoint() { + return MIN_POINT; + } + + @Override + public Point getMaxPoint() { + return MAX_POINT; + } + + @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(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(boolean extension) { + return false; + } + + @Override + public Optional getGameModeConfig() { + return Optional.empty(); + } + + @Override + public Optional copy() { + return Optional.empty(); + } + + @Override + public Optional copyBuild() { + return Optional.empty(); + } + + @Override + public Optional copyTestblock() { + return Optional.empty(); + } + + @Override + public void reset() { + + } + + @Override + public void resetBuild(@Nullable SchematicNode schematicNode, 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/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedRegion.java new file mode 100644 index 00000000..9d5bd31e --- /dev/null +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedRegion.java @@ -0,0 +1,148 @@ +/* + * 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.regionnew; + +import com.sk89q.worldedit.EditSession; +import de.steamwar.bausystem.regionnew.flags.Flag; +import de.steamwar.sql.SchematicNode; +import lombok.NonNull; +import org.bukkit.Location; + +import javax.annotation.Nullable; +import java.io.File; +import java.util.Optional; + +public class FixedRegion implements Region { // TODO: Implement! + + @Override + public RegionType getType() { + return RegionType.NORMAL; + } + + @Override + public & Flag.Value> RegionFlagPolicy hasFlag(@NonNull Flag flag) { + return null; + } + + @Override + public & Flag.Value> boolean setFlag(@NonNull Flag flag, Flag.Value value) { + return false; + } + + @Override + public & Flag.Value> Optional> getFlag(@NonNull Flag flag) { + return Optional.empty(); + } + + @Override + public Point getMinPoint() { + return null; + } + + @Override + public Point getMaxPoint() { + return null; + } + + @Override + public boolean inRegion(Location location) { + return false; + } + + @Override + public Optional getBuildMinPoint(boolean extension) { + return Optional.empty(); + } + + @Override + public Optional getBuildMaxPoint(boolean extension) { + return Optional.empty(); + } + + @Override + public boolean inBuildRegion(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(boolean extension) { + return false; + } + + @Override + public Optional getGameModeConfig() { + return Optional.empty(); + } + + @Override + public Optional copy() { + return Optional.empty(); + } + + @Override + public Optional copyBuild() { + return Optional.empty(); + } + + @Override + public Optional copyTestblock() { + return Optional.empty(); + } + + @Override + public void reset() { + + } + + @Override + public void resetBuild(@Nullable SchematicNode schematicNode, 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/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedRegionSystem.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedRegionSystem.java new file mode 100644 index 00000000..f29b1ebc --- /dev/null +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedRegionSystem.java @@ -0,0 +1,70 @@ +/* + * 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.regionnew; + +import org.bukkit.Location; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Stream; + +public class FixedRegionSystem implements RegionSystem { + + private static final Map REGION_MAP = new HashMap<>(); + + @Override + public void load() { + // TODO: Implement + } + + @Override + public void save() { + // TODO: Implement + } + + @Override + public Region getGlobalRegion() { + return FixedGlobalRegion.INSTANCE; + } + + @Override + public Region get(Location location) { + return REGION_MAP.values().stream() + .filter(region -> region.inRegion(location)) + .findFirst() + .orElse(FixedGlobalRegion.INSTANCE); + } + + @Override + public Optional getRegion(String name) { + return Optional.ofNullable(REGION_MAP.get(name)); + } + + @Override + public Stream getRegions() { + return REGION_MAP.values().stream(); + } + + @Override + public boolean isModular() { + return false; + } +} diff --git a/BauSystem/build.gradle.kts b/BauSystem/build.gradle.kts index ebb9422d..5c1f2608 100644 --- a/BauSystem/build.gradle.kts +++ b/BauSystem/build.gradle.kts @@ -27,6 +27,7 @@ tasks.build { } dependencies { + implementation(project(":BauSystem:BauSystem_RegionFixed")) implementation(project(":BauSystem:BauSystem_Main")) implementation(project(":BauSystem:BauSystem_15")) implementation(project(":BauSystem:BauSystem_18")) diff --git a/settings.gradle.kts b/settings.gradle.kts index 8ab618ff..999b22ee 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -177,7 +177,8 @@ include( "BauSystem:BauSystem_19", "BauSystem:BauSystem_20", "BauSystem:BauSystem_21", - "BauSystem:BauSystem_Main" + "BauSystem:BauSystem_Main", + "BauSystem:BauSystem_RegionFixed" ) include("CommandFramework") From 4e70a675c255363cbff46c0e0987c4a5bee06846 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 3 Nov 2024 13:27:35 +0100 Subject: [PATCH 02/56] Update Region.inBuildRegion and Region.inTestblockRegion --- .../steamwar/bausystem/regionnew/Region.java | 8 +++- .../bausystem/regionnew/RegionSystem.java | 47 +++++++++++++++++++ .../regionnew/FixedGlobalRegion.java | 4 +- .../bausystem/regionnew/FixedRegion.java | 4 +- 4 files changed, 57 insertions(+), 6 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Region.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Region.java index 8c3a61eb..1bdab641 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Region.java @@ -31,6 +31,10 @@ import java.util.Optional; public interface Region { + static Region getRegion(Location location) { + return RegionSystem.REGION_SYSTEM.get(location); + } + RegionType getType(); & Flag.Value> RegionFlagPolicy hasFlag(@NonNull Flag flag); @@ -49,13 +53,13 @@ public interface Region { Optional getBuildMaxPoint(boolean extension); - boolean inBuildRegion(boolean extension); + boolean inBuildRegion(Location location, boolean extension); Optional getTestblockMinPoint(boolean extension); Optional getTestblockMaxPoint(boolean extension); - boolean inTestblockRegion(boolean extension); + boolean inTestblockRegion(Location location, boolean extension); // TODO: Add forEachChunk and getChunkOutsidePredicate diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionSystem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionSystem.java index b5e8d63b..bbe4960d 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionSystem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionSystem.java @@ -21,11 +21,14 @@ package de.steamwar.bausystem.regionnew; import org.bukkit.Location; +import java.lang.reflect.InvocationTargetException; import java.util.Optional; import java.util.stream.Stream; public interface RegionSystem { + RegionSystem REGION_SYSTEM = init(); + void load(); void save(); @@ -37,4 +40,48 @@ public interface RegionSystem { Stream getRegions(); boolean isModular(); + + private static RegionSystem init() { + try { + return (RegionSystem) Class.forName("de.steamwar.bausystem.regionnew.FixedRegionSystem").getConstructor().newInstance(); + } catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | + InvocationTargetException e) { + return new RegionSystem() { + @Override + public void load() { + throw new UnsupportedOperationException(); + } + + @Override + public void save() { + throw new UnsupportedOperationException(); + } + + @Override + public Region getGlobalRegion() { + throw new UnsupportedOperationException(); + } + + @Override + public Region get(Location location) { + throw new UnsupportedOperationException(); + } + + @Override + public Optional getRegion(String name) { + throw new UnsupportedOperationException(); + } + + @Override + public Stream getRegions() { + throw new UnsupportedOperationException(); + } + + @Override + public boolean isModular() { + throw new UnsupportedOperationException(); + } + }; + } + } } diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedGlobalRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedGlobalRegion.java index 8288a057..81b39197 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedGlobalRegion.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedGlobalRegion.java @@ -93,7 +93,7 @@ public final class FixedGlobalRegion implements Region { } @Override - public boolean inBuildRegion(boolean extension) { + public boolean inBuildRegion(Location location, boolean extension) { return false; } @@ -108,7 +108,7 @@ public final class FixedGlobalRegion implements Region { } @Override - public boolean inTestblockRegion(boolean extension) { + public boolean inTestblockRegion(Location location, boolean extension) { return false; } diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedRegion.java index 9d5bd31e..c89cdf61 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedRegion.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedRegion.java @@ -77,7 +77,7 @@ public class FixedRegion implements Region { // TODO: Implement! } @Override - public boolean inBuildRegion(boolean extension) { + public boolean inBuildRegion(Location location, boolean extension) { return false; } @@ -92,7 +92,7 @@ public class FixedRegion implements Region { // TODO: Implement! } @Override - public boolean inTestblockRegion(boolean extension) { + public boolean inTestblockRegion(Location location, boolean extension) { return false; } From 7f41559647444c1292c5e5640e32ff861ba3ea50 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Tue, 12 Nov 2024 16:15:37 +0100 Subject: [PATCH 03/56] Fix build.gradle.kts as of 43618fc2 --- BauSystem/BauSystem_RegionFixed/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BauSystem/BauSystem_RegionFixed/build.gradle.kts b/BauSystem/BauSystem_RegionFixed/build.gradle.kts index bb84c063..b33f5f0a 100644 --- a/BauSystem/BauSystem_RegionFixed/build.gradle.kts +++ b/BauSystem/BauSystem_RegionFixed/build.gradle.kts @@ -31,8 +31,8 @@ java { } dependencies { - compileOnly(project(":BauSystem:BauSystem_Main")) - compileOnly(project(":SpigotCore")) + compileOnly(project(":BauSystem:BauSystem_Main", "default")) + compileOnly(project(":SpigotCore", "default")) compileOnly(libs.spigotapi) compileOnly(libs.axiom) From 8427ae36f2989fe52a253bdfb387cd09381fb666 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Tue, 12 Nov 2024 16:31:45 +0100 Subject: [PATCH 04/56] Remove unused TestblockMode --- .../bausystem/regionnew/flags/TestblockMode.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/TestblockMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/TestblockMode.java index d6d8075c..e7ff3e7b 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/TestblockMode.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/TestblockMode.java @@ -26,15 +26,12 @@ import lombok.Getter; @AllArgsConstructor public enum TestblockMode implements Flag.Value { - NO_VALUE("FLAG_TESTBLOCK_NO_VALUE", false, false), - NORTH("FLAG_TESTBLOCK_NORTH", false, true), - SOUTH("FLAG_TESTBLOCK_SOUTH", false, false), - FIXED_NORTH("FLAG_TESTBLOCK_NORTH", true, true), - FIXED_SOUTH("FLAG_TESTBLOCK_SOUTH", true, false); + NO_VALUE("FLAG_TESTBLOCK_NO_VALUE", false), + NORTH("FLAG_TESTBLOCK_NORTH", true), + SOUTH("FLAG_TESTBLOCK_SOUTH", false); private static TestblockMode[] values; private final String chatValue; - private final boolean fixed; private final boolean north; @Override From 6822dc796fe6d25f03860eac3e200c49ae784834 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sat, 21 Dec 2024 19:30:31 +0100 Subject: [PATCH 05/56] Update Region System of BauSystem --- .../bausystem/utils/FlatteningWrapper15.java | 2 +- .../features/autostart/AutostartListener.java | 8 +- .../features/backup/BackupCommand.java | 8 +- .../features/cannon/CannonDetector.java | 5 +- .../features/cannon/depth/Depth.java | 4 +- .../features/countingwand/Countingwand.java | 2 +- .../countingwand/CountingwandListener.java | 2 +- .../endstone/DesignEndStoneCommand.java | 3 +- .../killchecker/KillcheckerVisualizer.java | 2 +- .../features/observer/ObserverTracer.java | 2 +- .../features/region/RegionCommand.java | 2 +- .../region/items/ColorBauGuiItem.java | 2 +- .../features/script/lua/libs/LuaLib.java | 2 +- .../script/lua/libs/WorldEditLib.java | 2 +- .../features/simulator/data/tnt/TNTPhase.java | 3 +- .../features/slaves/laufbau/Cuboid.java | 2 +- .../laufbau/states/CreatingLaufState.java | 2 +- .../laufbau/states/ProcessingTracesState.java | 2 +- .../bausystem/features/team/SkinCommand.java | 6 +- .../team/boundary/BoundaryViewer.java | 9 +- .../blockcounter/BlockCounterListener.java | 8 +- .../bausystem/features/tracer/TNTPoint.java | 12 +- .../features/util/KillAllCommand.java | 10 +- .../features/util/SelectCommand.java | 2 +- .../features/world/BauScoreboard.java | 9 +- .../worldedit/ColorReplaceCommand.java | 2 +- .../bausystem/region/BackupScheduler.java | 42 +- .../{regionnew => region}/Color.java | 41 +- .../bausystem/region/FlagStorage.java | 110 +--- .../bausystem/region/GlobalRegion.java | 42 -- .../{regionnew => region}/Point.java | 2 +- .../de/steamwar/bausystem/region/Region.java | 613 +++--------------- .../RegionFlagPolicy.java | 6 +- .../{regionnew => region}/RegionSystem.java | 6 +- .../{regionnew => region}/RegionType.java | 4 +- .../bausystem/region/RegionUtils.java | 100 +-- .../flags/ChangedMode.java | 2 +- .../flags/ColorMode.java | 4 +- .../{regionnew => region}/flags/FireMode.java | 2 +- .../steamwar/bausystem/region/flags/Flag.java | 134 ++-- .../flags/FreezeMode.java | 2 +- .../{regionnew => region}/flags/ItemMode.java | 2 +- .../flags/NoGravityMode.java | 2 +- .../flags/ProtectMode.java | 2 +- .../{regionnew => region}/flags/TNTMode.java | 2 +- .../flags/TestblockMode.java | 2 +- .../region/flags/flagvalues/ColorMode.java | 72 -- .../region/flags/flagvalues/FireMode.java | 60 -- .../region/flags/flagvalues/FreezeMode.java | 61 -- .../region/flags/flagvalues/ItemMode.java | 60 -- .../flags/flagvalues/NoGravityMode.java | 60 -- .../region/flags/flagvalues/ProtectMode.java | 60 -- .../region/flags/flagvalues/TNTMode.java | 59 -- .../steamwar/bausystem/region/tags/Tag.java | 24 - .../region/utils/RegionExtensionType.java | 25 - .../region/utils/RegionSelectionType.java | 3 +- .../bausystem/region/utils/RegionType.java | 34 - .../bausystem/regionnew/FlagStorage.java | 29 - .../steamwar/bausystem/regionnew/Region.java | 85 --- .../bausystem/regionnew/RegionSide.java | 25 - .../bausystem/regionnew/flags/Flag.java | 102 --- .../Prototype.java.txt} | 0 .../bausystem/regionold/Region.java.txt | 584 +++++++++++++++++ .../loader/PrototypeLoader.java.txt} | 0 .../loader/RegionLoader.java.txt} | 0 .../loader/Updater.java.txt} | 0 .../bausystem/utils/FlatteningWrapper.java | 2 +- .../bausystem/utils/PasteBuilder.java | 4 +- .../utils/bossbar/GlobalBossbar.java | 4 +- .../FixedFlagStorage.java | 10 +- .../FixedGlobalRegion.java | 62 +- .../{regionnew => region}/FixedRegion.java | 63 +- .../FixedRegionSystem.java | 2 +- 73 files changed, 927 insertions(+), 1796 deletions(-) rename BauSystem/BauSystem_Main/src/de/steamwar/bausystem/{regionnew => region}/Color.java (65%) delete mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/GlobalRegion.java rename BauSystem/BauSystem_Main/src/de/steamwar/bausystem/{regionnew => region}/Point.java (98%) rename BauSystem/BauSystem_Main/src/de/steamwar/bausystem/{regionnew => region}/RegionFlagPolicy.java (90%) rename BauSystem/BauSystem_Main/src/de/steamwar/bausystem/{regionnew => region}/RegionSystem.java (94%) rename BauSystem/BauSystem_Main/src/de/steamwar/bausystem/{regionnew => region}/RegionType.java (93%) rename BauSystem/BauSystem_Main/src/de/steamwar/bausystem/{regionnew => region}/flags/ChangedMode.java (97%) rename BauSystem/BauSystem_Main/src/de/steamwar/bausystem/{regionnew => region}/flags/ColorMode.java (96%) rename BauSystem/BauSystem_Main/src/de/steamwar/bausystem/{regionnew => region}/flags/FireMode.java (96%) rename BauSystem/BauSystem_Main/src/de/steamwar/bausystem/{regionnew => region}/flags/FreezeMode.java (97%) rename BauSystem/BauSystem_Main/src/de/steamwar/bausystem/{regionnew => region}/flags/ItemMode.java (97%) rename BauSystem/BauSystem_Main/src/de/steamwar/bausystem/{regionnew => region}/flags/NoGravityMode.java (97%) rename BauSystem/BauSystem_Main/src/de/steamwar/bausystem/{regionnew => region}/flags/ProtectMode.java (97%) rename BauSystem/BauSystem_Main/src/de/steamwar/bausystem/{regionnew => region}/flags/TNTMode.java (96%) rename BauSystem/BauSystem_Main/src/de/steamwar/bausystem/{regionnew => region}/flags/TestblockMode.java (97%) delete mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ColorMode.java delete mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/FireMode.java delete mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/FreezeMode.java delete mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ItemMode.java delete mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/NoGravityMode.java delete mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ProtectMode.java delete mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/TNTMode.java delete mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/tags/Tag.java delete mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionExtensionType.java delete mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionType.java delete mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/FlagStorage.java delete mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Region.java delete mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionSide.java delete mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/Flag.java rename BauSystem/BauSystem_Main/src/de/steamwar/bausystem/{region/Prototype.java => regionold/Prototype.java.txt} (100%) create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionold/Region.java.txt rename BauSystem/BauSystem_Main/src/de/steamwar/bausystem/{region/loader/PrototypeLoader.java => regionold/loader/PrototypeLoader.java.txt} (100%) rename BauSystem/BauSystem_Main/src/de/steamwar/bausystem/{region/loader/RegionLoader.java => regionold/loader/RegionLoader.java.txt} (100%) rename BauSystem/BauSystem_Main/src/de/steamwar/bausystem/{region/loader/Updater.java => regionold/loader/Updater.java.txt} (100%) rename BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/{regionnew => region}/FixedFlagStorage.java (86%) rename BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/{regionnew => region}/FixedGlobalRegion.java (65%) rename BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/{regionnew => region}/FixedRegion.java (61%) rename BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/{regionnew => region}/FixedRegionSystem.java (97%) diff --git a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/FlatteningWrapper15.java b/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/FlatteningWrapper15.java index 69872f57..266326e0 100644 --- a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/FlatteningWrapper15.java +++ b/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/FlatteningWrapper15.java @@ -42,7 +42,7 @@ import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockTypes; -import de.steamwar.bausystem.regionnew.Point; +import de.steamwar.bausystem.region.Point; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java index 28126ec5..3185c66c 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java @@ -44,7 +44,6 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import java.io.File; -import java.text.SimpleDateFormat; import java.util.*; @Linked @@ -106,11 +105,11 @@ public class AutostartListener implements Listener { public void activate(Player player) { Region region = Region.getRegion(player.getLocation()); - if (region.isGlobal()) { + if (region.getType().isGlobal()) { BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO_REGION", player); return; } - if (!region.hasType(RegionType.TESTBLOCK)) { + if (region.getTestblockArea().isPresent()) { BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO_REGION", player); return; } @@ -131,8 +130,7 @@ public class AutostartListener implements Listener { event.blockList().forEach(block -> { Region region = Region.getRegion(block.getLocation()); if (!regionStartTime.containsKey(region)) return; - if (!region.hasType(RegionType.TESTBLOCK)) return; - if (!region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) return; + if (!region.getTestblockArea().inRegion(block.getLocation(), true)) return; long tickDiff = TPSUtils.currentRealTick.get() - regionStartTime.remove(region); long preFightDurationInSeconds = getPreFightDurationInSeconds(region); RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT1", tickDiff); 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 6abe927a..919c08cd 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,7 +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.tags.Tag; +import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.utils.PasteBuilder; import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommandUtils; @@ -49,7 +49,7 @@ public class BackupCommand extends SWCommand { } static boolean checkGlobalRegion(Region region, Player p) { - if (region.isGlobal()) { + if (region.getType().isGlobal()) { BauSystem.MESSAGE.send("BACKUP_REGION_NO_REGION", p); return true; } @@ -62,11 +62,11 @@ public class BackupCommand extends SWCommand { if (checkGlobalRegion(region, p)) { return; } - if (!region.get(Tag.CHANGED)) { + if (region.getFlag(Flag.CHANGED).isPresent()) { BauSystem.MESSAGE.send("BACKUP_CREATE_NO_CHANGE", p); return; } - if (region.backup()) { + if (region.backup(false)) { BauSystem.MESSAGE.send("BACKUP_CREATE_SUCCESS", p); } else { BauSystem.MESSAGE.send("BACKUP_CREATE_FAILURE", p); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/CannonDetector.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/CannonDetector.java index 3ab4fe70..7c73888d 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/CannonDetector.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/CannonDetector.java @@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.cannon.depth.Depth; import de.steamwar.bausystem.features.cannon.depth.DepthManager; import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.entity.TNTPrimed; @@ -85,8 +84,8 @@ public class CannonDetector implements Listener { grouped.forEach((cannonKey, tntPrimeds) -> { if (tntPrimeds.size() <= 5) return; Region region = Region.getRegion(tntPrimeds.get(0).getLocation()); - if (region.isGlobal()) return; - if (!region.hasType(RegionType.TESTBLOCK)) return; + if (region.getType().isGlobal()) return; + if (region.getTestblockArea().isEmpty()) return; Depth depth = new Depth(region); DepthManager.init(tntPrimeds, depth); }); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/depth/Depth.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/depth/Depth.java index 22ce7fde..4cfacb98 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/depth/Depth.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/depth/Depth.java @@ -23,8 +23,6 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.configplayer.Config; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; -import de.steamwar.bausystem.region.utils.RegionExtensionType; -import de.steamwar.bausystem.region.utils.RegionType; import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.TextComponent; @@ -50,7 +48,7 @@ public class Depth { public void update(List blocks) { List blocksList = blocks.stream() - .filter(block -> region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) + .filter(block -> region.getTestblockArea().inRegion(block.getLocation(), true)) .collect(Collectors.toList()); tntCount++; for (Block block : blocksList) { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/Countingwand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/Countingwand.java index 6c667ba7..fb9316b9 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/Countingwand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/Countingwand.java @@ -20,7 +20,7 @@ package de.steamwar.bausystem.features.countingwand; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.regionnew.Point; +import de.steamwar.bausystem.region.Point; import de.steamwar.bausystem.shared.Pair; import de.steamwar.bausystem.utils.ItemUtils; import de.steamwar.inventory.SWItem; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandListener.java index 9d811f28..7233670a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandListener.java @@ -19,7 +19,7 @@ package de.steamwar.bausystem.features.countingwand; -import de.steamwar.bausystem.regionnew.Point; +import de.steamwar.bausystem.region.Point; import de.steamwar.linkage.Linked; import org.bukkit.FluidCollisionMode; import org.bukkit.event.EventHandler; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java index 92934c23..e50541a8 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java @@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.design.endstone; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.utils.BauMemberUpdateEvent; import de.steamwar.command.SWCommand; import de.steamwar.linkage.Linked; @@ -49,7 +48,7 @@ public class DesignEndStoneCommand extends SWCommand implements Listener { @Register(description = "DESIGN_ENDSTONE_COMMAND_HELP") public void genericCommand(@Validator Player player) { Region region = Region.getRegion(player.getLocation()); - if (!region.hasType(RegionType.BUILD)) { + if (region.getBuildArea().isEmpty()) { BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player); return; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerVisualizer.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerVisualizer.java index d7145f37..04822aa8 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerVisualizer.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerVisualizer.java @@ -20,7 +20,7 @@ package de.steamwar.bausystem.features.killchecker; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.regionnew.Point; +import de.steamwar.bausystem.region.Point; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java index e4aedd0a..c1e08fcf 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java @@ -20,7 +20,7 @@ package de.steamwar.bausystem.features.observer; import de.steamwar.Reflection; -import de.steamwar.bausystem.regionnew.Point; +import de.steamwar.bausystem.region.Point; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Particle; 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 e7cedc22..6d8d6f4d 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 @@ -28,7 +28,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.session.ClipboardHolder; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.util.SelectCommand; -import de.steamwar.bausystem.regionnew.Point; +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; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java index b886e756..a38c397f 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java @@ -22,7 +22,7 @@ package de.steamwar.bausystem.features.region.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.linkage.specific.BauGuiItem; -import de.steamwar.bausystem.regionnew.Color; +import de.steamwar.bausystem.region.Color; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.ColorMode; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/LuaLib.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/LuaLib.java index a86542df..a4af0d3a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/LuaLib.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/LuaLib.java @@ -19,7 +19,7 @@ package de.steamwar.bausystem.features.script.lua.libs; -import de.steamwar.bausystem.regionnew.Point; +import de.steamwar.bausystem.region.Point; import lombok.AllArgsConstructor; import org.bukkit.entity.Player; import org.luaj.vm2.*; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/WorldEditLib.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/WorldEditLib.java index 7f0cac4d..87d1f9fb 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/WorldEditLib.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/WorldEditLib.java @@ -22,7 +22,7 @@ package de.steamwar.bausystem.features.script.lua.libs; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.bukkit.BukkitPlayer; import com.sk89q.worldedit.math.BlockVector3; -import de.steamwar.bausystem.regionnew.Point; +import de.steamwar.bausystem.region.Point; import de.steamwar.bausystem.utils.FlatteningWrapper; import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; 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 29f59d93..20fe8d41 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 @@ -23,7 +23,6 @@ import de.steamwar.bausystem.features.simulator.data.SimulatorPhase; import de.steamwar.bausystem.features.simulator.execute.SimulatorAction; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -65,7 +64,7 @@ public final class TNTPhase extends SimulatorPhase { @Override public void accept(World world) { Location location = position.toLocation(world); - if (Region.getRegion(location).get(Flag.FREEZE) == FreezeMode.ACTIVE) return; + if (Region.getRegion(location).getFlag(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/slaves/laufbau/Cuboid.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/Cuboid.java index e5699aaa..c31653a5 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/Cuboid.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/Cuboid.java @@ -19,7 +19,7 @@ package de.steamwar.bausystem.features.slaves.laufbau; -import de.steamwar.bausystem.regionnew.Point; +import de.steamwar.bausystem.region.Point; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingLaufState.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingLaufState.java index 369ca0d9..e4ed312b 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingLaufState.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingLaufState.java @@ -27,7 +27,7 @@ import com.sk89q.worldedit.world.block.BlockTypes; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.bausystem.regionnew.Point; +import de.steamwar.bausystem.region.Point; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java index 04c43fd3..94eb6549 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java @@ -26,7 +26,7 @@ import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; import de.steamwar.bausystem.features.tracer.TNTPoint; import de.steamwar.bausystem.features.tracer.Trace; import de.steamwar.bausystem.features.tracer.TraceManager; -import de.steamwar.bausystem.regionnew.Point; +import de.steamwar.bausystem.region.Point; import de.steamwar.bausystem.utils.FlatteningWrapper; import org.bukkit.Location; import org.bukkit.World; 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 8394691e..ae466066 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 @@ -21,9 +21,7 @@ package de.steamwar.bausystem.features.team; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.team.boundary.BoundaryViewer; -import de.steamwar.bausystem.region.Prototype; import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; @@ -69,14 +67,14 @@ public class SkinCommand extends SWCommand { return; } Region region = Region.getRegion(p.getLocation()); - if (region.isGlobal()) { + if (region.getType().isGlobal()) { BauSystem.MESSAGE.send("SKIN_NO_REGION", p); return; } String name = String.join(" ", names); File arenaFile = new File("sections19/" + name + "/" + typeKuerzel + "Arena.schem"); - File testblockFile = region.hasType(RegionType.TESTBLOCK) ? new File("sections19/" + name + "/" + typeKuerzel + "Testblock.schem") : null; + File testblockFile = region.getTestblockArea().isPresent() ? new File("sections19/" + name + "/" + typeKuerzel + "Testblock.schem") : null; arenaFile.getParentFile().mkdirs(); if (testblockFile != null) { 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 808e6398..4d2b34a7 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 @@ -48,21 +48,18 @@ public class BoundaryViewer implements Listener { } viewers.forEach(player -> { Region region = Region.getRegion(player.getLocation()); - if (region.isGlobal()) return; + if (region.getType().isGlobal()) return; showRegion(region, player); - if (region.getLinkedRegion() != null) { - showRegion(region.getLinkedRegion(), player); - } }); }, 20, 20); } private void showRegion(Region region, Player player) { drawCuboid(player, TrickyParticleWrapper.impl.getVillagerHappy(), region.getMinPoint(), region.getMaxPoint()); - if (region.hasType(RegionType.TESTBLOCK)) { + if (region.getTestblockArea().isPresent()) { drawCuboid(player, Particle.END_ROD, region.getMinPointTestblockExtension(), region.getMaxPointTestblockExtension()); } - if (region.hasType(RegionType.BUILD)) { + if (region.getBuildArea().isPresent()) { drawCuboid(player, Particle.END_ROD, region.getMinPointBuildExtension(), region.getMaxPointBuildExtension()); } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounterListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounterListener.java index 979e5fe3..a891b76f 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounterListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounterListener.java @@ -20,8 +20,6 @@ package de.steamwar.bausystem.features.testblock.blockcounter; import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.region.utils.RegionExtensionType; -import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.linkage.Linked; import org.bukkit.block.Block; import org.bukkit.event.EventHandler; @@ -37,11 +35,13 @@ public class BlockCounterListener implements Listener { @EventHandler public void onEntityExplode(EntityExplodeEvent event) { Region region = Region.getRegion(event.getLocation()); - if (region.isGlobal()) { + if (region.getType().isGlobal()) { return; } List blockList = event.blockList(); - blockList = blockList.stream().filter(block -> region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)).collect(Collectors.toList()); + blockList = blockList.stream() + .filter(block -> region.getTestblockArea().inRegion(block.getLocation(), true)) + .collect(Collectors.toList()); if (blockList.isEmpty()) { return; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPoint.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPoint.java index a33c52f0..73315d9a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPoint.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPoint.java @@ -20,8 +20,6 @@ package de.steamwar.bausystem.features.tracer; import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.region.utils.RegionExtensionType; -import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.core.Core; import lombok.AccessLevel; import lombok.AllArgsConstructor; @@ -39,7 +37,7 @@ import java.util.Optional; */ @AllArgsConstructor(access = AccessLevel.PACKAGE) @Getter -public class TNTPoint{ +public class TNTPoint { /** * Unique number to identify records being of the same tnt */ @@ -99,7 +97,7 @@ public class TNTPoint{ * Constructor for object creation in trace recording */ protected TNTPoint(int tntId, TNTPrimed tnt, boolean explosion, boolean afterFirstExplosion, long ticksSinceStart, - List history, List destroyedBlocks) { + List history, List destroyedBlocks) { this.tntId = tntId; this.explosion = explosion; if (Core.getVersion() > 15) { @@ -117,12 +115,10 @@ public class TNTPoint{ boolean buildDestroy = false; boolean testblockDestroy = false; for (Block destroyedBlock : destroyedBlocks) { - if (Region.getRegion(destroyedBlock.getLocation()).inRegion(destroyedBlock.getLocation(), RegionType.BUILD, - RegionExtensionType.EXTENSION)) { + if (Region.getRegion(destroyedBlock.getLocation()).getBuildArea().inRegion(destroyedBlock.getLocation(), true)) { buildDestroy = true; } - if (Region.getRegion(destroyedBlock.getLocation()).inRegion(destroyedBlock.getLocation(), - RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) { + if (Region.getRegion(destroyedBlock.getLocation()).getTestblockArea().inRegion(destroyedBlock.getLocation(), true)) { testblockDestroy = true; } } 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 e08b40c0..c0d99689 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 @@ -21,12 +21,9 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.region.RegionUtils; -import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionSelectionType; -import de.steamwar.bausystem.region.utils.RegionType; +import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.command.SWCommand; import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; @@ -53,7 +50,7 @@ public class KillAllCommand extends SWCommand { public void genericCommand(@Validator Player player, RegionSelectionType regionSelectionType) { Region region = Region.getRegion(player.getLocation()); AtomicLong count = new AtomicLong(0); - if (regionSelectionType == RegionSelectionType.GLOBAL || GlobalRegion.getInstance() == region) { + if (regionSelectionType == RegionSelectionType.GLOBAL || region.getType().isGlobal()) { WORLD.getEntities() .stream() .filter(e -> !(e instanceof Player)) @@ -66,7 +63,7 @@ public class KillAllCommand extends SWCommand { WORLD.getEntities() .stream() .filter(e -> !(e instanceof Player)) - .filter(e -> region.inRegion(e.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) + .filter(e -> region.inRegion(e.getLocation())) .forEach(entity -> { entity.remove(); count.incrementAndGet(); @@ -74,5 +71,4 @@ public class KillAllCommand extends SWCommand { RegionUtils.actionBar(region, "OTHER_KILLALL_REGION", count.get()); } } - } 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 4f1df1af..7a11d678 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 @@ -1,7 +1,7 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.regionnew.Point; +import de.steamwar.bausystem.region.Point; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java index 5bd1e06d..38aa4039 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java @@ -1,7 +1,5 @@ package de.steamwar.bausystem.features.world; -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.utils.ScoreboardElement; @@ -101,8 +99,11 @@ public class BauScoreboard implements Listener { @Override public String getTitle() { Region region = Region.getRegion(player.getLocation()); - if (GlobalRegion.getInstance() == region) return "§eSteam§8War"; - String colorCode = BauSystem.MESSAGE.parse(region.get(Flag.COLOR).getChatValue(), player).substring(0, 2); + if (region.getType().isGlobal()) return "§eSteam§8War"; + String colorCode = "§e"; + if (region.hasFlag(Flag.COLOR).isReadable()) { + colorCode = "§" + region.getFlag(Flag.COLOR).get().getColor().getColorCode(); + } return colorCode + "■ §eSteam§8War " + colorCode + "■"; // ■ } }); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java index 3df0755c..6b6659ba 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java @@ -28,7 +28,7 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import de.steamwar.bausystem.features.world.WorldEditListener; import de.steamwar.bausystem.features.worldedit.utils.SpecialReplace; -import de.steamwar.bausystem.regionnew.Color; +import de.steamwar.bausystem.region.Color; import de.steamwar.bausystem.shared.Pair; import de.steamwar.bausystem.utils.WorldEditUtils; import de.steamwar.command.PreviousArguments; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java index 44b57332..eb57e09f 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java @@ -1,33 +1,14 @@ -/* - * 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 de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.region.tags.Tag; +import de.steamwar.bausystem.region.flags.ChangedMode; +import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.linkage.Linked; import de.steamwar.linkage.api.Enable; import org.bukkit.scheduler.BukkitRunnable; import java.util.Iterator; - @Linked public class BackupScheduler implements Enable { @@ -39,26 +20,29 @@ public class BackupScheduler implements Enable { new BukkitRunnable() { @Override public void run() { - final Iterator regions = Region.getREGION_MAP().values().stream().filter(region -> region.get(Tag.CHANGED)).iterator(); - BackupScheduler.this.doBackup(regions); + Iterator regionsToBackup = RegionSystem.INSTANCE.getRegions() + .filter(region -> region.isFlag(Flag.CHANGED, ChangedMode.HAS_CHANGE)) + .iterator(); + if (!regionsToBackup.hasNext()) return; + doBackup(regionsToBackup); } }.runTaskTimer(BauSystem.getInstance(), INITIAL, PERIOD); } - public void doBackup(final Iterator regionIterator) { + private void doBackup(Iterator regionsToBackup) { new BukkitRunnable() { @Override public void run() { - if (!regionIterator.hasNext()) { + if (!regionsToBackup.hasNext()) { this.cancel(); return; } - final Region region = regionIterator.next(); - if (region.backup()) { - region.remove(Tag.CHANGED); + Region region = regionsToBackup.next(); + if (region.backup(true)) { + region.setFlag(Flag.CHANGED, ChangedMode.NO_CHANGE); } } }.runTaskTimer(BauSystem.getInstance(), 0, 20 * 60); } -} \ No newline at end of file +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Color.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Color.java similarity index 65% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Color.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Color.java index 6292fbe1..72052d74 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Color.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Color.java @@ -17,23 +17,30 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.regionnew; +package de.steamwar.bausystem.region; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@Getter public enum Color { - WHITE, - ORANGE, - MAGENTA, - LIGHT_BLUE, - YELLOW, - LIME, - PINK, - GRAY, - LIGHT_GRAY, - CYAN, - PURPLE, - BLUE, - BROWN, - GREEN, - RED, - BLACK; + WHITE('f'), + ORANGE('6'), + MAGENTA('5'), + LIGHT_BLUE('b'), + YELLOW('e'), + LIME('a'), + PINK('d'), + GRAY('8'), + LIGHT_GRAY('7'), + CYAN('3'), + PURPLE('5'), + BLUE('9'), + BROWN('e'), + GREEN('2'), + RED('c'), + BLACK('1'); + + private final char colorCode; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java index e0ee43a5..3ca76ace 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java @@ -1,107 +1,29 @@ /* - * This file is a part of the SteamWar software. + * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * 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 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. + * 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 . + * 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.Flag; -import de.steamwar.bausystem.region.tags.Tag; -import yapion.hierarchy.types.YAPIONObject; -import java.util.EnumMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; +public interface FlagStorage { -/** - * Tags and Flags are not allowed to have overlaping names. - */ -public class FlagStorage { + & Flag.Value> boolean set(Flag flag, T value); - public static FlagStorage createStorage(YAPIONObject yapionObject) { - FlagStorage flagStorage = new FlagStorage(); - for (final Flag flag : Flag.getFlags()) { - try { - String s = yapionObject.getPlainValue(flag.name()); - flagStorage.set(flag, flag.getFlagValueOf(s)); - } catch (Exception e) { - flagStorage.set(flag, flag.getDefaultValue()); - } - } - for (final Tag tag : Tag.values()) { - if (yapionObject.containsKey(tag.name())) { - flagStorage.set(tag); - } - } - return flagStorage; - } - - public static YAPIONObject toYAPION(FlagStorage flagStorage) { - YAPIONObject yapionObject = new YAPIONObject(); - for (final Flag flag : Flag.getFlags()) { - if (flag.getDefaultValue() == flagStorage.flags.getOrDefault(flag, flag.getDefaultValue())) { - yapionObject.remove(flag.name()); - } else { - yapionObject.add(flag.name(), flagStorage.get(flag).getValue().name()); - } - } - for (Tag tag : Tag.values()) { - if (flagStorage.tagSet.contains(tag)) { - yapionObject.add(tag.name(), ""); - } else { - yapionObject.remove(tag.name()); - } - } - return yapionObject; - } - - protected Map> flags; - protected Set tagSet; - - public FlagStorage() { - flags = new EnumMap<>(Flag.class); - tagSet = new HashSet<>(); - readKeys(); - } - - public boolean set(final Flag flagType, final Flag.Value value) { - return flags.put(flagType, value) != value; - } - - public Flag.Value get(final Flag flagType) { - return flags.getOrDefault(flagType, flagType.getDefaultValue()); - } - - public boolean set(final Tag tag) { - return tagSet.add(tag); - } - - public boolean remove(final Tag tag) { - return tagSet.remove(tag); - } - - public boolean is(final Tag tag) { - return tagSet.contains(tag); - } - - private void readKeys() { - for (final Flag flag : Flag.getFlags()) { - flags.put(flag, flag.getDefaultValue()); - } - } -} \ No newline at end of file + & Flag.Value> T get(Flag flag); +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/GlobalRegion.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/GlobalRegion.java deleted file mode 100644 index 83623989..00000000 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/GlobalRegion.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 de.steamwar.bausystem.region.utils.RegionExtensionType; -import de.steamwar.bausystem.region.utils.RegionType; -import lombok.Getter; -import org.bukkit.Location; -import yapion.hierarchy.types.YAPIONObject; - -public class GlobalRegion extends Region { - - @Getter - static GlobalRegion instance; - - public GlobalRegion(FlagStorage flagStorage, YAPIONObject regionData) { - super("global", null, new YAPIONObject(), flagStorage, regionData); - instance = this; - } - - @Override - public boolean inRegion(Location location, RegionType regionType, RegionExtensionType regionExtensionType) { - return true; - } -} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Point.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Point.java similarity index 98% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Point.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Point.java index a9f3534c..3dad7a51 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Point.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Point.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.regionnew; +package de.steamwar.bausystem.region; import com.sk89q.worldedit.math.BlockVector3; import lombok.AllArgsConstructor; 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 bf8477e9..72a007a0 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -1,585 +1,128 @@ /* - * This file is a part of the SteamWar software. + * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * 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 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. + * 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 . + * 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 com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.bukkit.BukkitWorld; -import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.bausystem.region.flags.flagvalues.TNTMode; -import de.steamwar.bausystem.region.tags.Tag; -import de.steamwar.bausystem.region.utils.RegionExtensionType; -import de.steamwar.bausystem.region.utils.RegionType; -import de.steamwar.bausystem.regionnew.Point; -import de.steamwar.bausystem.shared.SizedStack; -import de.steamwar.bausystem.utils.FlatteningWrapper; -import de.steamwar.bausystem.utils.PasteBuilder; -import de.steamwar.core.Core; -import de.steamwar.sql.SchematicType; -import lombok.AccessLevel; -import lombok.Getter; +import de.steamwar.sql.SchematicNode; import lombok.NonNull; -import org.bukkit.Bukkit; import org.bukkit.Location; -import yapion.hierarchy.types.YAPIONObject; -import yapion.hierarchy.types.YAPIONType; -import yapion.hierarchy.types.YAPIONValue; +import javax.annotation.Nullable; import java.io.File; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.*; -import java.util.function.ObjIntConsumer; -import java.util.function.Predicate; -import java.util.stream.Collectors; +import java.util.Optional; -@Getter -public class Region { +public interface Region { - @Getter - private static final Map REGION_MAP = new HashMap<>(); - private static final File backupFolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "backup"); - private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd' 'HH:mm:ss"); - - public static Region getRegion(Location location) { - return REGION_MAP.values().stream() - .filter(r -> r.inRegion(location, r.minPoint, r.maxPoint)) - .findFirst() - .orElse(GlobalRegion.instance); + static Region getRegion(Location location) { + return RegionSystem.INSTANCE.get(location); } - public static Set getRegion(Prototype prototype) { - return REGION_MAP.values().stream() - .filter(r -> r.getPrototype() == prototype) - .collect(Collectors.toSet()); + RegionType getType(); + + & Flag.Value> RegionFlagPolicy hasFlag(@NonNull Flag flag); + + & Flag.Value> boolean setFlag(@NonNull Flag flag, T value); + + & Flag.Value> Optional getFlag(@NonNull Flag flag); + + default & Flag.Value> boolean isFlag(@NonNull Flag flag, T value) { + if (hasFlag(flag).isReadable()) { + Optional optional = getFlag(flag); + return optional.isPresent() && optional.get() == value; + } + return false; } - public static void setGlobal(Flag flagType, Flag.Value value) { - REGION_MAP.values().forEach(region -> region.set(flagType, value)); - } + Point getMinPoint(); - YAPIONObject regionData; + Point getMaxPoint(); - private String name; - private Prototype prototype; - private Set prototypes; - private String skin; + boolean inRegion(Location location); - private Point minPoint; - private Point maxPoint; + Inner getBuildArea(); - private Point minPointTestblock; - private Point maxPointTestblock; + Inner getTestblockArea(); - private Point minPointTestblockExtension; - private Point maxPointTestblockExtension; + // TODO: Add forEachChunk and getChunkOutsidePredicate - private Point minPointBuild; - private Point maxPointBuild; + Optional getGameModeConfig(); - private Point minPointBuildExtension; - private Point maxPointBuildExtension; + boolean backup(boolean automatic); - private int floorLevel; - private int waterLevel; + Optional copy(); - private Point copyPoint; // Nullable - private Point testBlockPoint; // Nullable + void reset(); - private String linkedRegionName = null; // Nullable - private Region linkedRegion = null; // Nullable + void remember(EditSession editSession); - private FlagStorage flagStorage; + boolean undo(); - @Getter(AccessLevel.PRIVATE) - private SizedStack undoSessions; + boolean redo(); - @Getter(AccessLevel.PRIVATE) - private SizedStack redoSessions; + interface Inner { - public Region(String name, Prototype prototype, YAPIONObject regionConfig, FlagStorage flagStorage, YAPIONObject regionData) { - this.name = name; - this.regionData = regionData; - if (prototype != null) { - REGION_MAP.put(name, this); - } + Inner EMPTY = new Inner() { + private static final Point ZERO = new Point(0, 0, 0); - linkedRegionName = regionConfig.getPlainValueOrDefault("optionsLinkedWith", null); - - prototypes = new HashSet<>(); - if (regionConfig.containsKey("prototypes", YAPIONType.ARRAY)) { - regionConfig.getArray("prototypes").forEach(yapionAnyType -> { - if (yapionAnyType instanceof YAPIONValue) { - prototypes.add(((YAPIONValue) yapionAnyType).get()); - } - }); - } - if (regionConfig.containsKey("prototype")) { - prototypes.add(regionConfig.getPlainValue("prototype")); - } - - this.flagStorage = flagStorage; - Point point = null; - if (regionConfig.containsKey("minX", Integer.class) && regionConfig.containsKey("minY", Integer.class) && regionConfig.containsKey("minZ", Integer.class)) { - point = new Point(regionConfig.getPlainValue("minX"), regionConfig.getPlainValue("minY"), regionConfig.getPlainValue("minZ")); - } - if (prototype != null && prototypes.contains(prototype.getName())) { - generatePrototypeData(prototype, point); - } else if (regionConfig.containsKey("prototype")) { - generatePrototypeData(Prototype.getByName(regionConfig.getPlainValue("prototype")), point); - } - if (prototype != null) { - skin = regionData.getPlainValueOrDefault("skin", prototype.getDefaultSkin()); - if (!prototype.getSkinMap().containsKey(skin)) { - skin = prototype.getDefaultSkin(); + @Override + public Point getMinPoint(boolean extension) { + return ZERO; } - } - regionData.add("skin", skin); - if (!hasType(RegionType.BUILD) || !hasType(RegionType.TESTBLOCK)) { - flagStorage.set(Flag.TNT, TNTMode.DENY); - } - } - - private void generatePrototypeData(Prototype prototype, Point point) { - if (prototype == null) { - return; - } - - this.prototype = prototype; - this.skin = prototype.getDefaultSkin(); - - this.minPoint = point; - this.maxPoint = point.add(prototype.getSizeX() - 1, prototype.getSizeY() - 1, prototype.getSizeZ() - 1); - - if (prototype.getTestblock() != null) { - this.minPointTestblock = point.add(prototype.getTestblock().getOffsetX(), prototype.getTestblock().getOffsetY(), prototype.getTestblock().getOffsetZ()); - this.maxPointTestblock = this.minPointTestblock.add(prototype.getTestblock().getSizeX() - 1, prototype.getTestblock().getSizeY() - 1, prototype.getTestblock().getSizeZ() - 1); - - this.minPointTestblockExtension = this.minPointTestblock.subtract(prototype.getTestblock().getExtensionNegativeX(), prototype.getTestblock().getExtensionNegativeY(), prototype.getTestblock().getExtensionNegativeZ()); - this.maxPointTestblockExtension = this.maxPointTestblock.add(prototype.getTestblock().getExtensionPositiveX(), prototype.getTestblock().getExtensionPositiveY(), prototype.getTestblock().getExtensionPositiveZ()); - - if (prototype.getTestblock().getCopyOffsetX() != 0 || prototype.getTestblock().getCopyOffsetY() != 0 || prototype.getTestblock().getCopyOffsetZ() != 0) { - this.testBlockPoint = this.minPointTestblock.add(prototype.getTestblock().getCopyOffsetX(), prototype.getTestblock().getCopyOffsetY(), prototype.getTestblock().getCopyOffsetZ()); - } else { - this.testBlockPoint = this.minPointTestblock.add(prototype.getTestblock().getSizeX() / 2, 0, -1); + @Override + public Point getMaxPoint(boolean extension) { + return ZERO; } - } - if (prototype.getBuild() != null) { - this.minPointBuild = point.add(prototype.getBuild().getOffsetX(), prototype.getBuild().getOffsetY(), prototype.getBuild().getOffsetZ()); - this.maxPointBuild = this.minPointBuild.add(prototype.getBuild().getSizeX() - 1, prototype.getBuild().getSizeY() - 1, prototype.getBuild().getSizeZ() - 1); - - this.minPointBuildExtension = this.minPointBuild.subtract(prototype.getBuild().getExtensionNegativeX(), prototype.getBuild().getExtensionNegativeY(), prototype.getBuild().getExtensionNegativeZ()); - this.maxPointBuildExtension = this.maxPointBuild.add(prototype.getBuild().getExtensionPositiveX(), prototype.getBuild().getExtensionPositiveY(), prototype.getBuild().getExtensionPositiveZ()); - - if (!prototype.getBuild().isHasCopyPoint() && (prototype.getCopyPointOffsetX() != 0 || prototype.getCopyPointOffsetY() != 0 || prototype.getCopyPointOffsetZ() != 0)) { - this.copyPoint = minPoint.add(prototype.getCopyPointOffsetX(), prototype.getCopyPointOffsetY(), prototype.getCopyPointOffsetZ()); - } else if (prototype.getBuild().getCopyOffsetX() != 0 || prototype.getBuild().getCopyOffsetY() != 0 || prototype.getBuild().getCopyOffsetZ() != 0) { - this.copyPoint = this.minPointBuild.add(prototype.getBuild().getCopyOffsetX(), prototype.getBuild().getCopyOffsetY(), prototype.getBuild().getCopyOffsetZ()); - } else { - this.copyPoint = this.minPointBuild.add(prototype.getBuild().getSizeX() / 2, 0, prototype.getBuild().getSizeZ()); - } - } else if (prototype.getCopyPointOffsetX() != 0 || prototype.getCopyPointOffsetY() != 0 || prototype.getCopyPointOffsetZ() != 0) { - this.copyPoint = minPoint.add(prototype.getCopyPointOffsetX(), prototype.getCopyPointOffsetY(), prototype.getCopyPointOffsetZ()); - } - - if (prototype.getFloorOffset() != 0) { - floorLevel = minPoint.getY() + prototype.getFloorOffset(); - } else { - floorLevel = 0; - } - - if (prototype.getWaterOffset() != 0) { - waterLevel = minPoint.getY() + prototype.getWaterOffset(); - } else { - waterLevel = 0; - } - } - - public boolean inRegion(Location location, RegionType regionType, RegionExtensionType regionExtensionType) { - if (!hasType(regionType)) { - return false; - } - switch (regionType) { - case BUILD: - Point minBPoint = regionExtensionType == RegionExtensionType.EXTENSION ? minPointBuildExtension : minPointBuild; - Point maxBPoint = regionExtensionType == RegionExtensionType.EXTENSION ? maxPointBuildExtension : maxPointBuild; - return inRegion(location, minBPoint, maxBPoint); - case TESTBLOCK: - Point minTBPoint = regionExtensionType == RegionExtensionType.EXTENSION ? minPointTestblockExtension : minPointTestblock; - Point maxTBPoint = regionExtensionType == RegionExtensionType.EXTENSION ? maxPointTestblockExtension : maxPointTestblock; - return inRegion(location, minTBPoint, maxTBPoint); - default: - case NORMAL: - return inRegion(location, minPoint, maxPoint); - } - } - - private boolean inRegion(Location location, Point minPoint, Point maxPoint) { - int blockX = location.getBlockX(); - int blockY = location.getBlockY(); - int blockZ = location.getBlockZ(); - return blockX >= minPoint.getX() && blockX <= maxPoint.getX() && - blockY >= minPoint.getY() && blockY <= maxPoint.getY() && - blockZ >= minPoint.getZ() && blockZ <= maxPoint.getZ(); - } - - public boolean hasType(RegionType regionType) { - if (prototype == null) { - return false; - } - if (regionType == null) { - return false; - } - switch (regionType) { - case BUILD: - return prototype.getBuild() != null; - case TESTBLOCK: - return prototype.getTestblock() != null; - default: - case NORMAL: - return true; - } - } - - public boolean hasExtensionType(RegionType regionType) { - if (!hasType(regionType)) { - return false; - } - switch (regionType) { - case BUILD: - return prototype.getBuild().isExtensionRegistered(); - case TESTBLOCK: - return prototype.getTestblock().isExtensionRegistered(); - default: - case NORMAL: + @Override + public boolean inRegion(Location location, boolean extension) { return false; - } - } - - public String getDisplayName() { - return prototype != null ? prototype.getSkinMap().get(skin).getName() : ""; - } - - private void setLinkedRegion(Predicate regionConsumer) { - if (linkedRegionName == null) { - return; - } - if (linkedRegion != null) { - if (regionConsumer.test(linkedRegion)) { - RegionUtils.save(linkedRegion); } - return; - } - for (Region region : REGION_MAP.values()) { - if (region.name.equals(linkedRegionName)) { - linkedRegion = region; - if (regionConsumer.test(linkedRegion)) { - RegionUtils.save(linkedRegion); - } - return; + + @Override + public Optional copy(boolean extension) { + return Optional.empty(); } - } - } - public Region getLinkedRegion() { - if (linkedRegion == null && linkedRegionName != null) { - setLinkedRegion(region -> false); - } - return linkedRegion; - } - - public boolean setPrototype(@NonNull Prototype prototype) { - if (!prototypes.contains(prototype.getName())) { - return false; - } - return _setPrototype(prototype); - } - - boolean _setPrototype(@NonNull Prototype prototype) { - generatePrototypeData(prototype, minPoint); - RegionUtils.save(this); - return true; - } - - public boolean setSkin(@NonNull String skinName) { - if (!prototype.getSkinMap().containsKey(skinName)) { - return false; - } - this.skin = skinName; - setLinkedRegion(region -> { - region.skin = skinName; - return true; - }); - regionData.add("skin", skin); - return true; - } - - public void set(Flag flagType, Flag.Value value) { - if (flagStorage.set(flagType, value)) { - RegionUtils.save(this); - } - setLinkedRegion(region -> region.flagStorage.set(flagType, value)); - } - - public void set(Tag tag) { - if (flagStorage.set(tag)) { - RegionUtils.save(this); - } - setLinkedRegion(region -> region.flagStorage.set(tag)); - } - - public void remove(Tag tag) { - if (flagStorage.remove(tag)) { - RegionUtils.save(this); - } - } - - public Flag.Value get(Flag flagType) { - return flagStorage.get(flagType); - } - - public boolean get(Tag tagType) { - return flagStorage.is(tagType); - } - - public & Flag.Value> T getPlain(Flag flagType) { - return (T) flagStorage.get(flagType).getValue(); - } - - public & Flag.Value> T getPlain(Flag flagType, Class type) { - return (T) flagStorage.get(flagType).getValue(); - } - - public Point getMinPoint(RegionType regionType, RegionExtensionType regionExtensionType) { - switch (regionType) { - case TESTBLOCK: - return (regionExtensionType == null || regionExtensionType == RegionExtensionType.NORMAL) ? minPointTestblock : minPointTestblockExtension; - case BUILD: - return (regionExtensionType == null || regionExtensionType == RegionExtensionType.NORMAL) ? minPointBuild : minPointBuildExtension; - default: - case NORMAL: - return minPoint; - } - } - - public Point getMaxPoint(RegionType regionType, RegionExtensionType regionExtensionType) { - switch (regionType) { - case TESTBLOCK: - return (regionExtensionType == null || regionExtensionType == RegionExtensionType.NORMAL) ? maxPointTestblock : maxPointTestblockExtension; - case BUILD: - return (regionExtensionType == null || regionExtensionType == RegionExtensionType.NORMAL) ? maxPointBuild : maxPointBuildExtension; - default: - case NORMAL: - return maxPoint; - } - } - - boolean hasReset(RegionType regionType) { - if (!hasType(regionType)) { - return false; - } - switch (regionType) { - case TESTBLOCK: - return prototype.getSkinMap().get(skin).getTestblockSchematicFile() != null; - case BUILD: - return prototype.getSkinMap().get(skin).getBuildSchematicFile() != null; - default: - case NORMAL: - return prototype.getSkinMap().get(skin).getSchematicFile() != null; - } - } - - public File getResetFile(RegionType regionType) { - if (!hasReset(regionType)) { - return null; - } - switch (regionType) { - case TESTBLOCK: - return prototype.getSkinMap().get(skin).getTestblockSchematicFile(); - case BUILD: - return prototype.getSkinMap().get(skin).getBuildSchematicFile(); - default: - case NORMAL: - return prototype.getSkinMap().get(skin).getSchematicFile(); - } - } - - public void reset(PasteBuilder pasteBuilder, RegionType regionType, RegionExtensionType regionExtensionType) { - if (!hasReset(regionType)) { - return; - } - if (regionExtensionType == RegionExtensionType.EXTENSION && !hasExtensionType(regionType)) { - regionExtensionType = RegionExtensionType.NORMAL; - } - - pasteBuilder.reset(regionExtensionType == RegionExtensionType.EXTENSION) - .minPoint(getMinPoint(regionType, regionExtensionType)) - .maxPoint(getMaxPoint(regionType, regionExtensionType)) - .waterLevel(waterLevel); - if (pasteBuilder.getClipboardProvider().is(PasteBuilder.SchematicProvider.class)) { - SchematicType schematicType = pasteBuilder.getClipboardProvider().as(PasteBuilder.SchematicProvider.class).getSchematic().getSchemtype(); - pasteBuilder.rotate(schematicType.fightType() || schematicType.check()); - } - - switch (regionType) { - case BUILD: - pasteBuilder.pastePoint(minPointBuild.add(prototype.getBuild().getSizeX() / 2, 0, prototype.getBuild().getSizeZ() / 2)); - break; - case TESTBLOCK: - Point pastePoint = minPointTestblock.add(prototype.getTestblock().getSizeX() / 2, 0, prototype.getTestblock().getSizeZ() / 2); - if (pasteBuilder.getClipboardProvider().is(PasteBuilder.SchematicProvider.class)) { - SchematicType schematicType = pasteBuilder.getClipboardProvider().as(PasteBuilder.SchematicProvider.class).getSchematic().getSchemtype(); - if (schematicType.getKuerzel().equalsIgnoreCase("wg")) { - pastePoint = pastePoint.add(0, 0, 1); - } - if (schematicType.getKuerzel().equalsIgnoreCase("ws")) { - pastePoint = pastePoint.add(-1, 0, 1); - } - if (schematicType.getKuerzel().equalsIgnoreCase("as")) { - pastePoint = pastePoint.add(-1, 0, 1); - } - } - pasteBuilder.pastePoint(pastePoint); - break; - default: - case NORMAL: - pasteBuilder.pastePoint(minPoint.add(prototype.getSizeX() / 2, 0, prototype.getSizeZ() / 2)); - break; - } - - initSessions(); - undoSessions.push(pasteBuilder.run()); - } - - public void remember(EditSession editSession) { - initSessions(); - undoSessions.push(editSession); - } - - public boolean isGlobal() { - return this == GlobalRegion.getInstance(); - } - - private void initSessions() { - if (undoSessions == null) { - undoSessions = new SizedStack<>(20); - redoSessions = new SizedStack<>(20); - } - } - - public boolean undo() { - initSessions(); - EditSession session = undoSessions.pop(); - if (session == null) - return false; - - try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) { - session.undo(e); - redoSessions.push(e); - } - return true; - } - - public boolean redo() { - initSessions(); - EditSession session = redoSessions.pop(); - if (session == null) - return false; - - try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) { - session.redo(e); - undoSessions.push(e); - } - return true; - } - - public boolean backup() { - final File definedBackupFolder = new File(new File(backupFolder, prototype.getName()), name); - //noinspection ResultOfMethodCallIgnored - definedBackupFolder.mkdirs(); - - File[] currentBackups = definedBackupFolder.listFiles(); - if (currentBackups != null && currentBackups.length >= 20) { - List files = new ArrayList<>(Arrays.asList(currentBackups)); - files.sort(Comparator.comparingLong(File::lastModified)); - while (files.size() >= 20) files.remove(0).delete(); - } - - final File backupFile = new File(definedBackupFolder, LocalDateTime.now().format(formatter) + ".schem"); - return FlatteningWrapper.impl.backup(minPoint, maxPoint, backupFile); - } - - public static boolean copy(Point minPoint, Point maxPoint, File file) { - return FlatteningWrapper.impl.backup(minPoint, maxPoint, file); - } - - public List listBackup() { - final File definedBackupFolder = new File(new File(backupFolder, prototype.getName()), name); - //noinspection ResultOfMethodCallIgnored - definedBackupFolder.mkdirs(); - - File[] currentBackups = definedBackupFolder.listFiles(); - List files = new ArrayList<>(Arrays.asList(currentBackups)); - files.sort(Comparator.comparingLong(File::lastModified)); - return files.stream().map(File::getName).collect(Collectors.toList()); - } - - public File getBackupFile(String backupName) { - final File definedBackupFolder = new File(new File(backupFolder, prototype.getName()), name); - //noinspection ResultOfMethodCallIgnored - definedBackupFolder.mkdirs(); - File[] files = definedBackupFolder.listFiles((dir, name) -> name.equals(backupName + ".schem")); - if (files == null || files.length == 0) return null; - return files[0]; - } - - public void forEachChunk(ObjIntConsumer executor) { - for (int x = (int) Math.floor(minPoint.getX() / 16.0); x <= (int) Math.ceil(maxPoint.getX() / 16.0); x++) { - for (int z = (int) Math.floor(minPoint.getZ() / 16.0); z <= (int) Math.ceil(maxPoint.getZ() / 16.0); z++) { - executor.accept(x, z); + @Override + public void reset(@Nullable SchematicNode schematicNode, boolean extension) { } - } - } + }; - public boolean buildChunkOutside(int chunkX, int chunkY) { - if (!hasType(RegionType.BUILD)) { - return Math.floor(minPoint.getX() / 16.0) > chunkX || chunkX >= Math.ceil(maxPoint.getX() / 16.0) || - Math.floor(minPoint.getZ() / 16.0) > chunkY || chunkY >= Math.ceil(maxPoint.getZ() / 16.0); + default boolean isEmpty() { + return this == EMPTY; } - if (!hasExtensionType(RegionType.BUILD)) { - return Math.floor(minPointBuild.getX() / 16.0) > chunkX || chunkX >= Math.ceil(maxPointBuild.getX() / 16.0) || - Math.floor(minPointBuild.getZ() / 16.0) > chunkY || chunkY >= Math.ceil(maxPointBuild.getZ() / 16.0); - } - return Math.floor(minPointBuildExtension.getX() / 16.0) > chunkX || chunkX >= Math.ceil(maxPointBuildExtension.getX() / 16.0) || - Math.floor(minPointBuildExtension.getZ() / 16.0) > chunkY || chunkY >= Math.ceil(maxPointBuildExtension.getZ() / 16.0); - } - public File gameModeConfig() { - File baseFile = new File(BauSystem.getInstance().getDataFolder().getParentFile(), "FightSystem"); - for (int version = Core.getVersion(); version >= 15; version--) { - File specific = new File(baseFile, prototype.getDisplayName() + version + ".yml"); - if (specific.exists()) return specific; + default boolean isPresent() { + return this != EMPTY; } - return null; + + Point getMinPoint(boolean extension); + + Point getMaxPoint(boolean extension); + + boolean inRegion(Location location, boolean extension); + + Optional copy(boolean extension); + + void reset(@Nullable SchematicNode schematicNode, boolean extension); } -} \ No newline at end of file +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionFlagPolicy.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionFlagPolicy.java similarity index 90% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionFlagPolicy.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionFlagPolicy.java index 7878a79a..ecc3d136 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionFlagPolicy.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionFlagPolicy.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.regionnew; +package de.steamwar.bausystem.region; import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -31,4 +31,8 @@ public enum RegionFlagPolicy { private final boolean readable; private final boolean writable; + + public boolean isApplicable() { + return readable || writable; + } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionSystem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java similarity index 94% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionSystem.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java index bbe4960d..9c480219 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionSystem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.regionnew; +package de.steamwar.bausystem.region; import org.bukkit.Location; @@ -27,7 +27,7 @@ import java.util.stream.Stream; public interface RegionSystem { - RegionSystem REGION_SYSTEM = init(); + RegionSystem INSTANCE = init(); void load(); void save(); @@ -43,7 +43,7 @@ public interface RegionSystem { private static RegionSystem init() { try { - return (RegionSystem) Class.forName("de.steamwar.bausystem.regionnew.FixedRegionSystem").getConstructor().newInstance(); + return (RegionSystem) Class.forName("de.steamwar.bausystem.region.FixedRegionSystem").getConstructor().newInstance(); } catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { return new RegionSystem() { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionType.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionType.java similarity index 93% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionType.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionType.java index ff91fcd5..dda01029 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionType.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionType.java @@ -17,11 +17,13 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.regionnew; +package de.steamwar.bausystem.region; +import lombok.Getter; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor +@Getter public enum RegionType { GLOBAL(true), 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 e30c3ed9..1559025b 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionUtils.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionUtils.java @@ -1,92 +1,48 @@ -/* - * 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.EditSession; -import com.sk89q.worldedit.extent.clipboard.Clipboard; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.region.utils.RegionExtensionType; -import de.steamwar.bausystem.region.utils.RegionType; -import de.steamwar.bausystem.utils.FlatteningWrapper; -import de.steamwar.bausystem.worlddata.WorldData; import lombok.experimental.UtilityClass; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import java.io.File; import java.util.function.Consumer; import java.util.function.Function; - @UtilityClass public class RegionUtils { public void actionBar(Region region, String s, Object... objects) { + forEachInRegion(region, player -> { + player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(BauSystem.MESSAGE.parse(s, player, objects))); + }); + } + + public void message(Region region, String s, Object... objects) { + forEachInRegion(region, player -> BauSystem.MESSAGE.send(s, player, objects)); + } + + public void message(Region region, Function function) { + forEachInRegion(region, player -> { + String message = function.apply(player); + if (message == null) { + return; + } + + player.sendMessage(message); + }); + } + + public void message(Region region, Consumer consumer) { + forEachInRegion(region, consumer); + } + + public void forEachInRegion(Region region, Consumer consumer) { Bukkit.getOnlinePlayers() .stream() - .filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) - .filter(player -> !region.isGlobal() || Region.getRegion(player.getLocation()).isGlobal()) - .forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(BauSystem.MESSAGE.parse(s, player, objects)))); + .filter(player -> region.inRegion(player.getLocation())) + .filter(player -> !region.getType().isGlobal() || Region.getRegion(player.getLocation()).getType().isGlobal()) + .forEach(consumer); } - - public static void message(Region region, String message, Object... objects) { - Bukkit.getOnlinePlayers() - .stream() - .filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) - .filter(player -> !region.isGlobal() || Region.getRegion(player.getLocation()).isGlobal()) - .forEach(player -> BauSystem.MESSAGE.send(message, player, objects)); - } - - public static void message(Region region, Function function) { - Bukkit.getOnlinePlayers() - .stream() - .filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) - .filter(player -> !region.isGlobal() || Region.getRegion(player.getLocation()).isGlobal()) - .forEach(player -> { - String message = function.apply(player); - if (message == null) { - return; - } - - player.sendMessage(message); - }); - } - - public static void message(Region region, Consumer function) { - Bukkit.getOnlinePlayers() - .stream() - .filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) - .filter(player -> !region.isGlobal() || Region.getRegion(player.getLocation()).isGlobal()) - .forEach(player -> { - function.accept(player); - }); - } - - static void save(Region region) { - if (region.getPrototype() != null) { - region.regionData.add("prototype", region.getPrototype().getName()); - } - region.regionData.add("flagStorage", FlagStorage.toYAPION(region.getFlagStorage())); - WorldData.write(); - } - } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ChangedMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ChangedMode.java similarity index 97% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ChangedMode.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ChangedMode.java index 85e70f01..ee7e7399 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ChangedMode.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ChangedMode.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.regionnew.flags; +package de.steamwar.bausystem.region.flags; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ColorMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ColorMode.java similarity index 96% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ColorMode.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ColorMode.java index 229301c3..e266d874 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ColorMode.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ColorMode.java @@ -17,9 +17,9 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.regionnew.flags; +package de.steamwar.bausystem.region.flags; -import de.steamwar.bausystem.regionnew.Color; +import de.steamwar.bausystem.region.Color; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/FireMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/FireMode.java similarity index 96% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/FireMode.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/FireMode.java index f628bd47..48deb0b7 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/FireMode.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/FireMode.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.regionnew.flags; +package de.steamwar.bausystem.region.flags; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java index 3c9f3173..7cfa0347 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java @@ -1,85 +1,103 @@ /* - * This file is a part of the SteamWar software. + * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2025 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 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. + * 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 . + * 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.flags.flagvalues.*; import de.steamwar.bausystem.shared.EnumDisplay; import lombok.AllArgsConstructor; import lombok.Getter; -import java.util.EnumSet; +import java.util.HashSet; import java.util.Set; -import java.util.stream.Collectors; +import java.util.concurrent.atomic.AtomicInteger; -@Getter -@AllArgsConstructor -public enum Flag implements EnumDisplay { +public final class Flag & Flag.Value> implements EnumDisplay { - COLOR("FLAG_COLOR", ColorMode.class, ColorMode.YELLOW, false), - TNT("FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB, true), - FIRE("FLAG_FIRE", FireMode.class, FireMode.ALLOW, true), - FREEZE("FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE, true), - PROTECT("FLAG_PROTECT", ProtectMode.class, ProtectMode.ACTIVE, true), - ITEMS("FLAG_ITEMS", ItemMode.class, ItemMode.INACTIVE, true), - NO_GRAVITY("FLAG_NO_GRAVITY", NoGravityMode.class, NoGravityMode.INACTIVE, true), - ; + public static final Flag COLOR = new Flag<>("COLOR", "FLAG_COLOR", ColorMode.class, ColorMode.YELLOW); + public static final Flag TNT = new Flag<>("TNT", "FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB); + public static final Flag FIRE = new Flag<>("FIRE", "FLAG_FIRE", FireMode.class, FireMode.ALLOW); + public static final Flag FREEZE = new Flag<>("FREEZE", "FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE); + public static final Flag PROTECT = new Flag<>("PROTECT", "FLAG_PROTECT", ProtectMode.class, ProtectMode.ACTIVE); + public static final Flag ITEMS = new Flag<>("ITEMS", "FLAG_ITEMS", ItemMode.class, ItemMode.INACTIVE); + public static final Flag NO_GRAVITY = new Flag<>("NO_GRAVITY", "FLAG_NO_GRAVITY", NoGravityMode.class, NoGravityMode.INACTIVE); + public static final Flag TESTBLOCK = new Flag<>("TESTBLOCK", "FLAG_TESTBLOCK", TestblockMode.class, TestblockMode.NO_VALUE); + public static final Flag CHANGED = new Flag<>("CHANGED", "FLAG_CHANGED", ChangedMode.class, ChangedMode.NO_CHANGE); - @Getter - private static final Set flags; - @Getter - private static final Set resetFlags; + @Getter + private static final Set flags = new HashSet<>(); - static { - flags = EnumSet.allOf(Flag.class); - resetFlags = flags.stream().filter(flag -> flag.reset).collect(Collectors.toUnmodifiableSet()); - } + private static AtomicInteger counter = new AtomicInteger(0); - private final String chatValue; - private final Class> valueType; - private final Flag.Value defaultValue; - private final boolean reset; + private String name; + private int ordinal; - public Value getFlagValueOf(final String name) { - return this.defaultValue.getValueOf(name); - } + @Getter + private String chatValue; - @Override - public String toString() { - return this.name().toLowerCase(); - } + @Getter + private final Class> valueType; - @Override - public String getChatValue() { - return chatValue; - } + @Getter + private final Flag.Value defaultValue; - public interface Value & Value> extends EnumDisplay { + @Getter + private final Flag.Value[] values; - T getValue(); + private Flag(String name, String chatValue, Class> valueType, Value defaultValue) { + flags.add(this); - T getValueOf(final String name); + this.name = name; + this.ordinal = counter.getAndIncrement(); + this.chatValue = chatValue; - T[] getValues(); + this.valueType = valueType; + this.defaultValue = defaultValue; + this.values = defaultValue.getValues(); + } - default String getName() { - return this.getValue().name().toLowerCase(); - } - } -} \ No newline at end of file + public String name() { + return name; + } + + public int ordinal() { + return ordinal; + } + + public boolean oneOf(Flag... flags) { + for (Flag flag : flags) { + if (flag == this) { + return true; + } + } + return false; + } + + public interface Value & Value> extends EnumDisplay { + + T getValue(); + + T getValueOf(final String name); + + T[] getValues(); + + default String getName() { + return this.getValue().name().toLowerCase(); + } + } +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/FreezeMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/FreezeMode.java similarity index 97% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/FreezeMode.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/FreezeMode.java index f3da631c..4f80ca57 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/FreezeMode.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/FreezeMode.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.regionnew.flags; +package de.steamwar.bausystem.region.flags; import lombok.AllArgsConstructor; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ItemMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ItemMode.java similarity index 97% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ItemMode.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ItemMode.java index 7d29899c..a846a53c 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ItemMode.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ItemMode.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.regionnew.flags; +package de.steamwar.bausystem.region.flags; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/NoGravityMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/NoGravityMode.java similarity index 97% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/NoGravityMode.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/NoGravityMode.java index 68e9fa6b..921d36ea 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/NoGravityMode.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/NoGravityMode.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.regionnew.flags; +package de.steamwar.bausystem.region.flags; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ProtectMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ProtectMode.java similarity index 97% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ProtectMode.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ProtectMode.java index 2f510daa..be4f6132 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/ProtectMode.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ProtectMode.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.regionnew.flags; +package de.steamwar.bausystem.region.flags; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/TNTMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/TNTMode.java similarity index 96% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/TNTMode.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/TNTMode.java index e483a81b..0f73f81b 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/TNTMode.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/TNTMode.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.regionnew.flags; +package de.steamwar.bausystem.region.flags; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/TestblockMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/TestblockMode.java similarity index 97% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/TestblockMode.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/TestblockMode.java index e7ff3e7b..ba1b8f61 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/TestblockMode.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/TestblockMode.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.regionnew.flags; +package de.steamwar.bausystem.region.flags; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ColorMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ColorMode.java deleted file mode 100644 index 6159c959..00000000 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ColorMode.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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.flagvalues; - -import de.steamwar.bausystem.regionnew.Color; -import de.steamwar.bausystem.region.flags.Flag; -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public enum ColorMode implements Flag.Value { - WHITE("FLAG_COLOR_WHITE", Color.WHITE), - ORANGE("FLAG_COLOR_ORANGE", Color.ORANGE), - MAGENTA("FLAG_COLOR_MAGENTA", Color.MAGENTA), - LIGHT_BLUE("FLAG_COLOR_LIGHT_BLUE", Color.LIGHT_BLUE), - YELLOW("FLAG_COLOR_YELLOW", Color.YELLOW), - LIME("FLAG_COLOR_LIME", Color.LIME), - PINK("FLAG_COLOR_PINK", Color.PINK), - GRAY("FLAG_COLOR_GRAY", Color.GRAY), - LIGHT_GRAY("FLAG_COLOR_LIGHT_GRAY", Color.LIGHT_GRAY), - CYAN("FLAG_COLOR_CYAN", Color.CYAN), - PURPLE("FLAG_COLOR_PURPLE", Color.PURPLE), - BLUE("FLAG_COLOR_BLUE", Color.BLUE), - BROWN("FLAG_COLOR_BROWN", Color.BROWN), - GREEN("FLAG_COLOR_GREEN", Color.GREEN), - RED("FLAG_COLOR_RED", Color.RED), - BLACK("FLAG_COLOR_BLACK", Color.BLACK); - - private static ColorMode[] values; - private final String chatValue; - private final Color color; - - @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/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/FireMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/FireMode.java deleted file mode 100644 index cf0fab31..00000000 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/FireMode.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.flagvalues; - -import de.steamwar.bausystem.region.flags.Flag; -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public enum FireMode implements Flag.Value { - - ALLOW("FLAG_FIRE_ALLOW"), - DENY("FLAG_FIRE_DENY"); - - private static FireMode[] values; - private final String chatValue; - - @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/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/FreezeMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/FreezeMode.java deleted file mode 100644 index 1b1774c7..00000000 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/FreezeMode.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.flagvalues; - - -import de.steamwar.bausystem.region.flags.Flag; -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public enum FreezeMode implements Flag.Value { - - ACTIVE("FLAG_FREEZE_ACTIVE"), - INACTIVE("FLAG_FREEZE_INACTIVE"); - - private static FreezeMode[] values; - private final String chatValue; - - @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/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ItemMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ItemMode.java deleted file mode 100644 index c0cefa38..00000000 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ItemMode.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.flagvalues; - -import de.steamwar.bausystem.region.flags.Flag; -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public enum ItemMode implements Flag.Value { - - ACTIVE("FLAG_ITEMS_ACTIVE"), - INACTIVE("FLAG_ITEMS_INACTIVE"); - - private static ItemMode[] values; - private final String chatValue; - - @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/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/NoGravityMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/NoGravityMode.java deleted file mode 100644 index 33368a35..00000000 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/NoGravityMode.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.flagvalues; - -import de.steamwar.bausystem.region.flags.Flag; -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public enum NoGravityMode implements Flag.Value { - - ACTIVE("FLAG_NO_GRAVITY_ACTIVE"), - INACTIVE("FLAG_NO_GRAVITY_INACTIVE"); - - private static NoGravityMode[] values; - private final String chatValue; - - @Override - public NoGravityMode[] getValues() { - if (NoGravityMode.values == null) { - NoGravityMode.values = NoGravityMode.values(); //NOSONAR - } - return NoGravityMode.values; - } - - @Override - public NoGravityMode getValue() { - return this; - } - - @Override - public NoGravityMode getValueOf(final String name) { - try { - return NoGravityMode.valueOf(name.toUpperCase()); - } catch (IllegalArgumentException e) { - if (name.equalsIgnoreCase("false")) { - return NoGravityMode.INACTIVE; - } - return NoGravityMode.ACTIVE; - } - } -} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ProtectMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ProtectMode.java deleted file mode 100644 index 18ea897b..00000000 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ProtectMode.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.flagvalues; - -import de.steamwar.bausystem.region.flags.Flag; -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public enum ProtectMode implements Flag.Value { - - ACTIVE("FLAG_PROTECT_ACTIVE"), - INACTIVE("FLAG_PROTECT_INACTIVE"); - - private static ProtectMode[] values; - private final String chatValue; - - @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/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/TNTMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/TNTMode.java deleted file mode 100644 index 9b05d6b5..00000000 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/TNTMode.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.flagvalues; - -import de.steamwar.bausystem.region.flags.Flag; -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public enum TNTMode implements Flag.Value { - - ALLOW("FLAG_TNT_ALLOW"), - DENY("FLAG_TNT_DENY"), - ONLY_TB("FLAG_TNT_ONLY_TB"), - ONLY_BUILD("FLAG_TNT_ONLY_BUILD"); - - private static TNTMode[] values; - private final String chatValue; - - @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/BauSystem_Main/src/de/steamwar/bausystem/region/tags/Tag.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/tags/Tag.java deleted file mode 100644 index e37751d9..00000000 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/tags/Tag.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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.tags; - -public enum Tag { - CHANGED, -} 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 deleted file mode 100644 index 446e0d97..00000000 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionExtensionType.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2020 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.utils; - -public enum RegionExtensionType { - NORMAL, - EXTENSION -} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionSelectionType.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionSelectionType.java index aeac38eb..00d54bb2 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionSelectionType.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionSelectionType.java @@ -2,5 +2,6 @@ package de.steamwar.bausystem.region.utils; public enum RegionSelectionType { LOCAL, - GLOBAL + GLOBAL, + ; } 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 deleted file mode 100644 index a618c644..00000000 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionType.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2020 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.utils; - -import de.steamwar.bausystem.shared.EnumDisplay; -import lombok.AllArgsConstructor; -import lombok.Getter; - -@AllArgsConstructor -public enum RegionType implements EnumDisplay { - NORMAL("REGION_TYPE_NORMAL"), - BUILD("REGION_TYPE_BUILD"), - TESTBLOCK("REGION_TYPE_ONLY_TB"); - - @Getter - private String chatValue; -} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/FlagStorage.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/FlagStorage.java deleted file mode 100644 index 57a9523c..00000000 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/FlagStorage.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.regionnew; - -import de.steamwar.bausystem.regionnew.flags.Flag; - -public interface FlagStorage { - - & Flag.Value> boolean set(Flag flag, Flag.Value value); - - & Flag.Value> Flag.Value get(Flag flag); -} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Region.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Region.java deleted file mode 100644 index 1bdab641..00000000 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/Region.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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.regionnew; - -import com.sk89q.worldedit.EditSession; -import de.steamwar.bausystem.regionnew.flags.Flag; -import de.steamwar.sql.SchematicNode; -import lombok.NonNull; -import org.bukkit.Location; - -import javax.annotation.Nullable; -import java.io.File; -import java.util.Optional; - -public interface Region { - - static Region getRegion(Location location) { - return RegionSystem.REGION_SYSTEM.get(location); - } - - RegionType getType(); - - & Flag.Value> RegionFlagPolicy hasFlag(@NonNull Flag flag); - - & Flag.Value> boolean setFlag(@NonNull Flag flag, Flag.Value value); - - & Flag.Value> Optional> getFlag(@NonNull Flag flag); - - Point getMinPoint(); - - Point getMaxPoint(); - - boolean inRegion(Location location); - - Optional getBuildMinPoint(boolean extension); - - Optional getBuildMaxPoint(boolean extension); - - boolean inBuildRegion(Location location, boolean extension); - - Optional getTestblockMinPoint(boolean extension); - - Optional getTestblockMaxPoint(boolean extension); - - boolean inTestblockRegion(Location location, boolean extension); - - // TODO: Add forEachChunk and getChunkOutsidePredicate - - Optional getGameModeConfig(); - - Optional copy(); - - Optional copyBuild(); - - Optional copyTestblock(); - - void reset(); - - void resetBuild(@Nullable SchematicNode schematicNode, boolean extension); - - void resetTestblock(@Nullable SchematicNode schematicNode, boolean extension); - - void remember(EditSession editSession); - - boolean undo(); - - boolean redo(); -} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionSide.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionSide.java deleted file mode 100644 index 6834e300..00000000 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/RegionSide.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.regionnew; - -public enum RegionSide { - NORTH, - SOUTH -} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/Flag.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/Flag.java deleted file mode 100644 index d915c216..00000000 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionnew/flags/Flag.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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.regionnew.flags; - -import de.steamwar.bausystem.shared.EnumDisplay; -import lombok.Getter; - -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.atomic.AtomicInteger; - -public class Flag & Flag.Value> implements EnumDisplay { - - public static final Flag COLOR = new Flag<>("COLOR", "FLAG_COLOR", ColorMode.class, ColorMode.YELLOW); - public static final Flag TNT = new Flag<>("TNT", "FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB); - public static final Flag FIRE = new Flag<>("FIRE", "FLAG_FIRE", FireMode.class, FireMode.ALLOW); - public static final Flag FREEZE = new Flag<>("FREEZE", "FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE); - public static final Flag PROTECT = new Flag<>("PROTECT", "FLAG_PROTECT", ProtectMode.class, ProtectMode.ACTIVE); - public static final Flag ITEMS = new Flag<>("ITEMS", "FLAG_ITEMS", ItemMode.class, ItemMode.INACTIVE); - public static final Flag NO_GRAVITY = new Flag<>("NO_GRAVITY", "FLAG_NO_GRAVITY", NoGravityMode.class, NoGravityMode.INACTIVE); - public static final Flag TESTBLOCK = new Flag<>("TESTBLOCK", "FLAG_TESTBLOCK", TestblockMode.class, TestblockMode.NO_VALUE); - public static final Flag CHANGED = new Flag<>("CHANGED", "FLAG_CHANGED", ChangedMode.class, ChangedMode.NO_CHANGE); - - @Getter - private static final Set flags = new HashSet<>(); - - private static AtomicInteger counter = new AtomicInteger(0); - - private String name; - private int ordinal; - - @Getter - private String chatValue; - - @Getter - private final Class> valueType; - - @Getter - private final Flag.Value defaultValue; - - @Getter - private final Flag.Value[] values; - - private Flag(String name, String chatValue, Class> valueType, Value defaultValue) { - flags.add(this); - - this.name = name; - this.ordinal = counter.getAndIncrement(); - this.chatValue = chatValue; - - this.valueType = valueType; - this.defaultValue = defaultValue; - this.values = defaultValue.getValues(); - } - - public String name() { - return name; - } - - public int ordinal() { - return ordinal; - } - - public boolean oneOff(Flag... flags) { - for (Flag flag : flags) { - if (flag == this) { - return true; - } - } - return false; - } - - public interface Value & Flag.Value> extends EnumDisplay { - - T getValue(); - - T getValueOf(final String name); - - T[] getValues(); - - default String getName() { - return this.getValue().name().toLowerCase(); - } - } -} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Prototype.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionold/Prototype.java.txt similarity index 100% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Prototype.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionold/Prototype.java.txt diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionold/Region.java.txt b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionold/Region.java.txt new file mode 100644 index 00000000..c6f8b5c7 --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionold/Region.java.txt @@ -0,0 +1,584 @@ +/* + * 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.EditSession; +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.bukkit.BukkitWorld; +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.region.flags.Flag; +import de.steamwar.bausystem.region.flags.flagvalues.TNTMode; +import de.steamwar.bausystem.region.tags.Tag; +import de.steamwar.bausystem.region.utils.RegionExtensionType; +import de.steamwar.bausystem.region.utils.RegionType; +import de.steamwar.bausystem.shared.SizedStack; +import de.steamwar.bausystem.utils.FlatteningWrapper; +import de.steamwar.bausystem.utils.PasteBuilder; +import de.steamwar.core.Core; +import de.steamwar.sql.SchematicType; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NonNull; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import yapion.hierarchy.types.YAPIONObject; +import yapion.hierarchy.types.YAPIONType; +import yapion.hierarchy.types.YAPIONValue; + +import java.io.File; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.function.ObjIntConsumer; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +@Getter +public class Region { + + @Getter + private static final Map REGION_MAP = new HashMap<>(); + private static final File backupFolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "backup"); + private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd' 'HH:mm:ss"); + + public static Region getRegion(Location location) { + return REGION_MAP.values().stream() + .filter(r -> r.inRegion(location, r.minPoint, r.maxPoint)) + .findFirst() + .orElse(GlobalRegion.instance); + } + + public static Set getRegion(Prototype prototype) { + return REGION_MAP.values().stream() + .filter(r -> r.getPrototype() == prototype) + .collect(Collectors.toSet()); + } + + public static void setGlobal(Flag flagType, Flag.Value value) { + REGION_MAP.values().forEach(region -> region.set(flagType, value)); + } + + YAPIONObject regionData; + + private String name; + private Prototype prototype; + private Set prototypes; + private String skin; + + private Point minPoint; + private Point maxPoint; + + private Point minPointTestblock; + private Point maxPointTestblock; + + private Point minPointTestblockExtension; + private Point maxPointTestblockExtension; + + private Point minPointBuild; + private Point maxPointBuild; + + private Point minPointBuildExtension; + private Point maxPointBuildExtension; + + private int floorLevel; + private int waterLevel; + + private Point copyPoint; // Nullable + private Point testBlockPoint; // Nullable + + private String linkedRegionName = null; // Nullable + private Region linkedRegion = null; // Nullable + + private FlagStorage flagStorage; + + @Getter(AccessLevel.PRIVATE) + private SizedStack undoSessions; + + @Getter(AccessLevel.PRIVATE) + private SizedStack redoSessions; + + public Region(String name, Prototype prototype, YAPIONObject regionConfig, FlagStorage flagStorage, YAPIONObject regionData) { + this.name = name; + this.regionData = regionData; + if (prototype != null) { + REGION_MAP.put(name, this); + } + + linkedRegionName = regionConfig.getPlainValueOrDefault("optionsLinkedWith", null); + + prototypes = new HashSet<>(); + if (regionConfig.containsKey("prototypes", YAPIONType.ARRAY)) { + regionConfig.getArray("prototypes").forEach(yapionAnyType -> { + if (yapionAnyType instanceof YAPIONValue) { + prototypes.add(((YAPIONValue) yapionAnyType).get()); + } + }); + } + if (regionConfig.containsKey("prototype")) { + prototypes.add(regionConfig.getPlainValue("prototype")); + } + + this.flagStorage = flagStorage; + Point point = null; + if (regionConfig.containsKey("minX", Integer.class) && regionConfig.containsKey("minY", Integer.class) && regionConfig.containsKey("minZ", Integer.class)) { + point = new Point(regionConfig.getPlainValue("minX"), regionConfig.getPlainValue("minY"), regionConfig.getPlainValue("minZ")); + } + if (prototype != null && prototypes.contains(prototype.getName())) { + generatePrototypeData(prototype, point); + } else if (regionConfig.containsKey("prototype")) { + generatePrototypeData(Prototype.getByName(regionConfig.getPlainValue("prototype")), point); + } + if (prototype != null) { + skin = regionData.getPlainValueOrDefault("skin", prototype.getDefaultSkin()); + if (!prototype.getSkinMap().containsKey(skin)) { + skin = prototype.getDefaultSkin(); + } + } + regionData.add("skin", skin); + + if (!hasType(RegionType.BUILD) || !hasType(RegionType.TESTBLOCK)) { + flagStorage.set(Flag.TNT, TNTMode.DENY); + } + } + + private void generatePrototypeData(Prototype prototype, Point point) { + if (prototype == null) { + return; + } + + this.prototype = prototype; + this.skin = prototype.getDefaultSkin(); + + this.minPoint = point; + this.maxPoint = point.add(prototype.getSizeX() - 1, prototype.getSizeY() - 1, prototype.getSizeZ() - 1); + + if (prototype.getTestblock() != null) { + this.minPointTestblock = point.add(prototype.getTestblock().getOffsetX(), prototype.getTestblock().getOffsetY(), prototype.getTestblock().getOffsetZ()); + this.maxPointTestblock = this.minPointTestblock.add(prototype.getTestblock().getSizeX() - 1, prototype.getTestblock().getSizeY() - 1, prototype.getTestblock().getSizeZ() - 1); + + this.minPointTestblockExtension = this.minPointTestblock.subtract(prototype.getTestblock().getExtensionNegativeX(), prototype.getTestblock().getExtensionNegativeY(), prototype.getTestblock().getExtensionNegativeZ()); + this.maxPointTestblockExtension = this.maxPointTestblock.add(prototype.getTestblock().getExtensionPositiveX(), prototype.getTestblock().getExtensionPositiveY(), prototype.getTestblock().getExtensionPositiveZ()); + + if (prototype.getTestblock().getCopyOffsetX() != 0 || prototype.getTestblock().getCopyOffsetY() != 0 || prototype.getTestblock().getCopyOffsetZ() != 0) { + this.testBlockPoint = this.minPointTestblock.add(prototype.getTestblock().getCopyOffsetX(), prototype.getTestblock().getCopyOffsetY(), prototype.getTestblock().getCopyOffsetZ()); + } else { + this.testBlockPoint = this.minPointTestblock.add(prototype.getTestblock().getSizeX() / 2, 0, -1); + } + } + + if (prototype.getBuild() != null) { + this.minPointBuild = point.add(prototype.getBuild().getOffsetX(), prototype.getBuild().getOffsetY(), prototype.getBuild().getOffsetZ()); + this.maxPointBuild = this.minPointBuild.add(prototype.getBuild().getSizeX() - 1, prototype.getBuild().getSizeY() - 1, prototype.getBuild().getSizeZ() - 1); + + this.minPointBuildExtension = this.minPointBuild.subtract(prototype.getBuild().getExtensionNegativeX(), prototype.getBuild().getExtensionNegativeY(), prototype.getBuild().getExtensionNegativeZ()); + this.maxPointBuildExtension = this.maxPointBuild.add(prototype.getBuild().getExtensionPositiveX(), prototype.getBuild().getExtensionPositiveY(), prototype.getBuild().getExtensionPositiveZ()); + + if (!prototype.getBuild().isHasCopyPoint() && (prototype.getCopyPointOffsetX() != 0 || prototype.getCopyPointOffsetY() != 0 || prototype.getCopyPointOffsetZ() != 0)) { + this.copyPoint = minPoint.add(prototype.getCopyPointOffsetX(), prototype.getCopyPointOffsetY(), prototype.getCopyPointOffsetZ()); + } else if (prototype.getBuild().getCopyOffsetX() != 0 || prototype.getBuild().getCopyOffsetY() != 0 || prototype.getBuild().getCopyOffsetZ() != 0) { + this.copyPoint = this.minPointBuild.add(prototype.getBuild().getCopyOffsetX(), prototype.getBuild().getCopyOffsetY(), prototype.getBuild().getCopyOffsetZ()); + } else { + this.copyPoint = this.minPointBuild.add(prototype.getBuild().getSizeX() / 2, 0, prototype.getBuild().getSizeZ()); + } + } else if (prototype.getCopyPointOffsetX() != 0 || prototype.getCopyPointOffsetY() != 0 || prototype.getCopyPointOffsetZ() != 0) { + this.copyPoint = minPoint.add(prototype.getCopyPointOffsetX(), prototype.getCopyPointOffsetY(), prototype.getCopyPointOffsetZ()); + } + + if (prototype.getFloorOffset() != 0) { + floorLevel = minPoint.getY() + prototype.getFloorOffset(); + } else { + floorLevel = 0; + } + + if (prototype.getWaterOffset() != 0) { + waterLevel = minPoint.getY() + prototype.getWaterOffset(); + } else { + waterLevel = 0; + } + } + + public boolean inRegion(Location location, RegionType regionType, RegionExtensionType regionExtensionType) { + if (!hasType(regionType)) { + return false; + } + switch (regionType) { + case BUILD: + Point minBPoint = regionExtensionType == RegionExtensionType.EXTENSION ? minPointBuildExtension : minPointBuild; + Point maxBPoint = regionExtensionType == RegionExtensionType.EXTENSION ? maxPointBuildExtension : maxPointBuild; + return inRegion(location, minBPoint, maxBPoint); + case TESTBLOCK: + Point minTBPoint = regionExtensionType == RegionExtensionType.EXTENSION ? minPointTestblockExtension : minPointTestblock; + Point maxTBPoint = regionExtensionType == RegionExtensionType.EXTENSION ? maxPointTestblockExtension : maxPointTestblock; + return inRegion(location, minTBPoint, maxTBPoint); + default: + case NORMAL: + return inRegion(location, minPoint, maxPoint); + } + } + + private boolean inRegion(Location location, Point minPoint, Point maxPoint) { + int blockX = location.getBlockX(); + int blockY = location.getBlockY(); + int blockZ = location.getBlockZ(); + return blockX >= minPoint.getX() && blockX <= maxPoint.getX() && + blockY >= minPoint.getY() && blockY <= maxPoint.getY() && + blockZ >= minPoint.getZ() && blockZ <= maxPoint.getZ(); + } + + public boolean hasType(RegionType regionType) { + if (prototype == null) { + return false; + } + if (regionType == null) { + return false; + } + switch (regionType) { + case BUILD: + return prototype.getBuild() != null; + case TESTBLOCK: + return prototype.getTestblock() != null; + default: + case NORMAL: + return true; + } + } + + public boolean hasExtensionType(RegionType regionType) { + if (!hasType(regionType)) { + return false; + } + switch (regionType) { + case BUILD: + return prototype.getBuild().isExtensionRegistered(); + case TESTBLOCK: + return prototype.getTestblock().isExtensionRegistered(); + default: + case NORMAL: + return false; + } + } + + public String getDisplayName() { + return prototype != null ? prototype.getSkinMap().get(skin).getName() : ""; + } + + private void setLinkedRegion(Predicate regionConsumer) { + if (linkedRegionName == null) { + return; + } + if (linkedRegion != null) { + if (regionConsumer.test(linkedRegion)) { + RegionUtils.save(linkedRegion); + } + return; + } + for (Region region : REGION_MAP.values()) { + if (region.name.equals(linkedRegionName)) { + linkedRegion = region; + if (regionConsumer.test(linkedRegion)) { + RegionUtils.save(linkedRegion); + } + return; + } + } + } + + public Region getLinkedRegion() { + if (linkedRegion == null && linkedRegionName != null) { + setLinkedRegion(region -> false); + } + return linkedRegion; + } + + public boolean setPrototype(@NonNull Prototype prototype) { + if (!prototypes.contains(prototype.getName())) { + return false; + } + return _setPrototype(prototype); + } + + boolean _setPrototype(@NonNull Prototype prototype) { + generatePrototypeData(prototype, minPoint); + RegionUtils.save(this); + return true; + } + + public boolean setSkin(@NonNull String skinName) { + if (!prototype.getSkinMap().containsKey(skinName)) { + return false; + } + this.skin = skinName; + setLinkedRegion(region -> { + region.skin = skinName; + return true; + }); + regionData.add("skin", skin); + return true; + } + + public void set(Flag flagType, Flag.Value value) { + if (flagStorage.set(flagType, value)) { + RegionUtils.save(this); + } + setLinkedRegion(region -> region.flagStorage.set(flagType, value)); + } + + public void set(Tag tag) { + if (flagStorage.set(tag)) { + RegionUtils.save(this); + } + setLinkedRegion(region -> region.flagStorage.set(tag)); + } + + public void remove(Tag tag) { + if (flagStorage.remove(tag)) { + RegionUtils.save(this); + } + } + + public Flag.Value get(Flag flagType) { + return flagStorage.get(flagType); + } + + public boolean get(Tag tagType) { + return flagStorage.is(tagType); + } + + public & Flag.Value> T getPlain(Flag flagType) { + return (T) flagStorage.get(flagType).getValue(); + } + + public & Flag.Value> T getPlain(Flag flagType, Class type) { + return (T) flagStorage.get(flagType).getValue(); + } + + public Point getMinPoint(RegionType regionType, RegionExtensionType regionExtensionType) { + switch (regionType) { + case TESTBLOCK: + return (regionExtensionType == null || regionExtensionType == RegionExtensionType.NORMAL) ? minPointTestblock : minPointTestblockExtension; + case BUILD: + return (regionExtensionType == null || regionExtensionType == RegionExtensionType.NORMAL) ? minPointBuild : minPointBuildExtension; + default: + case NORMAL: + return minPoint; + } + } + + public Point getMaxPoint(RegionType regionType, RegionExtensionType regionExtensionType) { + switch (regionType) { + case TESTBLOCK: + return (regionExtensionType == null || regionExtensionType == RegionExtensionType.NORMAL) ? maxPointTestblock : maxPointTestblockExtension; + case BUILD: + return (regionExtensionType == null || regionExtensionType == RegionExtensionType.NORMAL) ? maxPointBuild : maxPointBuildExtension; + default: + case NORMAL: + return maxPoint; + } + } + + boolean hasReset(RegionType regionType) { + if (!hasType(regionType)) { + return false; + } + switch (regionType) { + case TESTBLOCK: + return prototype.getSkinMap().get(skin).getTestblockSchematicFile() != null; + case BUILD: + return prototype.getSkinMap().get(skin).getBuildSchematicFile() != null; + default: + case NORMAL: + return prototype.getSkinMap().get(skin).getSchematicFile() != null; + } + } + + public File getResetFile(RegionType regionType) { + if (!hasReset(regionType)) { + return null; + } + switch (regionType) { + case TESTBLOCK: + return prototype.getSkinMap().get(skin).getTestblockSchematicFile(); + case BUILD: + return prototype.getSkinMap().get(skin).getBuildSchematicFile(); + default: + case NORMAL: + return prototype.getSkinMap().get(skin).getSchematicFile(); + } + } + + public void reset(PasteBuilder pasteBuilder, RegionType regionType, RegionExtensionType regionExtensionType) { + if (!hasReset(regionType)) { + return; + } + if (regionExtensionType == RegionExtensionType.EXTENSION && !hasExtensionType(regionType)) { + regionExtensionType = RegionExtensionType.NORMAL; + } + + pasteBuilder.reset(regionExtensionType == RegionExtensionType.EXTENSION) + .minPoint(getMinPoint(regionType, regionExtensionType)) + .maxPoint(getMaxPoint(regionType, regionExtensionType)) + .waterLevel(waterLevel); + if (pasteBuilder.getClipboardProvider().is(PasteBuilder.SchematicProvider.class)) { + SchematicType schematicType = pasteBuilder.getClipboardProvider().as(PasteBuilder.SchematicProvider.class).getSchematic().getSchemtype(); + pasteBuilder.rotate(schematicType.fightType() || schematicType.check()); + } + + switch (regionType) { + case BUILD: + pasteBuilder.pastePoint(minPointBuild.add(prototype.getBuild().getSizeX() / 2, 0, prototype.getBuild().getSizeZ() / 2)); + break; + case TESTBLOCK: + Point pastePoint = minPointTestblock.add(prototype.getTestblock().getSizeX() / 2, 0, prototype.getTestblock().getSizeZ() / 2); + if (pasteBuilder.getClipboardProvider().is(PasteBuilder.SchematicProvider.class)) { + SchematicType schematicType = pasteBuilder.getClipboardProvider().as(PasteBuilder.SchematicProvider.class).getSchematic().getSchemtype(); + if (schematicType.getKuerzel().equalsIgnoreCase("wg")) { + pastePoint = pastePoint.add(0, 0, 1); + } + if (schematicType.getKuerzel().equalsIgnoreCase("ws")) { + pastePoint = pastePoint.add(-1, 0, 1); + } + if (schematicType.getKuerzel().equalsIgnoreCase("as")) { + pastePoint = pastePoint.add(-1, 0, 1); + } + } + pasteBuilder.pastePoint(pastePoint); + break; + default: + case NORMAL: + pasteBuilder.pastePoint(minPoint.add(prototype.getSizeX() / 2, 0, prototype.getSizeZ() / 2)); + break; + } + + initSessions(); + undoSessions.push(pasteBuilder.run()); + } + + public void remember(EditSession editSession) { + initSessions(); + undoSessions.push(editSession); + } + + public boolean isGlobal() { + return this == GlobalRegion.getInstance(); + } + + private void initSessions() { + if (undoSessions == null) { + undoSessions = new SizedStack<>(20); + redoSessions = new SizedStack<>(20); + } + } + + public boolean undo() { + initSessions(); + EditSession session = undoSessions.pop(); + if (session == null) + return false; + + try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) { + session.undo(e); + redoSessions.push(e); + } + return true; + } + + public boolean redo() { + initSessions(); + EditSession session = redoSessions.pop(); + if (session == null) + return false; + + try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) { + session.redo(e); + undoSessions.push(e); + } + return true; + } + + public boolean backup() { + final File definedBackupFolder = new File(new File(backupFolder, prototype.getName()), name); + //noinspection ResultOfMethodCallIgnored + definedBackupFolder.mkdirs(); + + File[] currentBackups = definedBackupFolder.listFiles(); + if (currentBackups != null && currentBackups.length >= 20) { + List files = new ArrayList<>(Arrays.asList(currentBackups)); + files.sort(Comparator.comparingLong(File::lastModified)); + while (files.size() >= 20) files.remove(0).delete(); + } + + final File backupFile = new File(definedBackupFolder, LocalDateTime.now().format(formatter) + ".schem"); + return FlatteningWrapper.impl.backup(minPoint, maxPoint, backupFile); + } + + public static boolean copy(Point minPoint, Point maxPoint, File file) { + return FlatteningWrapper.impl.backup(minPoint, maxPoint, file); + } + + public List listBackup() { + final File definedBackupFolder = new File(new File(backupFolder, prototype.getName()), name); + //noinspection ResultOfMethodCallIgnored + definedBackupFolder.mkdirs(); + + File[] currentBackups = definedBackupFolder.listFiles(); + List files = new ArrayList<>(Arrays.asList(currentBackups)); + files.sort(Comparator.comparingLong(File::lastModified)); + return files.stream().map(File::getName).collect(Collectors.toList()); + } + + public File getBackupFile(String backupName) { + final File definedBackupFolder = new File(new File(backupFolder, prototype.getName()), name); + //noinspection ResultOfMethodCallIgnored + definedBackupFolder.mkdirs(); + File[] files = definedBackupFolder.listFiles((dir, name) -> name.equals(backupName + ".schem")); + if (files == null || files.length == 0) return null; + return files[0]; + } + + public void forEachChunk(ObjIntConsumer executor) { + for (int x = (int) Math.floor(minPoint.getX() / 16.0); x <= (int) Math.ceil(maxPoint.getX() / 16.0); x++) { + for (int z = (int) Math.floor(minPoint.getZ() / 16.0); z <= (int) Math.ceil(maxPoint.getZ() / 16.0); z++) { + executor.accept(x, z); + } + } + } + + public boolean buildChunkOutside(int chunkX, int chunkY) { + if (!hasType(RegionType.BUILD)) { + return Math.floor(minPoint.getX() / 16.0) > chunkX || chunkX >= Math.ceil(maxPoint.getX() / 16.0) || + Math.floor(minPoint.getZ() / 16.0) > chunkY || chunkY >= Math.ceil(maxPoint.getZ() / 16.0); + } + if (!hasExtensionType(RegionType.BUILD)) { + return Math.floor(minPointBuild.getX() / 16.0) > chunkX || chunkX >= Math.ceil(maxPointBuild.getX() / 16.0) || + Math.floor(minPointBuild.getZ() / 16.0) > chunkY || chunkY >= Math.ceil(maxPointBuild.getZ() / 16.0); + } + return Math.floor(minPointBuildExtension.getX() / 16.0) > chunkX || chunkX >= Math.ceil(maxPointBuildExtension.getX() / 16.0) || + Math.floor(minPointBuildExtension.getZ() / 16.0) > chunkY || chunkY >= Math.ceil(maxPointBuildExtension.getZ() / 16.0); + } + + public File gameModeConfig() { + File baseFile = new File(BauSystem.getInstance().getDataFolder().getParentFile(), "FightSystem"); + for (int version = Core.getVersion(); version >= 15; version--) { + File specific = new File(baseFile, prototype.getDisplayName() + version + ".yml"); + if (specific.exists()) return specific; + } + return null; + } +} \ No newline at end of file diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/loader/PrototypeLoader.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionold/loader/PrototypeLoader.java.txt similarity index 100% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/loader/PrototypeLoader.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionold/loader/PrototypeLoader.java.txt diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/loader/RegionLoader.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionold/loader/RegionLoader.java.txt similarity index 100% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/loader/RegionLoader.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionold/loader/RegionLoader.java.txt diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/loader/Updater.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionold/loader/Updater.java.txt similarity index 100% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/loader/Updater.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionold/loader/Updater.java.txt diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/FlatteningWrapper.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/FlatteningWrapper.java index 12b7a78a..3cd96295 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/FlatteningWrapper.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/FlatteningWrapper.java @@ -22,7 +22,7 @@ package de.steamwar.bausystem.utils; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.extent.clipboard.Clipboard; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.regionnew.Point; +import de.steamwar.bausystem.region.Point; import de.steamwar.core.VersionDependent; import org.bukkit.Material; import org.bukkit.World; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PasteBuilder.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PasteBuilder.java index 8c3813ac..a4a74e17 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PasteBuilder.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PasteBuilder.java @@ -26,8 +26,8 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; -import de.steamwar.bausystem.regionnew.Color; -import de.steamwar.bausystem.regionnew.Point; +import de.steamwar.bausystem.region.Color; +import de.steamwar.bausystem.region.Point; import de.steamwar.sql.SchematicData; import de.steamwar.sql.SchematicNode; import lombok.Getter; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/bossbar/GlobalBossbar.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/bossbar/GlobalBossbar.java index a5aaf9fe..47f57907 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/bossbar/GlobalBossbar.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/bossbar/GlobalBossbar.java @@ -19,8 +19,8 @@ package de.steamwar.bausystem.utils.bossbar; -import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.RegionSystem; import org.bukkit.boss.BarColor; import org.bukkit.boss.BarFlag; import org.bukkit.boss.BarStyle; @@ -101,7 +101,7 @@ public class GlobalBossbar implements BauSystemBossbar { @Override public Region getRegion() { - return GlobalRegion.getInstance(); + return RegionSystem.INSTANCE.getGlobalRegion(); } @Override diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedFlagStorage.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedFlagStorage.java similarity index 86% rename from BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedFlagStorage.java rename to BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedFlagStorage.java index 1af55086..af44866a 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedFlagStorage.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedFlagStorage.java @@ -17,9 +17,9 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.regionnew; +package de.steamwar.bausystem.region; -import de.steamwar.bausystem.regionnew.flags.Flag; +import de.steamwar.bausystem.region.flags.Flag; import java.io.File; import java.util.HashMap; @@ -44,12 +44,12 @@ public class FixedFlagStorage implements FlagStorage { } @Override - public & Flag.Value> boolean set(Flag flag, Flag.Value value) { + public & Flag.Value> boolean set(Flag flag, T value) { return flagMap.put(flag, value) != value; } @Override - public & Flag.Value> Flag.Value get(Flag flag) { - return (Flag.Value) flagMap.get(flag); + public & Flag.Value> T get(Flag flag) { + return (T) flagMap.get(flag); } } diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedGlobalRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalRegion.java similarity index 65% rename from BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedGlobalRegion.java rename to BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalRegion.java index 81b39197..b36ddecb 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedGlobalRegion.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalRegion.java @@ -17,15 +17,13 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.regionnew; +package de.steamwar.bausystem.region; import com.sk89q.worldedit.EditSession; -import de.steamwar.bausystem.regionnew.flags.Flag; -import de.steamwar.sql.SchematicNode; +import de.steamwar.bausystem.region.flags.Flag; import lombok.NonNull; import org.bukkit.Location; -import javax.annotation.Nullable; import java.io.File; import java.util.Optional; @@ -35,6 +33,7 @@ public final class FixedGlobalRegion implements Region { private static final Point MIN_POINT = new Point(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE); private static final Point MAX_POINT = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); + private final FlagStorage FLAG_STORAGE = FixedFlagStorage.createFromRegion(this); // TODO: Update to either File or Region creation! private FixedGlobalRegion() { @@ -47,21 +46,21 @@ public final class FixedGlobalRegion implements Region { @Override public & Flag.Value> RegionFlagPolicy hasFlag(@NonNull Flag flag) { - if (flag.oneOff(Flag.TNT, Flag.FIRE, Flag.FREEZE, Flag.ITEMS)) { + if (flag.oneOf(Flag.TNT, Flag.FIRE, Flag.FREEZE, Flag.ITEMS, Flag.NO_GRAVITY)) { return RegionFlagPolicy.WRITABLE; } return RegionFlagPolicy.NOT_APPLICABLE; } @Override - public & Flag.Value> boolean setFlag(@NonNull Flag flag, Flag.Value value) { + public & Flag.Value> boolean setFlag(@NonNull Flag flag, T value) { return hasFlag(flag).isWritable() && FLAG_STORAGE.set(flag, value); } @Override - public & Flag.Value> Optional> getFlag(@NonNull Flag flag) { + public & Flag.Value> Optional getFlag(@NonNull Flag flag) { if (hasFlag(flag).isReadable()) { - return Optional.of(FLAG_STORAGE.get(flag)); + return Optional.ofNullable(FLAG_STORAGE.get(flag)); } else { return Optional.empty(); } @@ -83,33 +82,13 @@ public final class FixedGlobalRegion implements Region { } @Override - public Optional getBuildMinPoint(boolean extension) { - return Optional.empty(); + public Inner getBuildArea() { + return Inner.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; + public Inner getTestblockArea() { + return Inner.EMPTY; } @Override @@ -123,13 +102,8 @@ public final class FixedGlobalRegion implements Region { } @Override - public Optional copyBuild() { - return Optional.empty(); - } - - @Override - public Optional copyTestblock() { - return Optional.empty(); + public boolean backup(boolean automatic) { + return false; } @Override @@ -137,16 +111,6 @@ public final class FixedGlobalRegion implements Region { } - @Override - public void resetBuild(@Nullable SchematicNode schematicNode, boolean extension) { - - } - - @Override - public void resetTestblock(@Nullable SchematicNode schematicNode, boolean extension) { - - } - @Override public void remember(EditSession editSession) { diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegion.java similarity index 61% rename from BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedRegion.java rename to BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegion.java index c89cdf61..0023060d 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedRegion.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegion.java @@ -17,15 +17,13 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.regionnew; +package de.steamwar.bausystem.region; import com.sk89q.worldedit.EditSession; -import de.steamwar.bausystem.regionnew.flags.Flag; -import de.steamwar.sql.SchematicNode; +import de.steamwar.bausystem.region.flags.Flag; import lombok.NonNull; import org.bukkit.Location; -import javax.annotation.Nullable; import java.io.File; import java.util.Optional; @@ -42,12 +40,12 @@ public class FixedRegion implements Region { // TODO: Implement! } @Override - public & Flag.Value> boolean setFlag(@NonNull Flag flag, Flag.Value value) { + public & Flag.Value> boolean setFlag(@NonNull Flag flag, T value) { return false; } @Override - public & Flag.Value> Optional> getFlag(@NonNull Flag flag) { + public & Flag.Value> Optional getFlag(@NonNull Flag flag) { return Optional.empty(); } @@ -67,33 +65,13 @@ public class FixedRegion implements Region { // TODO: Implement! } @Override - public Optional getBuildMinPoint(boolean extension) { - return Optional.empty(); + public Inner getBuildArea() { + return Inner.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; + public Inner getTestblockArea() { + return Inner.EMPTY; } @Override @@ -101,36 +79,21 @@ public class FixedRegion implements Region { // TODO: Implement! return Optional.empty(); } + @Override + public boolean backup(boolean automatic) { + return false; + } + @Override public Optional copy() { return Optional.empty(); } - @Override - public Optional copyBuild() { - return Optional.empty(); - } - - @Override - public Optional copyTestblock() { - return Optional.empty(); - } - @Override public void reset() { } - @Override - public void resetBuild(@Nullable SchematicNode schematicNode, boolean extension) { - - } - - @Override - public void resetTestblock(@Nullable SchematicNode schematicNode, boolean extension) { - - } - @Override public void remember(EditSession editSession) { diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedRegionSystem.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java similarity index 97% rename from BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedRegionSystem.java rename to BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java index f29b1ebc..dfdaf3f3 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionnew/FixedRegionSystem.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.regionnew; +package de.steamwar.bausystem.region; import org.bukkit.Location; From 9a506a34f83b59a393272666e29e721e686df632 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 22 Dec 2024 13:09:15 +0100 Subject: [PATCH 06/56] Fix things and optimize imports --- .../BauSystem_Main/src/BauSystem.properties | 1 + .../src/BauSystem_de.properties | 1 + .../src/de/steamwar/bausystem/Permission.java | 2 - .../AttributeRemoveCommand.java | 1 - .../features/autostart/AutostartListener.java | 8 +- .../features/bau/ForceSpectatorCommand.java | 2 - .../bausystem/features/cannon/CannonKey.java | 1 - .../killchecker/KillcheckerCommand.java | 5 +- .../killchecker/KillcheckerVisualizer.java | 6 +- .../features/loader/LoaderRecorder.java | 1 - .../features/loadtimer/Loadtimer.java | 4 +- .../observer/ObserverTracerCommand.java | 1 - .../features/region/FireCommand.java | 18 +-- .../features/region/FireListener.java | 10 +- .../features/region/FreezeCommand.java | 18 +-- .../features/region/FreezeListener.java | 148 +++--------------- .../features/region/ItemsCommand.java | 19 +-- .../features/region/ItemsListener.java | 12 +- .../features/region/NoGravityCommand.java | 16 +- .../features/region/NoGravityListener.java | 12 +- .../features/region/ProtectCommand.java | 22 +-- .../features/region/ProtectListener.java | 20 ++- .../features/region/RegionListener.java | 5 +- .../region/RegionScoreboardElement.java | 8 +- .../bausystem/features/region/TNTCommand.java | 2 - .../features/region/TNTListener.java | 23 +-- .../features/region/TestblockCommand.java | 4 - .../features/region/items/FireBauGuiItem.java | 7 +- .../region/items/FreezeBauGuiItem.java | 7 +- .../region/items/ProtectBauGuiItem.java | 7 +- .../bausystem/features/script/ScriptGUI.java | 1 - .../script/event/CommandListener.java | 1 - .../features/script/event/EventListener.java | 6 +- .../script/lua/SteamWarLuaPlugin.java | 7 - .../script/lua/libs/ScoreboardLib.java | 2 - .../features/script/lua/libs/ServerLib.java | 1 - .../impl/PistonConfiguration.java | 1 - .../simulator/data/SimulatorElement.java | 1 - .../simulator/data/SimulatorPhase.java | 2 - .../slaves/laufbau/LaufbauCommand.java | 2 - .../slaves/panzern/PanzernCommand.java | 2 - .../testblock/blockcounter/BlockCount.java | 1 - .../features/tracer/TraceManager.java | 2 - .../bausystem/features/util/BindCommand.java | 7 +- .../bausystem/features/util/ClearCommand.java | 2 - .../features/util/KillAllCommand.java | 2 +- .../features/util/PistonCalculator.java | 5 +- .../bausystem/features/util/TimeCommand.java | 5 +- .../bausystem/features/warp/WarpCommand.java | 2 - .../features/world/BauMemberUpdate.java | 3 +- .../features/world/KickallCommand.java | 1 - .../world/WorldEditSelectionSaver.java | 1 - .../de/steamwar/bausystem/region/Region.java | 6 +- .../steamwar/bausystem/region/flags/Flag.java | 4 +- .../bausystem/utils/PlaceItemUtils.java | 5 +- .../utils/bossbar/RegionedBossbar.java | 4 +- 56 files changed, 151 insertions(+), 316 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/BauSystem.properties b/BauSystem/BauSystem_Main/src/BauSystem.properties index 61c95dc7..20bb5f87 100644 --- a/BauSystem/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem/BauSystem_Main/src/BauSystem.properties @@ -403,6 +403,7 @@ KILLCHECKER_INFO=§7Shows the overlaps of cannon kills in your build area. KILLCHECKER_INFO2=§7Only colorable blocks like Wool, Terractotta, Stained Glass and Concrete are counted. KILLCHECKER_ENABLE=§aKillchecker activated KILLCHECKER_DISABLE=§cKillchecker deactivated +KILLCHECKER_NO_BUILD=§cThere is no Build Area in this Region KILLCHECKER_BOSSBAR=§e§l{0} §7(§e{1}%§7) §e§l{2}§7 cannons # BlockCounter BLOCK_COUNTER_HELP_TOGGLE=§8/§eblockcounter §8- §7Toggle on/off diff --git a/BauSystem/BauSystem_Main/src/BauSystem_de.properties b/BauSystem/BauSystem_Main/src/BauSystem_de.properties index 3acad9fe..8af9ba4b 100644 --- a/BauSystem/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem/BauSystem_Main/src/BauSystem_de.properties @@ -362,6 +362,7 @@ KILLCHECKER_INFO=§7Zeigt Überlappungen der Kanonen Kills im Baubereich an. KILLCHECKER_INFO2=§7Nur farbige Blöcke wie Wolle, Terracotta, Stained Glass und Concrete wird gezählt. KILLCHECKER_ENABLE=§aKillchecker aktiviert KILLCHECKER_DISABLE=§cKillchecker deaktiviert +KILLCHECKER_NO_BUILD=§cEs gibt keinen Baubereich in dieser Region KILLCHECKER_BOSSBAR=§e§l{0} §7(§e{1}%§7) §e§l{2}§7 Kanonnen # BlockCounter BLOCK_COUNTER_HELP_TOGGLE=§8/§eblockcounter §8- §7Wechsel zwischen an und aus diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/Permission.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/Permission.java index 0985a62d..a4cefb9a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/Permission.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/Permission.java @@ -21,11 +21,9 @@ package de.steamwar.bausystem; import de.steamwar.bausystem.config.BauServer; import de.steamwar.bausystem.features.world.BauMemberUpdate; -import de.steamwar.bausystem.utils.BauMemberUpdateEvent; import de.steamwar.sql.BauweltMember; import de.steamwar.sql.SteamwarUser; import lombok.AllArgsConstructor; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import java.util.HashSet; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributeRemoveCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributeRemoveCommand.java index 689be980..eb621256 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributeRemoveCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributeRemoveCommand.java @@ -24,7 +24,6 @@ import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.MinVersion; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java index 3185c66c..3e477955 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java @@ -24,8 +24,6 @@ import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; -import de.steamwar.bausystem.region.utils.RegionExtensionType; -import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.utils.ItemUtils; import de.steamwar.inventory.SWItem; import de.steamwar.linkage.Linked; @@ -44,7 +42,9 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import java.io.File; -import java.util.*; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; @Linked public class AutostartListener implements Listener { @@ -140,7 +140,7 @@ public class AutostartListener implements Listener { } private int getPreFightDurationInSeconds(Region region) { - File file = region.gameModeConfig(); + File file = region.getGameModeConfig().orElse(null); if (file == null) return 30; FileConfiguration config = YamlConfiguration.loadConfiguration(file); return config.getInt("Times.PreFightDuration", 30); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/bau/ForceSpectatorCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/bau/ForceSpectatorCommand.java index 7bef91df..a192fec5 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/bau/ForceSpectatorCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/bau/ForceSpectatorCommand.java @@ -19,13 +19,11 @@ package de.steamwar.bausystem.features.bau; -import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; import de.steamwar.linkage.Linked; -import de.steamwar.techhider.TechHider; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/CannonKey.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/CannonKey.java index c260e8a9..08912f6f 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/CannonKey.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/CannonKey.java @@ -22,7 +22,6 @@ package de.steamwar.bausystem.features.cannon; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; -import org.bukkit.entity.TNTPrimed; import org.bukkit.util.Vector; import java.util.Set; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerCommand.java index 9ca7a480..1c6a3b41 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerCommand.java @@ -38,7 +38,6 @@ import org.bukkit.event.player.PlayerQuitEvent; import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import java.util.Set; @Linked public class KillcheckerCommand extends SWCommand implements Listener { @@ -57,6 +56,10 @@ public class KillcheckerCommand extends SWCommand implements Listener { @Register(value = "enable", description = "KILLCHECKER_HELP_ENABLE") public void genericCommand(@Validator Player player, @OptionalValue("-outline") @StaticValue(value = {"-area", "-outline"}, allowISE = true) boolean onlyOutline) { Region region = Region.getRegion(player.getLocation()); + if (region.getBuildArea().isEmpty()) { + BauSystem.MESSAGE.send("KILLCHECKER_NO_BUILD", player); + return; + } KillcheckerVisualizer killcheckerVisualizer = visualizers.computeIfAbsent(region, region1 -> new KillcheckerVisualizer(region1, bossBarService)); killcheckerVisualizer.recalc(); killcheckerVisualizer.show(player, onlyOutline); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerVisualizer.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerVisualizer.java index 04822aa8..52eae2b6 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerVisualizer.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerVisualizer.java @@ -22,8 +22,6 @@ package de.steamwar.bausystem.features.killchecker; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.Point; import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.region.utils.RegionExtensionType; -import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar; import de.steamwar.bausystem.utils.bossbar.BossBarService; import de.steamwar.entity.REntity; @@ -75,8 +73,8 @@ public class KillcheckerVisualizer { public KillcheckerVisualizer(Region region, BossBarService bossBarService) { this.region = region; - this.minPoint = region.getMinPoint(RegionType.BUILD, RegionExtensionType.NORMAL); - this.maxPoint = region.getMaxPoint(RegionType.BUILD, RegionExtensionType.NORMAL); + this.minPoint = region.getBuildArea().getMinPoint(false); + this.maxPoint = region.getBuildArea().getMaxPoint(false); yArea = (maxPoint.getX() - minPoint.getX()) * (maxPoint.getZ() - minPoint.getZ()); zArea = (maxPoint.getX() - minPoint.getX()) * (maxPoint.getY() - minPoint.getY()); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderRecorder.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderRecorder.java index cc3dce23..d3e2fcfb 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderRecorder.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderRecorder.java @@ -44,7 +44,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.BiConsumer; -import java.util.function.Consumer; public class LoaderRecorder implements Listener { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/Loadtimer.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/Loadtimer.java index 116edba5..12a4d867 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/Loadtimer.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/Loadtimer.java @@ -22,8 +22,6 @@ package de.steamwar.bausystem.features.loadtimer; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.region.utils.RegionExtensionType; -import de.steamwar.bausystem.region.utils.RegionType; import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -158,7 +156,7 @@ public class Loadtimer implements Listener { } public void onTntExplode(EntityExplodeEvent event) { - if (region.inRegion(event.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION) && stage == Stage.IGNITION) { + if (region.getBuildArea().inRegion(event.getLocation(), true) && stage == Stage.IGNITION) { stage = Stage.END; explode = TPSUtils.currentRealTick.get(); print(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerCommand.java index 531eda68..c09d3c18 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerCommand.java @@ -20,7 +20,6 @@ package de.steamwar.bausystem.features.observer; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; import de.steamwar.command.SWCommand; import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireCommand.java index 3a0d4403..c7372eb3 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireCommand.java @@ -19,13 +19,11 @@ package de.steamwar.bausystem.features.region; -import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; +import de.steamwar.bausystem.region.flags.FireMode; import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.bausystem.region.flags.flagvalues.FireMode; import de.steamwar.command.SWCommand; -import de.steamwar.command.TypeValidator; import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; @@ -55,14 +53,12 @@ public class FireCommand extends SWCommand { } private boolean toggle(Region region) { - switch (region.getPlain(Flag.FIRE, FireMode.class)) { - case ALLOW: - region.set(Flag.FIRE, FireMode.DENY); - return true; - default: - case DENY: - region.set(Flag.FIRE, FireMode.ALLOW); - return false; + if (region.isFlag(Flag.FIRE, FireMode.ALLOW)) { + region.setFlag(Flag.FIRE, FireMode.DENY); + return true; + } else { + region.setFlag(Flag.FIRE, FireMode.ALLOW); + return false; } } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireListener.java index 3cf4d1dc..840356d4 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireListener.java @@ -2,8 +2,8 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.flags.FireMode; import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.bausystem.region.flags.flagvalues.FireMode; import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; @@ -17,12 +17,12 @@ public class FireListener implements Listener, ScoreboardElement { @EventHandler public void onFireDamage(BlockBurnEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).getPlain(Flag.FIRE, FireMode.class) == FireMode.DENY) e.setCancelled(true); + if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FIRE, FireMode.DENY)) e.setCancelled(true); } @EventHandler public void onFireSpread(BlockSpreadEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).getPlain(Flag.FIRE, FireMode.class) == FireMode.DENY) e.setCancelled(true); + if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FIRE, FireMode.DENY)) e.setCancelled(true); } @Override @@ -37,7 +37,7 @@ public class FireListener implements Listener, ScoreboardElement { @Override public String get(Region region, Player p) { - if (region.get(Flag.FIRE) == Flag.FIRE.getDefaultValue()) return null; - return "§e" + BauSystem.MESSAGE.parse(Flag.FIRE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.FIRE).getChatValue(), p); + if (region.isFlag(Flag.FIRE, Flag.FIRE.getDefaultValue(), true)) return null; + return "§e" + BauSystem.MESSAGE.parse(Flag.FIRE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlag(Flag.FIRE).get().getChatValue(), p); } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeCommand.java index d154ce66..aee10390 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeCommand.java @@ -19,13 +19,11 @@ package de.steamwar.bausystem.features.region; -import de.steamwar.bausystem.Permission; 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.FreezeMode; +import de.steamwar.bausystem.region.flags.FreezeMode; import de.steamwar.command.SWCommand; -import de.steamwar.command.TypeValidator; import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; @@ -55,14 +53,12 @@ public class FreezeCommand extends SWCommand { } private boolean toggle(Region region) { - switch (region.getPlain(Flag.FREEZE, FreezeMode.class)) { - case ACTIVE: - region.set(Flag.FREEZE, FreezeMode.INACTIVE); - return false; - default: - case INACTIVE: - region.set(Flag.FREEZE, FreezeMode.ACTIVE); - return true; + if (region.isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { + region.setFlag(Flag.FREEZE, FreezeMode.INACTIVE); + return false; + } else { + region.setFlag(Flag.FREEZE, FreezeMode.ACTIVE); + return true; } } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java index 673867e7..fb15e84e 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java @@ -29,9 +29,7 @@ public class FreezeListener implements Listener, ScoreboardElement { @EventHandler public void onEntitySpawn(EntitySpawnEvent e) { - if (Region.getRegion(e.getLocation()).get(Flag.FREEZE) == FreezeMode.INACTIVE) { - return; - } + if (Region.getRegion(e.getLocation()).isFlag(Flag.FREEZE, FreezeMode.INACTIVE, true)) return; e.setCancelled(true); if (e.getEntityType() == TrickyTrialsWrapper.impl.getTntEntityType()) { Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { @@ -43,8 +41,7 @@ public class FreezeListener implements Listener, ScoreboardElement { @EventHandler public void onBlockCanBuild(BlockCanBuildEvent e) { if (!e.isBuildable()) return; - if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.INACTIVE) - return; + if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.INACTIVE, true)) return; if (e.getMaterial() == Material.TNT) { e.setBuildable(false); e.getBlock().setType(Material.TNT, false); @@ -53,14 +50,14 @@ public class FreezeListener implements Listener, ScoreboardElement { @EventHandler public void onEntityChangeBlock(EntityChangeBlockEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { + if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { e.setCancelled(true); } } @EventHandler public void onPhysicsEvent(BlockPhysicsEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { + if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { if (e.getSourceBlock().getType() == Material.NOTE_BLOCK) { BlockState state = e.getSourceBlock().getState(); NoteBlock noteBlock = (NoteBlock) state.getBlockData(); @@ -85,143 +82,44 @@ public class FreezeListener implements Listener, ScoreboardElement { @EventHandler public void onPistonExtend(BlockPistonExtendEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { + if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { e.setCancelled(true); } } - @EventHandler - public void onNotePlay(NotePlayEvent event) { - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=45, z=98},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=44, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=97},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=99},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=97},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=96},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=99},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-108, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=45, z=98},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-104, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} - - - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=49, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - ////[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=102},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-108, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-104, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - //[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} - } - - @EventHandler public void onPistonRetract(BlockPistonRetractEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { + if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { e.setCancelled(true); } } @EventHandler public void onBlockGrow(BlockGrowEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { + if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { e.setCancelled(true); } } @EventHandler public void onRedstoneEvent(BlockRedstoneEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { + if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { e.setNewCurrent(e.getOldCurrent()); } } @EventHandler public void onBlockDispense(BlockDispenseEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { + if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { e.setCancelled(true); } } @EventHandler public void onInventoryMoveEvent(InventoryMoveItemEvent e) { - if (e.getDestination().getLocation() != null && Region.getRegion(e.getDestination().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { + if (e.getDestination().getLocation() != null && Region.getRegion(e.getDestination().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { e.setCancelled(true); - } else if (e.getSource().getLocation() != null && Region.getRegion(e.getSource().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { + } else if (e.getSource().getLocation() != null && Region.getRegion(e.getSource().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { e.setCancelled(true); } } @@ -230,7 +128,7 @@ public class FreezeListener implements Listener, ScoreboardElement { public void onBlockBreak(BlockBreakEvent e) { if (Core.getVersion() < 19) return; if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return; - if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { + if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { e.setCancelled(true); e.getBlock().setType(Material.BARRIER, false); e.getBlock().setType(Material.AIR, false); @@ -253,35 +151,35 @@ public class FreezeListener implements Listener, ScoreboardElement { @EventHandler public void onFluidLevelChange(FluidLevelChangeEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { + if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { e.setCancelled(true); } } @EventHandler public void onBlockSpread(BlockSpreadEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { + if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { e.setCancelled(true); } } @EventHandler public void onBlockFromTo(BlockFromToEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { + if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { e.setCancelled(true); } } @EventHandler public void onSpongeAbsorb(SpongeAbsorbEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { + if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { e.setCancelled(true); } } @EventHandler public void onBlockForm(BlockFormEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { + if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { e.setCancelled(true); } } @@ -289,7 +187,7 @@ public class FreezeListener implements Listener, ScoreboardElement { @EventHandler public void onPlayerInteract(PlayerInteractEvent e) { if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return; - if (Region.getRegion(e.getClickedBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { + if (Region.getRegion(e.getClickedBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { Block block = e.getClickedBlock(); if (block.getType() == Material.LEVER) { Switch data = ((Switch) block.getBlockData()); @@ -300,9 +198,9 @@ public class FreezeListener implements Listener, ScoreboardElement { } @EventHandler - public void onBlockFade(BlockFadeEvent event) { - if (Region.getRegion(event.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { - event.setCancelled(true); + public void onBlockFade(BlockFadeEvent e) { + if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { + e.setCancelled(true); } } @@ -318,7 +216,7 @@ public class FreezeListener implements Listener, ScoreboardElement { @Override public String get(Region region, Player p) { - if (region.get(Flag.FREEZE) == Flag.FREEZE.getDefaultValue()) return null; - return "§e" + BauSystem.MESSAGE.parse(Flag.FREEZE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.FREEZE).getChatValue(), p); + if (region.isFlag(Flag.FREEZE, Flag.FREEZE.getDefaultValue(), true)) return null; + return "§e" + BauSystem.MESSAGE.parse(Flag.FREEZE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlag(Flag.FREEZE).get().getChatValue(), p); } } 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 8c4452cb..3003912c 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 @@ -19,14 +19,11 @@ package de.steamwar.bausystem.features.region; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.region.GlobalRegion; 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.ItemMode; +import de.steamwar.bausystem.region.flags.ItemMode; import de.steamwar.command.SWCommand; -import de.steamwar.command.TypeValidator; import de.steamwar.linkage.Linked; import de.steamwar.linkage.MinVersion; import org.bukkit.entity.Player; @@ -58,14 +55,12 @@ public class ItemsCommand extends SWCommand { } private boolean toggle(Region region) { - switch (region.getPlain(Flag.ITEMS, ItemMode.class)) { - case ACTIVE: - region.set(Flag.ITEMS, ItemMode.INACTIVE); - return false; - default: - case INACTIVE: - region.set(Flag.ITEMS, ItemMode.ACTIVE); - return true; + if (region.isFlag(Flag.ITEMS, ItemMode.ACTIVE)) { + region.setFlag(Flag.ITEMS, ItemMode.INACTIVE); + return false; + } else { + region.setFlag(Flag.ITEMS, ItemMode.ACTIVE); + return true; } } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsListener.java index 66e1fdb7..b673bb93 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsListener.java @@ -22,7 +22,7 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.bausystem.region.flags.flagvalues.ItemMode; +import de.steamwar.bausystem.region.flags.ItemMode; import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.linkage.Linked; import de.steamwar.linkage.MinVersion; @@ -35,13 +35,9 @@ import org.bukkit.event.entity.ItemSpawnEvent; @MinVersion(19) public class ItemsListener implements Listener, ScoreboardElement { - private static ItemMode getMode(Region region) { - return region.getPlain(Flag.ITEMS, ItemMode.class); - } - @EventHandler public void onItemSpawn(ItemSpawnEvent event) { - if (getMode(Region.getRegion(event.getLocation())) == ItemMode.INACTIVE) { + if (Region.getRegion(event.getLocation()).isFlag(Flag.ITEMS, ItemMode.INACTIVE, true)) { event.setCancelled(true); } } @@ -58,7 +54,7 @@ public class ItemsListener implements Listener, ScoreboardElement { @Override public String get(Region region, Player p) { - if (region.get(Flag.ITEMS) == Flag.ITEMS.getDefaultValue()) return null; - return "§e" + BauSystem.MESSAGE.parse(Flag.ITEMS.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.ITEMS).getChatValue(), p); + if (region.isFlag(Flag.ITEMS, Flag.ITEMS.getDefaultValue(), true)) return null; + return "§e" + BauSystem.MESSAGE.parse(Flag.ITEMS.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlag(Flag.ITEMS).get().getChatValue(), p); } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/NoGravityCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/NoGravityCommand.java index aeeaf588..3d3b6b61 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/NoGravityCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/NoGravityCommand.java @@ -22,7 +22,7 @@ package de.steamwar.bausystem.features.region; 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.NoGravityMode; +import de.steamwar.bausystem.region.flags.NoGravityMode; import de.steamwar.command.SWCommand; import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; @@ -53,14 +53,12 @@ public class NoGravityCommand extends SWCommand { } private boolean toggle(Region region) { - switch (region.getPlain(Flag.NO_GRAVITY, NoGravityMode.class)) { - case ACTIVE: - region.set(Flag.NO_GRAVITY, NoGravityMode.INACTIVE); - return false; - default: - case INACTIVE: - region.set(Flag.NO_GRAVITY, NoGravityMode.ACTIVE); - return true; + if (region.isFlag(Flag.NO_GRAVITY, NoGravityMode.ACTIVE)) { + region.setFlag(Flag.NO_GRAVITY, NoGravityMode.INACTIVE); + return false; + } else { + region.setFlag(Flag.NO_GRAVITY, NoGravityMode.ACTIVE); + return true; } } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/NoGravityListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/NoGravityListener.java index f86403f9..e69b8225 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/NoGravityListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/NoGravityListener.java @@ -22,7 +22,7 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.bausystem.region.flags.flagvalues.NoGravityMode; +import de.steamwar.bausystem.region.flags.NoGravityMode; import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.linkage.Linked; import org.bukkit.entity.EntityType; @@ -34,14 +34,10 @@ import org.bukkit.event.entity.EntitySpawnEvent; @Linked public class NoGravityListener implements Listener, ScoreboardElement { - private static NoGravityMode getMode(Region region) { - return region.getPlain(Flag.NO_GRAVITY, NoGravityMode.class); - } - @EventHandler public void onEntitySpawn(EntitySpawnEvent event) { if (event.getEntityType() == EntityType.PLAYER) return; - if (getMode(Region.getRegion(event.getLocation())) == NoGravityMode.ACTIVE) { + if (Region.getRegion(event.getLocation()).isFlag(Flag.NO_GRAVITY, NoGravityMode.ACTIVE)) { event.getEntity().setGravity(false); } } @@ -58,7 +54,7 @@ public class NoGravityListener implements Listener, ScoreboardElement { @Override public String get(Region region, Player p) { - if (region.get(Flag.NO_GRAVITY) == Flag.NO_GRAVITY.getDefaultValue()) return null; - return "§e" + BauSystem.MESSAGE.parse(Flag.NO_GRAVITY.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.NO_GRAVITY).getChatValue(), p); + if (region.isFlag(Flag.NO_GRAVITY, Flag.NO_GRAVITY.getDefaultValue(), true)) return null; + return "§e" + BauSystem.MESSAGE.parse(Flag.NO_GRAVITY.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlag(Flag.NO_GRAVITY).get().getChatValue(), p); } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectCommand.java index 4fc33cf0..04383c38 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectCommand.java @@ -20,13 +20,11 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; 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.ProtectMode; +import de.steamwar.bausystem.region.flags.ProtectMode; import de.steamwar.command.SWCommand; -import de.steamwar.command.TypeValidator; import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; @@ -41,22 +39,18 @@ public class ProtectCommand extends SWCommand { public void genericProtectCommand(@Validator Player p) { Region region = regionCheck(p); if (region == null) return; - switch (region.getPlain(Flag.PROTECT, ProtectMode.class)) { - case ACTIVE: - region.set(Flag.PROTECT, ProtectMode.INACTIVE); - RegionUtils.actionBar(region, "REGION_PROTECT_DISABLE"); - break; - default: - case INACTIVE: - region.set(Flag.PROTECT, ProtectMode.ACTIVE); - RegionUtils.actionBar(region, "REGION_PROTECT_ENABLE"); - break; + if (region.isFlag(Flag.PROTECT, ProtectMode.ACTIVE)) { + region.setFlag(Flag.PROTECT, ProtectMode.INACTIVE); + RegionUtils.actionBar(region, "REGION_PROTECT_DISABLE"); + } else { + region.setFlag(Flag.PROTECT, ProtectMode.ACTIVE); + RegionUtils.actionBar(region, "REGION_PROTECT_ENABLE"); } } private Region regionCheck(Player player) { Region region = Region.getRegion(player.getLocation()); - if (region.getFloorLevel() == 0) { + if (!region.hasFlag(Flag.PROTECT).isApplicable()) { BauSystem.MESSAGE.send("REGION_PROTECT_FALSE_REGION", player); return null; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectListener.java index 65ec30de..b90aa779 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectListener.java @@ -1,9 +1,10 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.region.Point; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode; +import de.steamwar.bausystem.region.flags.ProtectMode; import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.linkage.Linked; import org.bukkit.Location; @@ -21,13 +22,11 @@ public class ProtectListener implements Listener, ScoreboardElement { private void explode(List blockList, Location location) { Region region = Region.getRegion(location); - if (region.getFloorLevel() == 0) { - return; - } - if (region.getPlain(Flag.PROTECT, ProtectMode.class) == ProtectMode.INACTIVE) { - return; - } - blockList.removeIf(block -> block.getY() < region.getFloorLevel()); + if (region.isFlag(Flag.PROTECT, ProtectMode.INACTIVE)) return; + Point p1 = region.getBuildArea().getMinPoint(true); + Point p2 = region.getTestblockArea().getMinPoint(true); + int floorLevel = Math.min(p1.getY(), p2.getY()); + blockList.removeIf(block -> block.getY() < floorLevel); } @EventHandler @@ -52,8 +51,7 @@ public class ProtectListener implements Listener, ScoreboardElement { @Override public String get(Region region, Player p) { - if (region.getFloorLevel() == 0) return null; - if (region.get(Flag.PROTECT) != Flag.PROTECT.getDefaultValue()) return null; - return "§e" + BauSystem.MESSAGE.parse(Flag.PROTECT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.PROTECT).getChatValue(), p); + if (region.isFlag(Flag.PROTECT, Flag.PROTECT.getDefaultValue(), true)) return null; + return "§e" + BauSystem.MESSAGE.parse(Flag.PROTECT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlag(Flag.PROTECT).get().getChatValue(), p); } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionListener.java index 38b6532e..990c3379 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionListener.java @@ -21,7 +21,8 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.region.tags.Tag; +import de.steamwar.bausystem.region.flags.ChangedMode; +import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.linkage.Linked; import org.bukkit.Location; import org.bukkit.event.EventHandler; @@ -185,7 +186,7 @@ public class RegionListener implements Listener { new BukkitRunnable() { @Override public void run() { - Region.getRegion(location).set(Tag.CHANGED); + Region.getRegion(location).setFlag(Flag.CHANGED, ChangedMode.HAS_CHANGE); } }.runTaskAsynchronously(BauSystem.getInstance()); } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java index 246b9a01..7ad6dea1 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java @@ -19,8 +19,6 @@ package de.steamwar.bausystem.features.region; -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.linkage.Linked; @@ -41,7 +39,9 @@ public class RegionScoreboardElement implements ScoreboardElement { @Override public String get(Region region, Player p) { - if (GlobalRegion.getInstance() == region) return null; - return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + region.getDisplayName(); + if (region.getType().isGlobal()) return null; + // TODO: Fix this! + // return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + region.getName(); + return null; } } 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 27dcbe8f..0aa8a4c9 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 @@ -20,7 +20,6 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.flags.Flag; @@ -29,7 +28,6 @@ import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; -import de.steamwar.command.TypeValidator; import de.steamwar.linkage.Linked; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java index a8d34de5..6b1e899c 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java @@ -23,9 +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.utils.RegionExtensionType; -import de.steamwar.bausystem.region.utils.RegionType; +import de.steamwar.bausystem.region.flags.TNTMode; import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.linkage.Linked; import org.bukkit.block.Block; @@ -37,7 +35,6 @@ import org.bukkit.event.block.BlockExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent; import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; @Linked public class TNTListener implements Listener, ScoreboardElement { @@ -45,24 +42,17 @@ public class TNTListener implements Listener, ScoreboardElement { private void explode(List blockList) { blockList.removeIf(block -> { Region region = Region.getRegion(block.getLocation()); - TNTMode value = region.getPlain(Flag.TNT); + if (!region.hasFlag(Flag.TNT).isReadable()) return false; + TNTMode value = region.getFlag(Flag.TNT).get(); if (value == TNTMode.ALLOW) { return false; } else if (value == TNTMode.ONLY_TB) { - if (region.hasType(RegionType.BUILD) && region.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.NORMAL)) { - RegionUtils.actionBar(region, "REGION_TNT_BUILD_DESTROY"); - return true; - } - if (region.hasType(RegionType.BUILD) && region.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION)) { + if (region.getBuildArea().inRegion(block.getLocation(), true)) { RegionUtils.actionBar(region, "REGION_TNT_BUILD_DESTROY"); return true; } } else if (value == TNTMode.ONLY_BUILD) { - if (region.hasType(RegionType.TESTBLOCK) && region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.NORMAL)) { - RegionUtils.actionBar(region, "REGION_TNT_TB_DESTROY"); - return true; - } - if (region.hasType(RegionType.TESTBLOCK) && region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) { + if (region.getTestblockArea().inRegion(block.getLocation(), true)) { RegionUtils.actionBar(region, "REGION_TNT_TB_DESTROY"); return true; } @@ -93,6 +83,7 @@ public class TNTListener implements Listener, ScoreboardElement { @Override public String get(Region region, Player p) { - return "§e" + BauSystem.MESSAGE.parse(Flag.TNT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.TNT).getChatValue(), p); + if (!region.hasFlag(Flag.TNT).isReadable()) return null; + return "§e" + BauSystem.MESSAGE.parse(Flag.TNT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlag(Flag.TNT).get().getChatValue(), 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 6b319062..a56718c9 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 @@ -20,7 +20,6 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.config.BauServer; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; @@ -32,7 +31,6 @@ import de.steamwar.bausystem.utils.PasteBuilder; import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; -import de.steamwar.command.TypeValidator; import de.steamwar.linkage.Linked; import de.steamwar.linkage.LinkedInstance; import de.steamwar.sql.Punishment; @@ -43,10 +41,8 @@ import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import java.io.IOException; import java.util.*; import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Consumer; import java.util.function.Supplier; import java.util.logging.Level; import java.util.stream.Collectors; 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 79101ee9..4a69b708 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 @@ -23,8 +23,8 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.flags.FireMode; import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.bausystem.region.flags.flagvalues.FireMode; import de.steamwar.inventory.SWItem; import de.steamwar.linkage.Linked; import org.bukkit.Material; @@ -42,7 +42,10 @@ public class FireBauGuiItem extends BauGuiItem { @Override public ItemStack getItem(Player player) { Region region = Region.getRegion(player.getLocation()); - if (region.getPlain(Flag.FIRE, FireMode.class) == FireMode.ALLOW) { + if (!region.hasFlag(Flag.FIRE).isApplicable()) { + return new SWItem(Material.BARRIER, "").getItemStack(); + } + if (region.isFlag(Flag.FIRE, 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 1406638c..0fecdfa8 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 @@ -24,7 +24,7 @@ import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode; +import de.steamwar.bausystem.region.flags.FreezeMode; import de.steamwar.inventory.SWItem; import de.steamwar.linkage.Linked; import org.bukkit.Material; @@ -42,7 +42,10 @@ public class FreezeBauGuiItem extends BauGuiItem { @Override public ItemStack getItem(Player player) { Region region = Region.getRegion(player.getLocation()); - if (region.getPlain(Flag.FREEZE, FreezeMode.class) == FreezeMode.ACTIVE) { + if (!region.hasFlag(Flag.FREEZE).isApplicable()) { + return new SWItem(Material.BARRIER, "").getItemStack(); + } + if (region.isFlag(Flag.FREEZE, 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 a11e508d..5453414e 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 @@ -25,7 +25,7 @@ import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode; +import de.steamwar.bausystem.region.flags.ProtectMode; import de.steamwar.inventory.SWItem; import de.steamwar.linkage.Linked; import org.bukkit.Material; @@ -43,7 +43,10 @@ public class ProtectBauGuiItem extends BauGuiItem { @Override public ItemStack getItem(Player player) { Region region = Region.getRegion(player.getLocation()); - if (region.getPlain(Flag.PROTECT, ProtectMode.class) == ProtectMode.ACTIVE) { + if (!region.hasFlag(Flag.PROTECT).isApplicable()) { + return new SWItem(Material.BARRIER, "").getItemStack(); + } + if (region.isFlag(Flag.PROTECT, 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/script/ScriptGUI.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptGUI.java index add7ad81..fd6fd3f2 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptGUI.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptGUI.java @@ -22,7 +22,6 @@ package de.steamwar.bausystem.features.script; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.features.script.lua.SteamWarPlatform; -import de.steamwar.bausystem.utils.ItemUtils; import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/CommandListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/CommandListener.java index da5f1f21..7cf88d1e 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/CommandListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/CommandListener.java @@ -28,7 +28,6 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; -import org.luaj.vm2.LuaValue; import java.util.HashMap; import java.util.HashSet; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/EventListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/EventListener.java index 4c5feada..958d13a4 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/EventListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/EventListener.java @@ -153,7 +153,7 @@ public class EventListener implements Listener { for (Player player : Bukkit.getOnlinePlayers()) { if(!Permission.BUILD.hasPermission(player)) continue; - if (tntRegion.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) { + if (tntRegion.inRegion(player.getLocation())) { ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTSpawn, LuaValue.NIL, event); } } @@ -171,11 +171,11 @@ public class EventListener implements Listener { table.set("y", event.getLocation().getY()); table.set("z", event.getLocation().getZ()); - boolean inBuild = event.blockList().stream().anyMatch(block -> tntRegion.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION)); + boolean inBuild = event.blockList().stream().anyMatch(block -> tntRegion.getBuildArea().inRegion(block.getLocation(), true)); for (Player player : Bukkit.getOnlinePlayers()) { if(!Permission.BUILD.hasPermission(player)) continue; - if (tntRegion.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) { + if (tntRegion.inRegion(player.getLocation())) { ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplode, table, event); if (inBuild) { ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplodeInBuild, table, event); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/SteamWarLuaPlugin.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/SteamWarLuaPlugin.java index c3370904..a17943a9 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/SteamWarLuaPlugin.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/SteamWarLuaPlugin.java @@ -22,19 +22,14 @@ package de.steamwar.bausystem.features.script.lua; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldedit.bukkit.BukkitPlayer; -import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.event.platform.CommandEvent; import com.sk89q.worldedit.extension.platform.Actor; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.configplayer.Config; import de.steamwar.bausystem.features.script.ScriptRunner; import de.steamwar.bausystem.features.script.lua.libs.LuaLib; import de.steamwar.bausystem.features.world.WorldEditListener; import de.steamwar.bausystem.utils.WorldEditUtils; import de.steamwar.inventory.SWAnvilInv; -import net.md_5.bungee.api.ChatMessageType; -import net.md_5.bungee.api.chat.BaseComponent; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -47,8 +42,6 @@ import org.luaj.vm2.LuaValue; import org.luaj.vm2.Varargs; import org.luaj.vm2.lib.*; -import java.lang.reflect.Proxy; -import java.net.InetSocketAddress; import java.util.*; import java.util.logging.Level; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/ScoreboardLib.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/ScoreboardLib.java index af9c67ae..ff09ac9a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/ScoreboardLib.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/ScoreboardLib.java @@ -24,9 +24,7 @@ import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; import org.luaj.vm2.LuaTable; -import org.luaj.vm2.LuaValue; import org.luaj.vm2.Varargs; -import org.luaj.vm2.lib.TwoArgFunction; import org.luaj.vm2.lib.VarArgFunction; @Linked diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/ServerLib.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/ServerLib.java index 10a41830..039b849f 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/ServerLib.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/ServerLib.java @@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.script.lua.libs; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.features.loader.Loader; import de.steamwar.bausystem.features.loader.LoaderRecorder; import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.inventory.SWItem; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/shieldprinting/impl/PistonConfiguration.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/shieldprinting/impl/PistonConfiguration.java index dab77b8e..c3efb459 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/shieldprinting/impl/PistonConfiguration.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/shieldprinting/impl/PistonConfiguration.java @@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.shieldprinting.BlockDataConfiguration; import de.steamwar.inventory.SWItem; import org.bukkit.Material; -import org.bukkit.block.data.BlockData; import org.bukkit.block.data.type.Piston; import org.bukkit.entity.Player; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/SimulatorElement.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/SimulatorElement.java index 119143db..88aaaa96 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/SimulatorElement.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/SimulatorElement.java @@ -33,7 +33,6 @@ import yapion.hierarchy.types.YAPIONObject; import java.util.ArrayList; import java.util.Comparator; import java.util.List; -import java.util.Map; import java.util.function.BiConsumer; @Getter diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/SimulatorPhase.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/SimulatorPhase.java index b226d124..f69977a6 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/SimulatorPhase.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/SimulatorPhase.java @@ -25,8 +25,6 @@ import lombok.Setter; import org.bukkit.util.Vector; import yapion.hierarchy.types.YAPIONObject; -import java.util.List; -import java.util.Map; import java.util.function.BiConsumer; @Getter diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauCommand.java index daff9d87..34beeee7 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauCommand.java @@ -20,12 +20,10 @@ package de.steamwar.bausystem.features.slaves.laufbau; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.shared.Pair; import de.steamwar.bausystem.utils.WorldEditUtils; import de.steamwar.command.SWCommand; -import de.steamwar.command.TypeValidator; import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.Location; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/PanzernCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/PanzernCommand.java index cca7a266..6c983358 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/PanzernCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/PanzernCommand.java @@ -20,14 +20,12 @@ package de.steamwar.bausystem.features.slaves.panzern; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.shared.Pair; import de.steamwar.bausystem.utils.WorldEditUtils; import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; -import de.steamwar.command.TypeValidator; import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.Location; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCount.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCount.java index 84853b8c..e0e79f77 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCount.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCount.java @@ -24,7 +24,6 @@ import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; import lombok.ToString; -import org.bukkit.Bukkit; import org.bukkit.block.Block; import org.bukkit.scheduler.BukkitTask; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceManager.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceManager.java index 060db33b..a61ed1f6 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceManager.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceManager.java @@ -25,12 +25,10 @@ import de.steamwar.bausystem.features.tracer.rendering.dynamicflags.AtFlag; import de.steamwar.bausystem.features.tracer.rendering.dynamicflags.IsolateFlag; import de.steamwar.bausystem.region.Region; import de.steamwar.linkage.Linked; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.server.PluginEnableEvent; import java.io.File; import java.util.*; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/BindCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/BindCommand.java index 9a93977e..c71c8400 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/BindCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/BindCommand.java @@ -8,7 +8,6 @@ import com.sk89q.worldedit.extension.platform.Actor; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.features.script.ScriptCommand; import de.steamwar.bausystem.features.script.ScriptRunner; import de.steamwar.bausystem.features.world.WorldEditListener; import de.steamwar.bausystem.utils.WorldEditUtils; @@ -28,10 +27,12 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.persistence.PersistentDataType; -import org.luaj.vm2.LuaValue; import java.lang.reflect.Field; -import java.util.*; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Objects; import java.util.logging.Level; import java.util.stream.Collectors; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/ClearCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/ClearCommand.java index 1df08e5d..f1e64ce5 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/ClearCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/ClearCommand.java @@ -20,9 +20,7 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; import de.steamwar.command.SWCommand; -import de.steamwar.command.TypeValidator; import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; 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 c0d99689..0812255e 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 @@ -22,8 +22,8 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.region.utils.RegionSelectionType; 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/features/util/PistonCalculator.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculator.java index 5cc4b744..b50ab2fa 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,7 +21,10 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.entity.*; +import de.steamwar.entity.CWireframe; +import de.steamwar.entity.REntity; +import de.steamwar.entity.REntityServer; +import de.steamwar.entity.RTextDisplay; 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/util/TimeCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/TimeCommand.java index 249f4072..ea38d446 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/TimeCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/TimeCommand.java @@ -20,8 +20,9 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.command.*; +import de.steamwar.command.SWCommand; +import de.steamwar.command.SWCommandUtils; +import de.steamwar.command.TypeMapper; import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.entity.Player; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java index aad07fcb..4b35cef7 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java @@ -20,13 +20,11 @@ package de.steamwar.bausystem.features.warp; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.utils.ListChatView; import de.steamwar.bausystem.worlddata.WorldData; import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommandUtils; import de.steamwar.command.TypeMapper; -import de.steamwar.command.TypeValidator; import de.steamwar.linkage.Linked; import de.steamwar.linkage.api.Disable; import de.steamwar.linkage.api.Enable; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java index d5aa97d5..1e1eba45 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java @@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.world; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.region.GlobalRegion; +import de.steamwar.bausystem.region.RegionSystem; import de.steamwar.bausystem.utils.BauMemberUpdateEvent; import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar; import de.steamwar.bausystem.utils.bossbar.BossBarService; @@ -94,7 +95,7 @@ public class BauMemberUpdate extends PacketHandler implements Listener { } private static void showSpectatorNotice(Player player) { - BauSystemBossbar bossbar = BossBarService.instance.get(player, GlobalRegion.getInstance(), "spectator"); + BauSystemBossbar bossbar = BossBarService.instance.get(player, RegionSystem.INSTANCE.getGlobalRegion(), "spectator"); bossbar.setTitle(BauSystem.MESSAGE.parse("SPECTATOR", player)); bossbar.setColor(BarColor.WHITE); bossbar.setStyle(BarStyle.SOLID); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/KickallCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/KickallCommand.java index d4e5d3f7..44bdb818 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/KickallCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/KickallCommand.java @@ -22,7 +22,6 @@ package de.steamwar.bausystem.features.world; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.config.BauServer; import de.steamwar.command.SWCommand; -import de.steamwar.command.TypeValidator; import de.steamwar.linkage.Linked; import de.steamwar.linkage.LinkedInstance; import org.bukkit.Bukkit; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditSelectionSaver.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditSelectionSaver.java index 1d989226..85351f06 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditSelectionSaver.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditSelectionSaver.java @@ -32,7 +32,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; -import org.checkerframework.checker.units.qual.min; import java.io.*; import java.util.List; 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 72a007a0..53959621 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -44,11 +44,15 @@ public interface Region { & Flag.Value> Optional getFlag(@NonNull Flag flag); default & Flag.Value> boolean isFlag(@NonNull Flag flag, T value) { + return isFlag(flag, value, false); + } + + default & Flag.Value> boolean isFlag(@NonNull Flag flag, T value, boolean defaultValue) { if (hasFlag(flag).isReadable()) { Optional optional = getFlag(flag); return optional.isPresent() && optional.get() == value; } - return false; + return defaultValue; } Point getMinPoint(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java index 7cfa0347..e9eb963b 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java @@ -54,12 +54,12 @@ public final class Flag & Flag.Value> implements EnumDispla private final Class> valueType; @Getter - private final Flag.Value defaultValue; + private final T defaultValue; @Getter private final Flag.Value[] values; - private Flag(String name, String chatValue, Class> valueType, Value defaultValue) { + private Flag(String name, String chatValue, Class> valueType, T defaultValue) { flags.add(this); this.name = name; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemUtils.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemUtils.java index 3202c88e..6ada6d86 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemUtils.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemUtils.java @@ -27,7 +27,6 @@ import org.bukkit.*; import org.bukkit.block.*; import org.bukkit.block.data.*; import org.bukkit.block.data.type.Hopper; -import org.bukkit.block.data.type.Observer; import org.bukkit.block.data.type.*; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockCanBuildEvent; @@ -38,7 +37,9 @@ import org.bukkit.inventory.meta.*; import org.bukkit.util.RayTraceResult; import org.bukkit.util.Vector; -import java.util.*; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; 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 5fb1cc99..843c8500 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 @@ -21,8 +21,6 @@ package de.steamwar.bausystem.utils.bossbar; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.region.utils.RegionExtensionType; -import de.steamwar.bausystem.region.utils.RegionType; import org.bukkit.Bukkit; import org.bukkit.boss.BarColor; import org.bukkit.boss.BarFlag; @@ -120,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(), RegionType.NORMAL, RegionExtensionType.NORMAL)) { + if (region.inRegion(event.getTo())) { bossBar.addPlayer(player); } else { bossBar.removePlayer(player); From ae15e16daeafb0862459cf645f8b3cb00c4f7417 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 22 Dec 2024 22:13:25 +0100 Subject: [PATCH 07/56] Update BauMemberUpdate --- .../de/steamwar/bausystem/features/world/BauMemberUpdate.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java index 1e1eba45..7077cd56 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java @@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.world; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.RegionSystem; import de.steamwar.bausystem.utils.BauMemberUpdateEvent; import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar; @@ -76,7 +75,7 @@ public class BauMemberUpdate extends PacketHandler implements Listener { SPECTATORS.remove(player); newBuilder.add(player); player.removePotionEffect(PotionEffectType.GLOWING); - BossBarService.instance.remove(player, GlobalRegion.getInstance(), "spectator"); + BossBarService.instance.remove(player, RegionSystem.INSTANCE.getGlobalRegion(), "spectator"); } } }); From ef19959eb25249f6140a7c9ef3945b90a80627c4 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Mon, 23 Dec 2024 10:45:20 +0100 Subject: [PATCH 08/56] 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; +} From 5e5bfedb524060d0c316d66c886a355cd5c503d0 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Mon, 23 Dec 2024 12:12:06 +0100 Subject: [PATCH 09/56] Fix some more build errors --- .../src/de/steamwar/bausystem/BauSystem.java | 8 +++--- .../features/region/ColorCommand.java | 6 ++--- .../features/region/RegionCommand.java | 4 +-- .../features/region/ResetCommand.java | 6 ++--- .../region/items/ColorBauGuiItem.java | 2 +- .../features/region/items/TntBauGuiItem.java | 2 +- .../features/script/lua/libs/RegionLib.java | 27 +++++++------------ 7 files changed, 25 insertions(+), 30 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 1d47beb8..4774565c 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -32,9 +32,7 @@ import de.steamwar.bausystem.features.tracer.TraceManager; import de.steamwar.bausystem.features.tracer.TraceRecorder; import de.steamwar.bausystem.features.world.BauScoreboard; import de.steamwar.bausystem.linkage.specific.BauGuiItem; -import de.steamwar.bausystem.region.loader.PrototypeLoader; -import de.steamwar.bausystem.region.loader.RegionLoader; -import de.steamwar.bausystem.region.loader.Updater; +import de.steamwar.bausystem.region.RegionSystem; import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.bausystem.utils.TickListener; import de.steamwar.bausystem.utils.TickManager; @@ -95,6 +93,8 @@ public class BauSystem extends JavaPlugin { instance = this; SWUtils.setBausystem(instance); + RegionSystem.INSTANCE.load(); + /* try { PrototypeLoader.load(); RegionLoader.load(); @@ -107,6 +107,7 @@ public class BauSystem extends JavaPlugin { new Updater(PrototypeLoader.file, PrototypeLoader::load); new Updater(RegionLoader.file, RegionLoader::load); + */ SWCommandUtils.addValidator(Player.class, validator(Permission.BUILD)); SWCommandUtils.addValidator(CommandSender.class, validator(Permission.BUILD)); @@ -223,6 +224,7 @@ public class BauSystem extends JavaPlugin { }); WorldData.write(); + RegionSystem.INSTANCE.save(); Config.getInstance().saveAll(); } 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 545219a2..34401970 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 @@ -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; @@ -57,11 +57,11 @@ public class ColorCommand extends SWCommand { return; } Region region = Region.getRegion(p.getLocation()); - if (region.isGlobal()) { + if (region.getType().isGlobal()) { BauSystem.MESSAGE.send("REGION_COLOR_NO_REGION", p); return; } - region.set(Flag.COLOR, color); + region.setFlag(Flag.COLOR, color); try { PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL))) .ignoreAir(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 6d8d6f4d..e9183e32 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 @@ -32,7 +32,7 @@ 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.flagvalues.ColorMode; +import de.steamwar.bausystem.region.flags.ColorMode; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.shared.Pair; @@ -71,7 +71,7 @@ public class RegionCommand extends SWCommand { } static boolean checkGlobalRegion(Region region, Player p) { - if (region.isGlobal()) { + if (region.getType().isGlobal()) { BauSystem.MESSAGE.send("REGION_REGION_NO_REGION", p); return true; } 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 4490a146..cc12f7b8 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 @@ -21,11 +21,11 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.config.BauServer; -import de.steamwar.bausystem.region.GlobalRegion; 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.flagvalues.ColorMode; +import de.steamwar.bausystem.region.flags.ColorMode; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.utils.PasteBuilder; @@ -99,7 +99,7 @@ public class ResetCommand extends SWCommand { private Region regionCheck(Player player) { Region region = Region.getRegion(player.getLocation()); - if (region == GlobalRegion.getInstance()) { + if (region == RegionSystem.INSTANCE.getGlobalRegion()) { BauSystem.MESSAGE.send("REGION_RESET_NO_REGION", player); return null; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java index a38c397f..119b6fae 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java @@ -25,7 +25,7 @@ import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.region.Color; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.bausystem.region.flags.flagvalues.ColorMode; +import de.steamwar.bausystem.region.flags.ColorMode; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; import de.steamwar.linkage.Linked; 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 38f1b04a..77969ff8 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 @@ -24,7 +24,7 @@ import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.region.Region; 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.inventory.SWInventory; import de.steamwar.inventory.SWItem; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/RegionLib.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/RegionLib.java index f615dad3..c0c5a3d5 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/RegionLib.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/RegionLib.java @@ -20,13 +20,8 @@ package de.steamwar.bausystem.features.script.lua.libs; import de.steamwar.bausystem.features.loader.Loader; -import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.bausystem.region.flags.flagvalues.FireMode; -import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode; -import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode; -import de.steamwar.bausystem.region.flags.flagvalues.TNTMode; +import de.steamwar.bausystem.region.flags.*; import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; import org.luaj.vm2.LuaTable; @@ -49,24 +44,22 @@ public class RegionLib implements LuaLib { table.set("name", getter(() -> region.get().getName())); table.set("type", getter(() -> { Region region1 = region.get(); - if (region1 instanceof GlobalRegion) { + if (region1.getType().isGlobal()) { return "global"; - } else { - return region1.getPrototype().getName(); } + return region1.getPrototype().getName(); })); LuaValue tntLib = LuaValue.tableOf(); - tntLib.set("mode", getter(() -> region.get().getPlain(Flag.TNT, TNTMode.class).name())); - tntLib.set("enabled", getter(() -> region.get().getPlain(Flag.TNT, TNTMode.class) != TNTMode.DENY)); - tntLib.set("onlyTb", getter(() -> region.get().getPlain(Flag.TNT, TNTMode.class) == TNTMode.ONLY_TB)); - tntLib.set("onlyBuild", getter(() -> region.get().getPlain(Flag.TNT, TNTMode.class) == TNTMode.ONLY_BUILD)); - + tntLib.set("mode", getter(() -> region.get().getFlag(Flag.TNT).get().name())); + tntLib.set("enabled", getter(() -> region.get().getFlag(Flag.TNT).get() != TNTMode.DENY)); + tntLib.set("onlyTb", getter(() -> region.get().getFlag(Flag.TNT).get() == TNTMode.ONLY_TB)); + tntLib.set("onlyBuild", getter(() -> region.get().getFlag(Flag.TNT).get() == TNTMode.ONLY_BUILD)); table.set("tnt", tntLib); - table.set("fire", getter(() -> region.get().getPlain(Flag.FIRE, FireMode.class) == FireMode.ALLOW)); - table.set("freeze", getter(() -> region.get().getPlain(Flag.FREEZE, FreezeMode.class) == FreezeMode.ACTIVE)); - table.set("protect", getter(() -> region.get().getPlain(Flag.PROTECT, ProtectMode.class) == ProtectMode.ACTIVE)); + table.set("fire", getter(() -> region.get().getFlag(Flag.FIRE).get() == FireMode.ALLOW)); + table.set("freeze", getter(() -> region.get().getFlag(Flag.FREEZE).get() == FreezeMode.ACTIVE)); + table.set("protect", getter(() -> region.get().getFlag(Flag.PROTECT).get() == ProtectMode.ACTIVE)); //LuaValue traceLib = LuaValue.tableOf(); //traceLib.set("active", getter(() -> !region.get().isGlobal() && Recorder.INSTANCE.get(region.get()) instanceof ActiveTracer)); From 3d0e5fc28d2cb48beec31449ef4dac773988de53 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Tue, 24 Dec 2024 14:47:23 +0100 Subject: [PATCH 10/56] Fix many things --- .../features/design/endstone/DesignEndStone.java | 12 ++++++------ .../features/loadtimer/LoadtimerCommand.java | 4 ++-- .../features/loadtimer/LoadtimerGuiItem.java | 4 ++-- .../bausystem/features/region/RegionCommand.java | 12 ++++++------ .../features/script/lua/libs/StorageLib.java | 3 ++- .../shieldprinting/ShieldPrintingCommand.java | 6 +++--- .../features/techhider/TechHiderCommand.java | 2 +- .../bausystem/features/tracer/TraceRepository.java | 4 +++- .../bausystem/features/xray/XrayCommand.java | 2 +- .../src/de/steamwar/bausystem/region/Region.java | 7 +++++++ .../bausystem/utils/bossbar/BossBarService.java | 2 +- 11 files changed, 34 insertions(+), 24 deletions(-) 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); From 3bb84d0dcc71c3db6ab44e7c0cbd1f81abdef11d Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Wed, 12 Mar 2025 09:11:38 +0100 Subject: [PATCH 11/56] Fixup BoundaryViewer to trigger rebuild --- .../bausystem/features/team/boundary/BoundaryViewer.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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 4d2b34a7..f6636c4f 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 @@ -20,11 +20,9 @@ package de.steamwar.bausystem.features.team.boundary; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.regionnew.Point; +import de.steamwar.bausystem.region.Point; import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.core.TrickyParticleWrapper; -import de.steamwar.core.TrickyTrialsWrapper; import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.Particle; @@ -57,10 +55,10 @@ 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, Particle.END_ROD, region.getMinPointTestblockExtension(), region.getMaxPointTestblockExtension()); + drawCuboid(player, Particle.END_ROD, region.getTestblockArea().getMinPoint(true), region.getTestblockArea().getMaxPoint(true)); } if (region.getBuildArea().isPresent()) { - drawCuboid(player, Particle.END_ROD, region.getMinPointBuildExtension(), region.getMaxPointBuildExtension()); + drawCuboid(player, Particle.END_ROD, region.getBuildArea().getMinPoint(true), region.getBuildArea().getMaxPoint(true)); } } From 7dc9da549c381db215a7eb665ae297ac7d6515ed Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 3 Jul 2025 09:52:56 +0200 Subject: [PATCH 12/56] Fix some more stuff --- .../features/region/FreezeListener.java | 2 +- .../features/script/lua/libs/RegionLib.java | 31 ++++++++++--------- .../features/script/lua/libs/StorageLib.java | 4 +-- .../simulator/execute/StabFinalizer.java | 9 +++--- .../simulator/execute/StabGenerator.java | 10 +++--- .../features/tracer/TraceRepository.java | 4 +-- .../de/steamwar/bausystem/region/Region.java | 3 ++ .../bausystem/region/RegionSystem.java | 5 +-- 8 files changed, 39 insertions(+), 29 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java index fb15e84e..d0b63900 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java @@ -3,7 +3,7 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode; +import de.steamwar.bausystem.region.flags.FreezeMode; import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.core.Core; import de.steamwar.core.TrickyTrialsWrapper; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/RegionLib.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/RegionLib.java index c0c5a3d5..18b8760a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/RegionLib.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/RegionLib.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.script.lua.libs; import de.steamwar.bausystem.features.loader.Loader; import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.RegionSystem; import de.steamwar.bausystem.region.flags.*; import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; @@ -28,6 +29,7 @@ import org.luaj.vm2.LuaTable; import org.luaj.vm2.LuaValue; import org.luaj.vm2.lib.OneArgFunction; +import java.util.UUID; import java.util.function.Supplier; @Linked @@ -41,13 +43,14 @@ public class RegionLib implements LuaLib { private LuaTable create(Supplier region, Player player) { LuaTable table = LuaValue.tableOf(); - table.set("name", getter(() -> region.get().getName())); + table.set("name", getter(() -> region.get().getID().toString())); + table.set("id", getter(() -> region.get().getID().toString())); table.set("type", getter(() -> { Region region1 = region.get(); if (region1.getType().isGlobal()) { return "global"; } - return region1.getPrototype().getName(); + return region1.getType().name().toLowerCase(); })); LuaValue tntLib = LuaValue.tableOf(); @@ -72,16 +75,16 @@ public class RegionLib implements LuaLib { Loader loader = Loader.getLoader(player); table.set("loader", getter(() -> loader == null ? "OFF" : loader.getStage().name())); - table.set("copyPoint", getter(() -> toPos(region.get().getCopyPoint()))); - table.set("minPointBuild", getter(() -> toPos(region.get().getMinPointBuild()))); - table.set("maxPointBuild", getter(() -> toPos(region.get().getMaxPointBuild()))); - table.set("minPointBuildExtension", getter(() -> toPos(region.get().getMinPointBuildExtension()))); - table.set("maxPointBuildExtension", getter(() -> toPos(region.get().getMaxPointBuildExtension()))); - table.set("testblockPoint", getter(() -> toPos(region.get().getTestBlockPoint()))); - table.set("minPointTestblock", getter(() -> toPos(region.get().getMinPointTestblock()))); - table.set("maxPointTestblock", getter(() -> toPos(region.get().getMaxPointTestblock()))); - table.set("minPointTestblockExtension", getter(() -> toPos(region.get().getMinPointTestblockExtension()))); - table.set("maxPointTestblockExtension", getter(() -> toPos(region.get().getMaxPointTestblockExtension()))); + table.set("copyPoint", getter(() -> toPos(region.get().getBuildArea().getCopyPoint()))); + table.set("minPointBuild", getter(() -> toPos(region.get().getBuildArea().getMinPoint(false)))); + table.set("maxPointBuild", getter(() -> toPos(region.get().getBuildArea().getMinPoint(false)))); + table.set("minPointBuildExtension", getter(() -> toPos(region.get().getBuildArea().getMinPoint(true)))); + table.set("maxPointBuildExtension", getter(() -> toPos(region.get().getBuildArea().getMinPoint(true)))); + table.set("testblockPoint", getter(() -> toPos(region.get().getTestblockArea().getCopyPoint()))); + table.set("minPointTestblock", getter(() -> toPos(region.get().getTestblockArea().getMinPoint(false)))); + table.set("maxPointTestblock", getter(() -> toPos(region.get().getTestblockArea().getMinPoint(false)))); + table.set("minPointTestblockExtension", getter(() -> toPos(region.get().getTestblockArea().getMinPoint(true)))); + table.set("maxPointTestblockExtension", getter(() -> toPos(region.get().getTestblockArea().getMinPoint(true)))); return table; } @@ -92,11 +95,11 @@ public class RegionLib implements LuaLib { table.set("get", new OneArgFunction() { @Override public LuaValue call(LuaValue arg) { - return create(() -> Region.getREGION_MAP().get(arg.checkjstring()), player); + return create(() -> RegionSystem.INSTANCE.getRegion(UUID.fromString(arg.checkjstring())).orElse(RegionSystem.INSTANCE.getGlobalRegion()), player); } }); - table.set("list", getter(() -> LuaValue.listOf(Region.getREGION_MAP().values().stream().map(region -> create(() -> region, player)).toArray(LuaTable[]::new)))); + table.set("list", getter(() -> LuaValue.listOf(RegionSystem.INSTANCE.getRegions().map(region -> create(() -> region, player)).toArray(LuaTable[]::new)))); return table; } 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 51a35bd7..37454427 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 @@ -75,7 +75,7 @@ public class StorageLib implements LuaLib, Enable, Disable { jsonObject.keySet().forEach(key -> { map.put(key, fromJson(jsonObject.get(key))); }); - Region region = RegionSystem.INSTANCE.getRegion(regionStorage.getName().substring(0, regionStorage.getName().length() - ".json".length())).orElse(null); + Region region = RegionSystem.INSTANCE.getRegion(UUID.fromString(regionStorage.getName().substring(0, regionStorage.getName().length() - ".json".length()))).orElse(null); REGION_STORAGE.put(region, map); } catch (Exception e) {} } @@ -144,7 +144,7 @@ public class StorageLib implements LuaLib, Enable, Disable { regionStorageDirectory.mkdirs(); for (Map.Entry> entry : REGION_STORAGE.entrySet()) { try { - FileWriter fileWriter = new FileWriter(new File(regionStorageDirectory, entry.getKey().getName() + ".json")); + FileWriter fileWriter = new FileWriter(new File(regionStorageDirectory, entry.getKey().getID().toString() + ".json")); gson.toJson(toJson(entry.getValue()), fileWriter); fileWriter.close(); } catch (IOException e) {} 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 5c0d77aa..79148cc3 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 @@ -19,10 +19,9 @@ package de.steamwar.bausystem.features.simulator.execute; -import de.steamwar.bausystem.features.tracer.Trace; 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.flags.flagvalues.ColorMode; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.utils.PasteBuilder; @@ -38,8 +37,10 @@ public class StabFinalizer extends StabStep { protected void start() { try { PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard); - PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider) - .color(data.region.getPlain(Flag.COLOR, ColorMode.class).getColor()); + PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider); + if (data.region.hasFlag(Flag.COLOR).isReadable()) { + pasteBuilder.color(data.region.getFlag(Flag.COLOR).get().getColor()); + } data.region.reset(pasteBuilder, RegionType.TESTBLOCK, RegionExtensionType.EXTENSION); } catch (SecurityException e) { stop(); 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 4a15ebcb..a53e0093 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,7 +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.flags.flagvalues.ColorMode; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.utils.PasteBuilder; @@ -56,7 +55,8 @@ 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)) return; + if (!data.region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) + return; int component = data.direction.component.apply(block.getLocation().toVector()); destroyedBlocksPerSlice.computeIfAbsent(component, __ -> new HashSet<>()) .add(block.getLocation()); @@ -72,8 +72,10 @@ public class StabGenerator extends StabStep implements Listener { protected void start() { try { PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard); - PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider) - .color(data.region.getPlain(Flag.COLOR, ColorMode.class).getColor()); + PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider); + if (data.region.hasFlag(Flag.COLOR).isReadable()) { + pasteBuilder.color(data.region.getFlag(Flag.COLOR).get().getColor()); + } data.region.reset(pasteBuilder, RegionType.TESTBLOCK, RegionExtensionType.EXTENSION); } catch (SecurityException e) { stop(); 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 e20ec561..0765d92b 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 @@ -32,7 +32,7 @@ public class TraceRepository { @Cleanup ObjectInputStream reader = new ObjectInputStream(new GZIPInputStream(new FileInputStream(recordsFile))); UUID uuid = UUID.fromString(reader.readUTF()); - Region region = RegionSystem.INSTANCE.getRegion(reader.readUTF()).orElse(null); + Region region = RegionSystem.INSTANCE.getRegion(UUID.fromString(reader.readUTF())).orElse(null); if (region == null) return null; Date date = (Date) reader.readObject(); int serialisationVersion = reader.readInt(); @@ -48,7 +48,7 @@ public class TraceRepository { protected static void writeTrace(Trace trace, List records) { ObjectOutputStream outputStream = new ObjectOutputStream(new GZIPOutputStream(new FileOutputStream(trace.getRecordsSaveFile()))); outputStream.writeUTF(trace.getUuid().toString()); - outputStream.writeUTF(trace.getRegion().getName()); + outputStream.writeUTF(trace.getRegion().getID().toString()); outputStream.writeObject(trace.getDate()); outputStream.writeInt(SERIALISATION_VERSION); 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 6c8dce46..74a4fcec 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -28,6 +28,7 @@ import org.bukkit.Location; import javax.annotation.Nullable; import java.io.File; import java.util.Optional; +import java.util.UUID; public interface Region { @@ -35,6 +36,8 @@ public interface Region { return RegionSystem.INSTANCE.get(location); } + UUID getID(); + RegionType getType(); & Flag.Value> RegionFlagPolicy hasFlag(@NonNull Flag flag); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java index 9c480219..26ee4bc6 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java @@ -23,6 +23,7 @@ import org.bukkit.Location; import java.lang.reflect.InvocationTargetException; import java.util.Optional; +import java.util.UUID; import java.util.stream.Stream; public interface RegionSystem { @@ -35,7 +36,7 @@ public interface RegionSystem { Region getGlobalRegion(); Region get(Location location); - Optional getRegion(String name); + Optional getRegion(UUID id); Stream getRegions(); @@ -68,7 +69,7 @@ public interface RegionSystem { } @Override - public Optional getRegion(String name) { + public Optional getRegion(UUID id) { throw new UnsupportedOperationException(); } From e98f53bbabdee2d52ab3bfccd3e53253c57940ee Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 3 Jul 2025 10:22:56 +0200 Subject: [PATCH 13/56] Update Region --- .../bausystem/region/FlagStorage.java | 6 +- .../de/steamwar/bausystem/region/Region.java | 90 +++---------------- .../bausystem/region/RegionHistory.java | 31 +++++++ 3 files changed, 47 insertions(+), 80 deletions(-) create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionHistory.java diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java index 3ca76ace..1c8048b6 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java @@ -21,9 +21,13 @@ package de.steamwar.bausystem.region; import de.steamwar.bausystem.region.flags.Flag; +import java.util.Optional; + public interface FlagStorage { + & Flag.Value> RegionFlagPolicy has(Flag flag); + & Flag.Value> boolean set(Flag flag, T value); - & Flag.Value> T get(Flag flag); + & Flag.Value> Optional get(Flag flag); } 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 74a4fcec..34d69f45 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -20,15 +20,14 @@ package de.steamwar.bausystem.region; import com.sk89q.worldedit.EditSession; -import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.sql.SchematicNode; -import lombok.NonNull; import org.bukkit.Location; import javax.annotation.Nullable; import java.io.File; import java.util.Optional; import java.util.UUID; +import java.util.function.BiConsumer; public interface Region { @@ -40,92 +39,21 @@ public interface Region { RegionType getType(); - & Flag.Value> RegionFlagPolicy hasFlag(@NonNull Flag flag); + FlagStorage getFlags(); - & Flag.Value> boolean setFlag(@NonNull Flag flag, T value); + Area getArea(); - & Flag.Value> Optional getFlag(@NonNull Flag flag); + Optional getBuildArea(); - default & Flag.Value> boolean isFlag(@NonNull Flag flag, T value) { - return isFlag(flag, value, false); - } - - default & Flag.Value> boolean isFlag(@NonNull Flag flag, T value, boolean defaultValue) { - if (hasFlag(flag).isReadable()) { - Optional optional = getFlag(flag); - return optional.isPresent() && optional.get() == value; - } - return defaultValue; - } - - Point getMinPoint(); - - Point getMaxPoint(); - - boolean inRegion(Location location); - - Inner getBuildArea(); - - Inner getTestblockArea(); + Optional getTestblockArea(); // TODO: Add forEachChunk and getChunkOutsidePredicate Optional getGameModeConfig(); - boolean backup(boolean automatic); + RegionHistory getHistory(); - Optional copy(); - - void reset(); - - void remember(EditSession editSession); - - boolean undo(); - - boolean redo(); - - interface Inner { - - Inner EMPTY = new Inner() { - private static final Point ZERO = new Point(0, 0, 0); - - @Override - public Point getMinPoint(boolean extension) { - return ZERO; - } - - @Override - public Point getMaxPoint(boolean extension) { - return ZERO; - } - - @Override - public Point getCopyPoint() { - return ZERO; - } - - @Override - public boolean inRegion(Location location, boolean extension) { - return false; - } - - @Override - public Optional copy(boolean extension) { - return Optional.empty(); - } - - @Override - public void reset(@Nullable SchematicNode schematicNode, boolean extension) { - } - }; - - default boolean isEmpty() { - return this == EMPTY; - } - - default boolean isPresent() { - return this != EMPTY; - } + interface Area { Point getMinPoint(boolean extension); @@ -138,5 +66,9 @@ public interface Region { Optional copy(boolean extension); void reset(@Nullable SchematicNode schematicNode, boolean extension); + + void forEachChunk(BiConsumer executor); + + boolean isChunkOutside(int chunkX, int chunkZ); } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionHistory.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionHistory.java new file mode 100644 index 00000000..17ff9c19 --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionHistory.java @@ -0,0 +1,31 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 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; + +public interface RegionHistory { + + void remember(EditSession editSession); + + boolean undo(); + + boolean redo(); +} From 314aaf7a760663533cdea6603cb05b47d4aba6ff Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 3 Jul 2025 15:37:22 +0200 Subject: [PATCH 14/56] Update Region --- .../BauSystem_Main/src/de/steamwar/bausystem/region/Region.java | 2 -- 1 file changed, 2 deletions(-) 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 34d69f45..d3f51f88 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -47,8 +47,6 @@ public interface Region { Optional getTestblockArea(); - // TODO: Add forEachChunk and getChunkOutsidePredicate - Optional getGameModeConfig(); RegionHistory getHistory(); From c9b4e6ab451c3b5b98078237f8dee35eb633e306 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 3 Jul 2025 15:54:48 +0200 Subject: [PATCH 15/56] Improve Region some more --- .../bausystem/region/BackupScheduler.java | 11 +++-- .../de/steamwar/bausystem/region/Color.java | 46 ------------------- .../de/steamwar/bausystem/region/Region.java | 2 +- .../bausystem/region/flags/ColorMode.java | 35 +++++++------- .../bausystem/region/utils/RegionType.java | 20 ++++---- 5 files changed, 35 insertions(+), 79 deletions(-) delete mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Color.java diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java index eb57e09f..512c0199 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java @@ -1,5 +1,6 @@ package de.steamwar.bausystem.region; +import com.sk89q.worldedit.EditSession; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.flags.ChangedMode; import de.steamwar.bausystem.region.flags.Flag; @@ -21,7 +22,8 @@ public class BackupScheduler implements Enable { @Override public void run() { Iterator regionsToBackup = RegionSystem.INSTANCE.getRegions() - .filter(region -> region.isFlag(Flag.CHANGED, ChangedMode.HAS_CHANGE)) + .filter(region -> region.getFlags().has(Flag.CHANGED).isReadable()) + .filter(region -> region.getFlags().get(Flag.CHANGED).get() == ChangedMode.HAS_CHANGE) .iterator(); if (!regionsToBackup.hasNext()) return; doBackup(regionsToBackup); @@ -39,9 +41,10 @@ public class BackupScheduler implements Enable { } Region region = regionsToBackup.next(); - if (region.backup(true)) { - region.setFlag(Flag.CHANGED, ChangedMode.NO_CHANGE); - } + EditSession editSession = region.getArea() + .copy(false); + // TODO: Implement saving EditSession to schematic! + region.getFlags().set(Flag.CHANGED, ChangedMode.NO_CHANGE); } }.runTaskTimer(BauSystem.getInstance(), 0, 20 * 60); } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Color.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Color.java deleted file mode 100644 index 72052d74..00000000 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Color.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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 lombok.Getter; -import lombok.RequiredArgsConstructor; - -@RequiredArgsConstructor -@Getter -public enum Color { - WHITE('f'), - ORANGE('6'), - MAGENTA('5'), - LIGHT_BLUE('b'), - YELLOW('e'), - LIME('a'), - PINK('d'), - GRAY('8'), - LIGHT_GRAY('7'), - CYAN('3'), - PURPLE('5'), - BLUE('9'), - BROWN('e'), - GREEN('2'), - RED('c'), - BLACK('1'); - - private final char colorCode; -} 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 d3f51f88..0b7cd049 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -61,7 +61,7 @@ public interface Region { boolean inRegion(Location location, boolean extension); - Optional copy(boolean extension); + EditSession copy(boolean extension); void reset(@Nullable SchematicNode schematicNode, boolean extension); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ColorMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ColorMode.java index e266d874..1f7db755 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ColorMode.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ColorMode.java @@ -19,33 +19,32 @@ package de.steamwar.bausystem.region.flags; -import de.steamwar.bausystem.region.Color; import lombok.AllArgsConstructor; import lombok.Getter; @Getter @AllArgsConstructor public enum ColorMode implements Flag.Value { - WHITE("FLAG_COLOR_WHITE", Color.WHITE), - ORANGE("FLAG_COLOR_ORANGE", Color.ORANGE), - MAGENTA("FLAG_COLOR_MAGENTA", Color.MAGENTA), - LIGHT_BLUE("FLAG_COLOR_LIGHT_BLUE", Color.LIGHT_BLUE), - YELLOW("FLAG_COLOR_YELLOW", Color.YELLOW), - LIME("FLAG_COLOR_LIME", Color.LIME), - PINK("FLAG_COLOR_PINK", Color.PINK), - GRAY("FLAG_COLOR_GRAY", Color.GRAY), - LIGHT_GRAY("FLAG_COLOR_LIGHT_GRAY", Color.LIGHT_GRAY), - CYAN("FLAG_COLOR_CYAN", Color.CYAN), - PURPLE("FLAG_COLOR_PURPLE", Color.PURPLE), - BLUE("FLAG_COLOR_BLUE", Color.BLUE), - BROWN("FLAG_COLOR_BROWN", Color.BROWN), - GREEN("FLAG_COLOR_GREEN", Color.GREEN), - RED("FLAG_COLOR_RED", Color.RED), - BLACK("FLAG_COLOR_BLACK", Color.BLACK); + WHITE("FLAG_COLOR_WHITE", 'f'), + ORANGE("FLAG_COLOR_ORANGE", '6'), + MAGENTA("FLAG_COLOR_MAGENTA", '5'), + LIGHT_BLUE("FLAG_COLOR_LIGHT_BLUE", 'b'), + YELLOW("FLAG_COLOR_YELLOW", 'e'), + LIME("FLAG_COLOR_LIME", 'a'), + PINK("FLAG_COLOR_PINK", 'd'), + GRAY("FLAG_COLOR_GRAY", '8'), + LIGHT_GRAY("FLAG_COLOR_LIGHT_GRAY", '7'), + CYAN("FLAG_COLOR_CYAN", '3'), + PURPLE("FLAG_COLOR_PURPLE", '5'), + BLUE("FLAG_COLOR_BLUE", '9'), + BROWN("FLAG_COLOR_BROWN", 'e'), + GREEN("FLAG_COLOR_GREEN", '2'), + RED("FLAG_COLOR_RED", 'c'), + BLACK("FLAG_COLOR_BLACK", '1'); private static ColorMode[] values; private final String chatValue; - private final Color color; + private final char colorCode; @Override public ColorMode[] getValues() { 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 index 79d83ff7..1ea7e577 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionType.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionType.java @@ -15,25 +15,25 @@ import java.util.function.Predicate; public enum RegionType implements EnumDisplay { NORMAL("REGION_TYPE_NORMAL", region -> true, - region -> null, - (region, extension) -> region.getMinPoint(), - (region, extension) -> region.getMaxPoint()), + Region::getArea, + (region, extension) -> region.getArea().getMinPoint(false), + (region, extension) -> region.getArea().getMaxPoint(false)), BUILD("REGION_TYPE_BUILD", region -> region.getBuildArea().isPresent(), - Region::getBuildArea, - (region, extension) -> region.getBuildArea().getMinPoint(extension), - (region, extension) -> region.getBuildArea().getMaxPoint(extension)), + region -> region.getBuildArea().get(), + (region, extension) -> region.getBuildArea().get().getMinPoint(extension), + (region, extension) -> region.getBuildArea().get().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)), + region -> region.getTestblockArea().get(), + (region, extension) -> region.getTestblockArea().get().getMinPoint(extension), + (region, extension) -> region.getTestblockArea().get().getMaxPoint(extension)), ; private String chatValue; private Predicate hasType; - private Function toInner; + private Function toInner; private BiFunction toMinPoint; private BiFunction toMaxPoint; } From 7e61db5e58d94e21548068e4308e1a37bd6320c9 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 10 Jul 2025 14:01:19 +0200 Subject: [PATCH 16/56] Fix some more issues --- .../features/region/items/ColorBauGuiItem.java | 13 ++++++------- .../bausystem/features/tpslimit/TPSSystem.java | 5 ++--- .../worldedit/ColorReplaceCommand.java | 18 +++++++++--------- .../de/steamwar/bausystem/region/Region.java | 3 +++ .../steamwar/bausystem/utils/PasteBuilder.java | 8 ++++---- 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java index 119b6fae..ae633edd 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java @@ -22,10 +22,9 @@ package de.steamwar.bausystem.features.region.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.linkage.specific.BauGuiItem; -import de.steamwar.bausystem.region.Color; import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.ColorMode; +import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; import de.steamwar.linkage.Linked; @@ -45,7 +44,7 @@ public class ColorBauGuiItem extends BauGuiItem { super(2); } - private static Material mapColor(Color color) { + private static Material mapColor(ColorMode color) { switch (color) { case RED: return Material.RED_CONCRETE; @@ -85,17 +84,17 @@ public class ColorBauGuiItem extends BauGuiItem { @Override public ItemStack getItem(Player player) { Region region = Region.getRegion(player.getLocation()); - ColorMode mode = region.getPlain(Flag.COLOR, ColorMode.class); - return new SWItem(mapColor(mode.getColor()), BauSystem.MESSAGE.parse("REGION_ITEM_COLOR", player, BauSystem.MESSAGE.parse(mode.getChatValue(), player))).getItemStack(); + ColorMode mode = region.getFlags().get(Flag.COLOR).orElse(ColorMode.PINK); + return new SWItem(mapColor(mode), BauSystem.MESSAGE.parse("REGION_ITEM_COLOR", player, BauSystem.MESSAGE.parse(mode.getChatValue(), player))).getItemStack(); } @Override public boolean click(ClickType click, Player p) { p.closeInventory(); - ColorMode current = Region.getRegion(p.getLocation()).getPlain(Flag.COLOR, ColorMode.class); + ColorMode current = Region.getRegion(p.getLocation()).getFlags().get(Flag.COLOR).orElse(ColorMode.PINK); List> items = new ArrayList<>(); for (ColorMode value : ColorMode.values()) { - items.add(new SWListInv.SWListEntry<>(new SWItem(mapColor(value.getColor()), (byte) 0, "§f" + BauSystem.MESSAGE.parse(value.getChatValue(), p), Collections.emptyList(), value == current, clickType -> { + items.add(new SWListInv.SWListEntry<>(new SWItem(mapColor(value), (byte) 0, "§f" + BauSystem.MESSAGE.parse(value.getChatValue(), p), Collections.emptyList(), value == current, clickType -> { }), value)); } SWListInv inv = new SWListInv<>(p, BauSystem.MESSAGE.parse("REGION_ITEM_COLOR_CHOOSE", p), items, (clickType, colorMode) -> { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java index f84ab72e..bb03ae0a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java @@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.linkage.specific.BauGuiItem; -import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.bausystem.utils.TickEndEvent; @@ -85,14 +84,14 @@ public class TPSSystem implements Listener { private void bossbar() { if ((TickManager.impl.isStepping() || TickManager.impl.isSprinting()) && TickManager.impl.getRemainingTicks() > 0) { Bukkit.getOnlinePlayers().forEach(player -> { - BauSystemBossbar bossbar = BossBarService.instance.get(player, GlobalRegion.getInstance(), "TickStep"); + BauSystemBossbar bossbar = BossBarService.instance.get(player, Region.getGlobalRegion(), "TickStep"); bossbar.setColor(BarColor.YELLOW); bossbar.setTitle(BauSystem.MESSAGE.parse("TICK_BOSSBAR", player, TickManager.impl.getDoneTicks(), TickManager.impl.getTotalTicks())); bossbar.setProgress(TickManager.impl.getDoneTicks() / (double) TickManager.impl.getTotalTicks()); }); } else { Bukkit.getOnlinePlayers().forEach(player -> { - BossBarService.instance.remove(player, GlobalRegion.getInstance(), "TickStep"); + BossBarService.instance.remove(player, Region.getGlobalRegion(), "TickStep"); }); } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java index 6b6659ba..f3efca4b 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java @@ -28,7 +28,7 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import de.steamwar.bausystem.features.world.WorldEditListener; import de.steamwar.bausystem.features.worldedit.utils.SpecialReplace; -import de.steamwar.bausystem.region.Color; +import de.steamwar.bausystem.region.flags.ColorMode; import de.steamwar.bausystem.shared.Pair; import de.steamwar.bausystem.utils.WorldEditUtils; import de.steamwar.command.PreviousArguments; @@ -63,7 +63,7 @@ public class ColorReplaceCommand extends SWCommand { @Register(description = "COLORREPLACE_HELP") @SneakyThrows - public void genericCommand(@Validator Player player, Pair from, Color to) { + public void genericCommand(@Validator Player player, Pair from, ColorMode to) { if (from.getValue() == to) { BukkitAdapter.adapt(player).printInfo(TranslatableComponent.of("worldedit.replace.replaced", new Component[]{TextComponent.of(0)})); return; @@ -89,23 +89,23 @@ public class ColorReplaceCommand extends SWCommand { } @ClassMapper(value = Pair.class, local = true) - public TypeMapper> typeMapper() { - return new TypeMapper>() { + public TypeMapper> typeMapper() { + return new TypeMapper>() { @Override - public Pair map(CommandSender commandSender, PreviousArguments previousArguments, String s) { + public Pair map(CommandSender commandSender, PreviousArguments previousArguments, String s) { if (s.contains("%")) { String[] split = s.split("%"); if (split.length != 2) { return null; } - Color color = Color.valueOf(split[1].toUpperCase()); + ColorMode color = ColorMode.valueOf(split[1].toUpperCase()); try { return new Pair<>(Integer.parseInt(split[0]), color); } catch (NumberFormatException e) { return null; } } - return new Pair<>(100, Color.valueOf(s.toUpperCase())); + return new Pair<>(100, ColorMode.valueOf(s.toUpperCase())); } @Override @@ -113,12 +113,12 @@ public class ColorReplaceCommand extends SWCommand { if (s.matches("[0-9].*")) { if (s.contains("%")) { String sub = s.substring(0, s.indexOf("%") + 1); - return Arrays.stream(Color.values()).map(Color::name).map(t -> sub + t.toLowerCase()).collect(Collectors.toSet()); + return Arrays.stream(ColorMode.values()).map(ColorMode::name).map(t -> sub + t.toLowerCase()).collect(Collectors.toSet()); } else { return Arrays.asList(s); } } else { - return Arrays.stream(Color.values()).map(Color::name).map(String::toLowerCase).collect(Collectors.toSet()); + return Arrays.stream(ColorMode.values()).map(ColorMode::name).map(String::toLowerCase).collect(Collectors.toSet()); } } }; 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 0b7cd049..d28430a2 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -34,6 +34,9 @@ public interface Region { static Region getRegion(Location location) { return RegionSystem.INSTANCE.get(location); } + static Region getGlobalRegion() { + return RegionSystem.INSTANCE.getGlobalRegion(); + } UUID getID(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PasteBuilder.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PasteBuilder.java index a4a74e17..0622bb11 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PasteBuilder.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PasteBuilder.java @@ -26,8 +26,8 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; -import de.steamwar.bausystem.region.Color; import de.steamwar.bausystem.region.Point; +import de.steamwar.bausystem.region.flags.ColorMode; import de.steamwar.sql.SchematicData; import de.steamwar.sql.SchematicNode; import lombok.Getter; @@ -102,8 +102,8 @@ public class PasteBuilder { return this; } - public PasteBuilder color(Color color) { - if (color == Color.PINK) return this; + public PasteBuilder color(ColorMode color) { + if (color == ColorMode.PINK) return this; Map blockCache = new HashMap<>(); return map((clipboard, blockVector3) -> { @@ -122,7 +122,7 @@ public class PasteBuilder { } /** - * Can only be used before {@link #color(Color)}. + * Can only be used before {@link #color(ColorMode)}. */ public PasteBuilder onlyColors(boolean onlyColors) { if (!onlyColors) return this; From 43cca3376ebef1fc7d79db0edd68ad594b1149ea Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 11 Jul 2025 21:36:50 +0200 Subject: [PATCH 17/56] Fix some more issues --- .../features/autostart/AutostartListener.java | 2 +- .../features/script/event/EventListener.java | 4 +- .../features/techhider/TechHiderCommand.java | 6 +-- .../features/util/KillAllCommand.java | 2 +- .../features/world/BauScoreboard.java | 5 +- .../bausystem/features/xray/XrayCommand.java | 4 +- .../de/steamwar/bausystem/region/Point.java | 2 + .../de/steamwar/bausystem/region/Region.java | 53 ++++++++++++++++++- 8 files changed, 65 insertions(+), 13 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java index 3e477955..59e4fd3a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java @@ -109,7 +109,7 @@ public class AutostartListener implements Listener { BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO_REGION", player); return; } - if (region.getTestblockArea().isPresent()) { + if (region.getTestblockArea().isEmpty()) { BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO_REGION", player); return; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/EventListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/EventListener.java index 958d13a4..54ddac4e 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/EventListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/EventListener.java @@ -153,7 +153,7 @@ public class EventListener implements Listener { for (Player player : Bukkit.getOnlinePlayers()) { if(!Permission.BUILD.hasPermission(player)) continue; - if (tntRegion.inRegion(player.getLocation())) { + if (tntRegion.getArea().inRegion(player.getLocation(), false)) { ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTSpawn, LuaValue.NIL, event); } } @@ -175,7 +175,7 @@ public class EventListener implements Listener { for (Player player : Bukkit.getOnlinePlayers()) { if(!Permission.BUILD.hasPermission(player)) continue; - if (tntRegion.inRegion(player.getLocation())) { + if (tntRegion.getArea().inRegion(player.getLocation(), false)) { ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplode, table, event); if (inBuild) { ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplodeInBuild, table, event); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java index 8ac94d2d..08ab82d8 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java @@ -85,8 +85,8 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE Set hiddenBlocks = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlocks"))); Set hiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities"))); - TechHider current = new TechHider((TechHider.LocationEvaluator) (p, cX, cY) -> { - if (rg.buildChunkOutside(cX, cY)) return true; + TechHider current = new TechHider((p, cX, cY) -> { + if (rg.getBuildArea().isChunkOutside(cX, cY)) return true; return !hidden.get(rg).contains(p); }, Material.valueOf(obfuscateWith.toUpperCase()), hiddenBlocks.stream().map(String::toUpperCase).map(Material::valueOf).collect(Collectors.toSet()), hiddenBlockEntities); current.enable(); @@ -105,7 +105,7 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE hidden.get(region).add(player); BauSystem.MESSAGE.sendPrefixless("TECHHIDER_ON", player, ChatMessageType.ACTION_BAR); } - region.forEachChunk((x, z) -> { + region.getBuildArea().forEachChunk((x, z) -> { CraftbukkitWrapper.impl.sendChunk(player, x, z); }); } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java index b461939f..d82448a0 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java @@ -62,7 +62,7 @@ public class KillAllCommand extends SWCommand { WORLD.getEntities() .stream() .filter(e -> !(e instanceof Player)) - .filter(e -> region.inRegion(e.getLocation())) + .filter(e -> region.getArea().inRegion(e.getLocation(), false)) .forEach(entity -> { entity.remove(); count.incrementAndGet(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java index 38aa4039..b53f48c8 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java @@ -1,6 +1,7 @@ package de.steamwar.bausystem.features.world; import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.flags.ColorMode; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.linkage.Linked; @@ -101,8 +102,8 @@ public class BauScoreboard implements Listener { Region region = Region.getRegion(player.getLocation()); if (region.getType().isGlobal()) return "§eSteam§8War"; String colorCode = "§e"; - if (region.hasFlag(Flag.COLOR).isReadable()) { - colorCode = "§" + region.getFlag(Flag.COLOR).get().getColor().getColorCode(); + if (region.getFlags().has(Flag.COLOR).isReadable()) { + colorCode = "§" + region.getFlags().get(Flag.COLOR).orElse(ColorMode.PINK).getColorCode(); } return colorCode + "■ §eSteam§8War " + colorCode + "■"; // ■ } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java index b18c54d7..c077d839 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java @@ -103,7 +103,7 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen hidden.get(region).add(player); BauSystem.MESSAGE.sendPrefixless("XRAY_ON", player, ChatMessageType.ACTION_BAR); } - region.forEachChunk((x, z) -> { + region.getBuildArea().forEachChunk((x, z) -> { CraftbukkitWrapper.impl.sendChunk(player, x, z); }); } @@ -149,7 +149,7 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen private TechHider createXray(Region rg, Set obfuscate) { TechHider current = new TechHider((TechHider.LocationEvaluator) (p, cX, cY) -> { - if (rg.buildChunkOutside(cX, cY)) return true; + if (rg.getBuildArea().isChunkOutside(cX, cY)) return true; return !hidden.get(rg).contains(p); }, Material.STRUCTURE_VOID, obfuscate, new HashSet<>()); current.enable(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Point.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Point.java index 3dad7a51..da8b68c5 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Point.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Point.java @@ -34,6 +34,8 @@ import org.bukkit.entity.Player; @AllArgsConstructor public class Point { + public static final Point ZERO = new Point(0, 0, 0); + private final int x; private final int y; private final int z; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java index d28430a2..447a4fd5 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -46,9 +46,9 @@ public interface Region { Area getArea(); - Optional getBuildArea(); + Area getBuildArea(); - Optional getTestblockArea(); + Area getTestblockArea(); Optional getGameModeConfig(); @@ -56,6 +56,55 @@ public interface Region { interface Area { + Area EMPTY = new Area() { + @Override + public boolean isEmpty() { + return true; + } + + @Override + public Point getMinPoint(boolean extension) { + return Point.ZERO; + } + + @Override + public Point getMaxPoint(boolean extension) { + return Point.ZERO; + } + + @Override + public Point getCopyPoint() { + return Point.ZERO; + } + + @Override + public boolean inRegion(Location location, boolean extension) { + return false; + } + + @Override + public EditSession copy(boolean extension) { + return null; + } + + @Override + public void reset(@Nullable SchematicNode schematicNode, boolean extension) { + } + + @Override + public void forEachChunk(BiConsumer executor) { + } + + @Override + public boolean isChunkOutside(int chunkX, int chunkZ) { + return false; + } + }; + + default boolean isEmpty() { + return false; + } + Point getMinPoint(boolean extension); Point getMaxPoint(boolean extension); From a6b703b8214d7c98f56bca991d07de71173549b3 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 11 Jul 2025 21:54:27 +0200 Subject: [PATCH 18/56] Fix some more issues --- .../features/region/FireListener.java | 8 +- .../features/region/TNTListener.java | 7 +- .../features/script/lua/libs/RegionLib.java | 14 +-- .../features/techhider/TechHiderCommand.java | 2 +- .../bausystem/features/xray/XrayCommand.java | 2 +- .../bausystem/region/FlagOptional.java | 97 +++++++++++++++++++ .../bausystem/region/FlagStorage.java | 4 +- .../bausystem/region/utils/RegionType.java | 16 +-- 8 files changed, 122 insertions(+), 28 deletions(-) create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagOptional.java diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireListener.java index 840356d4..7c65f00d 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireListener.java @@ -17,12 +17,12 @@ public class FireListener implements Listener, ScoreboardElement { @EventHandler public void onFireDamage(BlockBurnEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FIRE, FireMode.DENY)) e.setCancelled(true); + if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FIRE).isWithDefault(FireMode.DENY)) e.setCancelled(true); } @EventHandler public void onFireSpread(BlockSpreadEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FIRE, FireMode.DENY)) e.setCancelled(true); + if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FIRE).isWithDefault(FireMode.DENY)) e.setCancelled(true); } @Override @@ -37,7 +37,7 @@ public class FireListener implements Listener, ScoreboardElement { @Override public String get(Region region, Player p) { - if (region.isFlag(Flag.FIRE, Flag.FIRE.getDefaultValue(), true)) return null; - return "§e" + BauSystem.MESSAGE.parse(Flag.FIRE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlag(Flag.FIRE).get().getChatValue(), p); + if (region.getFlags().get(Flag.FIRE).isWithDefault(FireMode.DENY)) return null; + return "§e" + BauSystem.MESSAGE.parse(Flag.FIRE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.FIRE).getWithDefault().getChatValue(), p); } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java index 6b1e899c..791a9cb1 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java @@ -42,8 +42,7 @@ public class TNTListener implements Listener, ScoreboardElement { private void explode(List blockList) { blockList.removeIf(block -> { Region region = Region.getRegion(block.getLocation()); - if (!region.hasFlag(Flag.TNT).isReadable()) return false; - TNTMode value = region.getFlag(Flag.TNT).get(); + TNTMode value = region.getFlags().get(Flag.TNT).getWithDefault(); if (value == TNTMode.ALLOW) { return false; } else if (value == TNTMode.ONLY_TB) { @@ -83,7 +82,7 @@ public class TNTListener implements Listener, ScoreboardElement { @Override public String get(Region region, Player p) { - if (!region.hasFlag(Flag.TNT).isReadable()) return null; - return "§e" + BauSystem.MESSAGE.parse(Flag.TNT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlag(Flag.TNT).get().getChatValue(), p); + if (region.getFlags().get(Flag.TNT).isWithDefault(TNTMode.ALLOW)) return null; + return "§e" + BauSystem.MESSAGE.parse(Flag.TNT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.TNT).getWithDefault().getChatValue(), p); } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/RegionLib.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/RegionLib.java index 18b8760a..52c97c21 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/RegionLib.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/RegionLib.java @@ -54,15 +54,15 @@ public class RegionLib implements LuaLib { })); LuaValue tntLib = LuaValue.tableOf(); - tntLib.set("mode", getter(() -> region.get().getFlag(Flag.TNT).get().name())); - tntLib.set("enabled", getter(() -> region.get().getFlag(Flag.TNT).get() != TNTMode.DENY)); - tntLib.set("onlyTb", getter(() -> region.get().getFlag(Flag.TNT).get() == TNTMode.ONLY_TB)); - tntLib.set("onlyBuild", getter(() -> region.get().getFlag(Flag.TNT).get() == TNTMode.ONLY_BUILD)); + tntLib.set("mode", getter(() -> region.get().getFlags().get(Flag.TNT).nameWithDefault())); + tntLib.set("enabled", getter(() -> region.get().getFlags().get(Flag.TNT).orElse(null) != TNTMode.DENY)); + tntLib.set("onlyTb", getter(() -> region.get().getFlags().get(Flag.TNT).orElse(null) == TNTMode.ONLY_TB)); + tntLib.set("onlyBuild", getter(() -> region.get().getFlags().get(Flag.TNT).orElse(null) == TNTMode.ONLY_BUILD)); table.set("tnt", tntLib); - table.set("fire", getter(() -> region.get().getFlag(Flag.FIRE).get() == FireMode.ALLOW)); - table.set("freeze", getter(() -> region.get().getFlag(Flag.FREEZE).get() == FreezeMode.ACTIVE)); - table.set("protect", getter(() -> region.get().getFlag(Flag.PROTECT).get() == ProtectMode.ACTIVE)); + table.set("fire", getter(() -> region.get().getFlags().get(Flag.FIRE).orElse(null) == FireMode.ALLOW)); + table.set("freeze", getter(() -> region.get().getFlags().get(Flag.FREEZE).orElse(null) == FreezeMode.ACTIVE)); + table.set("protect", getter(() -> region.get().getFlags().get(Flag.PROTECT).orElse(null) == ProtectMode.ACTIVE)); //LuaValue traceLib = LuaValue.tableOf(); //traceLib.set("active", getter(() -> !region.get().isGlobal() && Recorder.INSTANCE.get(region.get()) instanceof ActiveTracer)); 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 08ab82d8..e3510306 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 @@ -69,7 +69,7 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE } Optional techHider = techHiders.computeIfAbsent(region, rg -> { - File file = rg.gameModeConfig(); + File file = rg.getGameModeConfig().orElse(null); if (file == null) { return Optional.empty(); } 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 c077d839..547e31d9 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 @@ -70,7 +70,7 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen } Optional techHider = techHiders.computeIfAbsent(region, rg -> { - File file = rg.gameModeConfig(); + File file = rg.getGameModeConfig().orElse(null); if (file == null) { return Optional.empty(); } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagOptional.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagOptional.java new file mode 100644 index 00000000..eb0bb0af --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagOptional.java @@ -0,0 +1,97 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 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.Flag; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; + +import java.util.NoSuchElementException; +import java.util.Optional; + +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class FlagOptional & Flag.Value> { + + private final Flag flag; + private final T value; + + public static & Flag.Value> FlagOptional of(Flag flag) { + return new FlagOptional<>(flag, null); + } + + public static & Flag.Value> FlagOptional of(Flag flag, T value) { + return new FlagOptional<>(flag, value); + } + + public boolean isPresent() { + return value != null; + } + + public boolean isEmpty() { + return value == null; + } + + public boolean is(T value) { + if (isEmpty()) return false; + return this.value.equals(value); + } + + public boolean isWithDefault(T value) { + if (isEmpty()) { + return flag.getDefaultValue().equals(value); + } else { + return this.value.equals(value); + } + } + + public T get() { + if (isEmpty()) { + throw new NoSuchElementException("No value present"); + } + return value; + } + + public T getWithDefault() { + if (isEmpty()) { + return flag.getDefaultValue(); + } else { + return value; + } + } + + public T orElse(T defaultValue) { + if (isEmpty()) { + return defaultValue; + } else { + return value; + } + } + + public Optional name() { + if (isEmpty()) { + return Optional.empty(); + } + return Optional.of(value.name()); + } + + public String nameWithDefault() { + return getWithDefault().name(); + } +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java index 1c8048b6..922e1ab2 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java @@ -21,13 +21,11 @@ package de.steamwar.bausystem.region; import de.steamwar.bausystem.region.flags.Flag; -import java.util.Optional; - public interface FlagStorage { & Flag.Value> RegionFlagPolicy has(Flag flag); & Flag.Value> boolean set(Flag flag, T value); - & Flag.Value> Optional get(Flag flag); + & Flag.Value> FlagOptional get(Flag flag); } 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 index 1ea7e577..27412cec 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionType.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionType.java @@ -19,15 +19,15 @@ public enum RegionType implements EnumDisplay { (region, extension) -> region.getArea().getMinPoint(false), (region, extension) -> region.getArea().getMaxPoint(false)), BUILD("REGION_TYPE_BUILD", - region -> region.getBuildArea().isPresent(), - region -> region.getBuildArea().get(), - (region, extension) -> region.getBuildArea().get().getMinPoint(extension), - (region, extension) -> region.getBuildArea().get().getMaxPoint(extension)), + region -> !region.getBuildArea().isEmpty(), + Region::getBuildArea, + (region, extension) -> region.getBuildArea().getMinPoint(extension), + (region, extension) -> region.getBuildArea().getMaxPoint(extension)), TESTBLOCK("REGION_TYPE_ONLY_TB", - region -> region.getTestblockArea().isPresent(), - region -> region.getTestblockArea().get(), - (region, extension) -> region.getTestblockArea().get().getMinPoint(extension), - (region, extension) -> region.getTestblockArea().get().getMaxPoint(extension)), + region -> !region.getTestblockArea().isEmpty(), + Region::getTestblockArea, + (region, extension) -> region.getTestblockArea().getMinPoint(extension), + (region, extension) -> region.getTestblockArea().getMaxPoint(extension)), ; private String chatValue; From 0287881e33ee27a82c913d9ba8e17ea05db1ff4f Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sat, 12 Jul 2025 18:17:46 +0200 Subject: [PATCH 19/56] Fix some more issues --- .../features/region/FireCommand.java | 6 +-- .../features/region/FreezeCommand.java | 6 +-- .../features/region/FreezeListener.java | 42 +++++++++---------- .../features/region/ItemsListener.java | 6 +-- .../features/region/NoGravityCommand.java | 6 +-- .../features/region/NoGravityListener.java | 6 +-- .../features/region/ProtectCommand.java | 8 ++-- .../features/region/ProtectListener.java | 6 +-- .../features/region/RegionListener.java | 2 +- .../bausystem/features/region/TNTCommand.java | 20 ++++----- .../bausystem/region/FlagOptional.java | 8 ++++ 11 files changed, 62 insertions(+), 54 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireCommand.java index c7372eb3..e694f19a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireCommand.java @@ -53,11 +53,11 @@ public class FireCommand extends SWCommand { } private boolean toggle(Region region) { - if (region.isFlag(Flag.FIRE, FireMode.ALLOW)) { - region.setFlag(Flag.FIRE, FireMode.DENY); + if (region.getFlags().get(Flag.FIRE).isWithDefault(FireMode.ALLOW)) { + region.getFlags().set(Flag.FIRE, FireMode.DENY); return true; } else { - region.setFlag(Flag.FIRE, FireMode.ALLOW); + region.getFlags().set(Flag.FIRE, FireMode.ALLOW); return false; } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeCommand.java index aee10390..ceba317d 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeCommand.java @@ -53,11 +53,11 @@ public class FreezeCommand extends SWCommand { } private boolean toggle(Region region) { - if (region.isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { - region.setFlag(Flag.FREEZE, FreezeMode.INACTIVE); + if (region.getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) { + region.getFlags().set(Flag.FREEZE, FreezeMode.INACTIVE); return false; } else { - region.setFlag(Flag.FREEZE, FreezeMode.ACTIVE); + region.getFlags().set(Flag.FREEZE, FreezeMode.ACTIVE); return true; } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java index d0b63900..c83b1561 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java @@ -29,7 +29,7 @@ public class FreezeListener implements Listener, ScoreboardElement { @EventHandler public void onEntitySpawn(EntitySpawnEvent e) { - if (Region.getRegion(e.getLocation()).isFlag(Flag.FREEZE, FreezeMode.INACTIVE, true)) return; + if (Region.getRegion(e.getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return; e.setCancelled(true); if (e.getEntityType() == TrickyTrialsWrapper.impl.getTntEntityType()) { Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { @@ -41,7 +41,7 @@ public class FreezeListener implements Listener, ScoreboardElement { @EventHandler public void onBlockCanBuild(BlockCanBuildEvent e) { if (!e.isBuildable()) return; - if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.INACTIVE, true)) return; + if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return; if (e.getMaterial() == Material.TNT) { e.setBuildable(false); e.getBlock().setType(Material.TNT, false); @@ -50,14 +50,14 @@ public class FreezeListener implements Listener, ScoreboardElement { @EventHandler public void onEntityChangeBlock(EntityChangeBlockEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { + if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) { e.setCancelled(true); } } @EventHandler public void onPhysicsEvent(BlockPhysicsEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { + if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) { if (e.getSourceBlock().getType() == Material.NOTE_BLOCK) { BlockState state = e.getSourceBlock().getState(); NoteBlock noteBlock = (NoteBlock) state.getBlockData(); @@ -82,44 +82,44 @@ public class FreezeListener implements Listener, ScoreboardElement { @EventHandler public void onPistonExtend(BlockPistonExtendEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { + if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) { e.setCancelled(true); } } @EventHandler public void onPistonRetract(BlockPistonRetractEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { + if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) { e.setCancelled(true); } } @EventHandler public void onBlockGrow(BlockGrowEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { + if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) { e.setCancelled(true); } } @EventHandler public void onRedstoneEvent(BlockRedstoneEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { + if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) { e.setNewCurrent(e.getOldCurrent()); } } @EventHandler public void onBlockDispense(BlockDispenseEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { + if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) { e.setCancelled(true); } } @EventHandler public void onInventoryMoveEvent(InventoryMoveItemEvent e) { - if (e.getDestination().getLocation() != null && Region.getRegion(e.getDestination().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { + if (e.getDestination().getLocation() != null && Region.getRegion(e.getDestination().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) { e.setCancelled(true); - } else if (e.getSource().getLocation() != null && Region.getRegion(e.getSource().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { + } else if (e.getSource().getLocation() != null && Region.getRegion(e.getSource().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) { e.setCancelled(true); } } @@ -128,7 +128,7 @@ public class FreezeListener implements Listener, ScoreboardElement { public void onBlockBreak(BlockBreakEvent e) { if (Core.getVersion() < 19) return; if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return; - if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { + if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) { e.setCancelled(true); e.getBlock().setType(Material.BARRIER, false); e.getBlock().setType(Material.AIR, false); @@ -151,35 +151,35 @@ public class FreezeListener implements Listener, ScoreboardElement { @EventHandler public void onFluidLevelChange(FluidLevelChangeEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { + if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) { e.setCancelled(true); } } @EventHandler public void onBlockSpread(BlockSpreadEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { + if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) { e.setCancelled(true); } } @EventHandler public void onBlockFromTo(BlockFromToEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { + if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) { e.setCancelled(true); } } @EventHandler public void onSpongeAbsorb(SpongeAbsorbEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { + if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) { e.setCancelled(true); } } @EventHandler public void onBlockForm(BlockFormEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { + if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) { e.setCancelled(true); } } @@ -187,7 +187,7 @@ public class FreezeListener implements Listener, ScoreboardElement { @EventHandler public void onPlayerInteract(PlayerInteractEvent e) { if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return; - if (Region.getRegion(e.getClickedBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { + if (Region.getRegion(e.getClickedBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) { Block block = e.getClickedBlock(); if (block.getType() == Material.LEVER) { Switch data = ((Switch) block.getBlockData()); @@ -199,7 +199,7 @@ public class FreezeListener implements Listener, ScoreboardElement { @EventHandler public void onBlockFade(BlockFadeEvent e) { - if (Region.getRegion(e.getBlock().getLocation()).isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { + if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) { e.setCancelled(true); } } @@ -216,7 +216,7 @@ public class FreezeListener implements Listener, ScoreboardElement { @Override public String get(Region region, Player p) { - if (region.isFlag(Flag.FREEZE, Flag.FREEZE.getDefaultValue(), true)) return null; - return "§e" + BauSystem.MESSAGE.parse(Flag.FREEZE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlag(Flag.FREEZE).get().getChatValue(), p); + if (region.getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return null; + return "§e" + BauSystem.MESSAGE.parse(Flag.FREEZE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.FREEZE).getWithDefault().getChatValue(), p); } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsListener.java index b673bb93..47fd27c8 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsListener.java @@ -37,7 +37,7 @@ public class ItemsListener implements Listener, ScoreboardElement { @EventHandler public void onItemSpawn(ItemSpawnEvent event) { - if (Region.getRegion(event.getLocation()).isFlag(Flag.ITEMS, ItemMode.INACTIVE, true)) { + if (Region.getRegion(event.getLocation()).getFlags().get(Flag.ITEMS).isWithDefault(ItemMode.INACTIVE)) { event.setCancelled(true); } } @@ -54,7 +54,7 @@ public class ItemsListener implements Listener, ScoreboardElement { @Override public String get(Region region, Player p) { - if (region.isFlag(Flag.ITEMS, Flag.ITEMS.getDefaultValue(), true)) return null; - return "§e" + BauSystem.MESSAGE.parse(Flag.ITEMS.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlag(Flag.ITEMS).get().getChatValue(), p); + if (region.getFlags().get(Flag.ITEMS).isWithDefault(ItemMode.INACTIVE)) return null; + return "§e" + BauSystem.MESSAGE.parse(Flag.ITEMS.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.ITEMS).getWithDefault().getChatValue(), p); } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/NoGravityCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/NoGravityCommand.java index 3d3b6b61..6ef0b428 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/NoGravityCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/NoGravityCommand.java @@ -53,11 +53,11 @@ public class NoGravityCommand extends SWCommand { } private boolean toggle(Region region) { - if (region.isFlag(Flag.NO_GRAVITY, NoGravityMode.ACTIVE)) { - region.setFlag(Flag.NO_GRAVITY, NoGravityMode.INACTIVE); + if (region.getFlags().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.ACTIVE)) { + region.getFlags().set(Flag.NO_GRAVITY, NoGravityMode.INACTIVE); return false; } else { - region.setFlag(Flag.NO_GRAVITY, NoGravityMode.ACTIVE); + region.getFlags().set(Flag.NO_GRAVITY, NoGravityMode.ACTIVE); return true; } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/NoGravityListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/NoGravityListener.java index e69b8225..f874fb41 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/NoGravityListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/NoGravityListener.java @@ -37,7 +37,7 @@ public class NoGravityListener implements Listener, ScoreboardElement { @EventHandler public void onEntitySpawn(EntitySpawnEvent event) { if (event.getEntityType() == EntityType.PLAYER) return; - if (Region.getRegion(event.getLocation()).isFlag(Flag.NO_GRAVITY, NoGravityMode.ACTIVE)) { + if (Region.getRegion(event.getLocation()).getFlags().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.ACTIVE)) { event.getEntity().setGravity(false); } } @@ -54,7 +54,7 @@ public class NoGravityListener implements Listener, ScoreboardElement { @Override public String get(Region region, Player p) { - if (region.isFlag(Flag.NO_GRAVITY, Flag.NO_GRAVITY.getDefaultValue(), true)) return null; - return "§e" + BauSystem.MESSAGE.parse(Flag.NO_GRAVITY.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlag(Flag.NO_GRAVITY).get().getChatValue(), p); + if (region.getFlags().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.INACTIVE)) return null; + return "§e" + BauSystem.MESSAGE.parse(Flag.NO_GRAVITY.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.NO_GRAVITY).getWithDefault().getChatValue(), p); } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectCommand.java index 04383c38..a390bddd 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectCommand.java @@ -39,18 +39,18 @@ public class ProtectCommand extends SWCommand { public void genericProtectCommand(@Validator Player p) { Region region = regionCheck(p); if (region == null) return; - if (region.isFlag(Flag.PROTECT, ProtectMode.ACTIVE)) { - region.setFlag(Flag.PROTECT, ProtectMode.INACTIVE); + if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.ACTIVE)) { + region.getFlags().set(Flag.PROTECT, ProtectMode.INACTIVE); RegionUtils.actionBar(region, "REGION_PROTECT_DISABLE"); } else { - region.setFlag(Flag.PROTECT, ProtectMode.ACTIVE); + region.getFlags().set(Flag.PROTECT, ProtectMode.ACTIVE); RegionUtils.actionBar(region, "REGION_PROTECT_ENABLE"); } } private Region regionCheck(Player player) { Region region = Region.getRegion(player.getLocation()); - if (!region.hasFlag(Flag.PROTECT).isApplicable()) { + if (!region.getFlags().has(Flag.PROTECT).isApplicable()) { BauSystem.MESSAGE.send("REGION_PROTECT_FALSE_REGION", player); return null; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectListener.java index b90aa779..2abe5569 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectListener.java @@ -22,7 +22,7 @@ public class ProtectListener implements Listener, ScoreboardElement { private void explode(List blockList, Location location) { Region region = Region.getRegion(location); - if (region.isFlag(Flag.PROTECT, ProtectMode.INACTIVE)) return; + if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.INACTIVE)) return; Point p1 = region.getBuildArea().getMinPoint(true); Point p2 = region.getTestblockArea().getMinPoint(true); int floorLevel = Math.min(p1.getY(), p2.getY()); @@ -51,7 +51,7 @@ public class ProtectListener implements Listener, ScoreboardElement { @Override public String get(Region region, Player p) { - if (region.isFlag(Flag.PROTECT, Flag.PROTECT.getDefaultValue(), true)) return null; - return "§e" + BauSystem.MESSAGE.parse(Flag.PROTECT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlag(Flag.PROTECT).get().getChatValue(), p); + if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.INACTIVE)) return null; + return "§e" + BauSystem.MESSAGE.parse(Flag.PROTECT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.PROTECT).getWithDefault().getChatValue(), p); } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionListener.java index 990c3379..78c917c1 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionListener.java @@ -186,7 +186,7 @@ public class RegionListener implements Listener { new BukkitRunnable() { @Override public void run() { - Region.getRegion(location).setFlag(Flag.CHANGED, ChangedMode.HAS_CHANGE); + Region.getRegion(location).getFlags().set(Flag.CHANGED, ChangedMode.HAS_CHANGE); } }.runTaskAsynchronously(BauSystem.getInstance()); } 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 3c862f4f..df5bd796 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 @@ -24,7 +24,7 @@ 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.TNTMode; -import de.steamwar.bausystem.region.utils.RegionType; +import de.steamwar.bausystem.region.flags.TestblockMode; import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; @@ -96,7 +96,7 @@ public class TNTCommand extends SWCommand { @Override public List tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) { Region region = Region.getRegion(((Player) sender).getLocation()); - if (region.hasType(RegionType.TESTBLOCK) && region.hasType(RegionType.BUILD)) { + if (region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) { return new ArrayList<>(tntModeMap.keySet()); } else { return new ArrayList<>(tntModeMapReduced.keySet()); @@ -106,7 +106,7 @@ public class TNTCommand extends SWCommand { @Override public TNTMode map(CommandSender sender, PreviousArguments previousArguments, String s) { Region region = Region.getRegion(((Player) sender).getLocation()); - if (region.hasType(RegionType.TESTBLOCK) && region.hasType(RegionType.BUILD)) { + if (region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) { return tntModeMap.getOrDefault(s, null); } else { return tntModeMapReduced.getOrDefault(s, null); @@ -132,24 +132,24 @@ public class TNTCommand extends SWCommand { } private void tntToggle(Region region, TNTMode requestedMode, String requestedMessage) { - if (requestedMode != null && region.hasType(RegionType.TESTBLOCK) && region.hasType(RegionType.BUILD)) { - region.set(Flag.TNT, requestedMode); + if (requestedMode != null && region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) { + region.getFlags().set(Flag.TNT, requestedMode); RegionUtils.actionBar(region, requestedMessage); return; } - switch (region.getPlain(Flag.TNT, TNTMode.class)) { + switch (region.getFlags().get(Flag.TNT).getWithDefault()) { case ALLOW: case ONLY_TB: case ONLY_BUILD: - region.set(Flag.TNT, TNTMode.DENY); + region.getFlags().set(Flag.TNT, TNTMode.DENY); RegionUtils.actionBar(region, getDisableMessage()); break; case DENY: - if (region.hasType(RegionType.TESTBLOCK) && region.hasType(RegionType.BUILD)) { - region.set(Flag.TNT, TNTMode.ONLY_TB); + if (region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) { + region.getFlags().set(Flag.TNT, TNTMode.ONLY_TB); RegionUtils.actionBar(region, getTestblockEnableMessage()); } else { - region.set(Flag.TNT, TNTMode.ALLOW); + region.getFlags().set(Flag.TNT, TNTMode.ALLOW); RegionUtils.actionBar(region, getEnableMessage()); } break; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagOptional.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagOptional.java index eb0bb0af..e3e725fc 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagOptional.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagOptional.java @@ -53,6 +53,10 @@ public class FlagOptional & Flag.Value> { return this.value.equals(value); } + public boolean isNot(T value) { + return !is(value); + } + public boolean isWithDefault(T value) { if (isEmpty()) { return flag.getDefaultValue().equals(value); @@ -61,6 +65,10 @@ public class FlagOptional & Flag.Value> { } } + public boolean isNotWithDefault(T value) { + return !isWithDefault(value); + } + public T get() { if (isEmpty()) { throw new NoSuchElementException("No value present"); From 598daadd3394caf04f2482169a1f6eea17923e80 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Wed, 30 Jul 2025 18:49:54 +0200 Subject: [PATCH 20/56] 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 b50ab2fa..5cc4b744 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); From fb518efe63dedf0f0330b57b3d47564c22d98c58 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Wed, 30 Jul 2025 20:37:52 +0200 Subject: [PATCH 21/56] Reduce to 24 compiler errors --- .../features/backup/BackupCommand.java | 69 +++++++++---------- .../region/RegionScoreboardElement.java | 5 +- .../features/region/ResetCommand.java | 2 +- .../bausystem/features/team/SkinCommand.java | 9 ++- .../bausystem/region/BackupScheduler.java | 11 +-- .../de/steamwar/bausystem/region/Region.java | 4 ++ .../bausystem/region/RegionBackups.java | 56 +++++++++++++++ 7 files changed, 109 insertions(+), 47 deletions(-) create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionBackups.java 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 f4d610ee..b2671e84 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 @@ -19,27 +19,23 @@ 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.RegionBackups; import de.steamwar.bausystem.region.flags.ChangedMode; import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.bausystem.utils.PasteBuilder; +import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; -import de.steamwar.command.SWCommandUtils; import de.steamwar.command.TypeMapper; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; import de.steamwar.linkage.Linked; import net.md_5.bungee.api.chat.ClickEvent; import org.bukkit.Material; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; @Linked @@ -67,7 +63,8 @@ public class BackupCommand extends SWCommand { BauSystem.MESSAGE.send("BACKUP_CREATE_NO_CHANGE", p); return; } - if (region.backup(false)) { + Optional backup = region.getBackups().create(RegionBackups.BackupType.MANUAL); + if (backup.isPresent()) { BauSystem.MESSAGE.send("BACKUP_CREATE_SUCCESS", p); } else { BauSystem.MESSAGE.send("BACKUP_CREATE_FAILURE", p); @@ -75,25 +72,17 @@ public class BackupCommand extends SWCommand { } @Register(value = "load", description = "BACKUP_HELP_LOAD") - public void backupLoad(@Validator("owner") Player p, @Mapper("backupName") String backupName) { + public void backupLoad(@Validator("owner") Player p, @Mapper("backup") RegionBackups.Backup backup) { Region region = Region.getRegion(p.getLocation()); if (checkGlobalRegion(region, p)) { return; } - File backupFile = region.getBackupFile(backupName.replace('_', ' ')); - if (backupFile == null) { + if (backup.load()) { + BauSystem.MESSAGE.send("BACKUP_LOAD", p); + } else { BauSystem.MESSAGE.send("BACKUP_LOAD_FAILURE", p); - return; } - EditSession editSession = new PasteBuilder(new PasteBuilder.FileProvider(backupFile)) - .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.getHistory().remember(editSession); - BauSystem.MESSAGE.send("BACKUP_LOAD", p); } @Register(value = "list", description = "BACKUP_HELP_LIST") @@ -102,10 +91,10 @@ public class BackupCommand extends SWCommand { if (checkGlobalRegion(region, p)) { return; } - List backups = listBackup(p); + List backups = listBackup(p); BauSystem.MESSAGE.send("BACKUP_LIST_HEAD", p, backups.size()); - backups.forEach(s -> { - BauSystem.MESSAGE.send("BACKUP_LIST_ENTRY", p, "/backup load " + s, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/backup load " + s), s); + backups.forEach(backup -> { + BauSystem.MESSAGE.send("BACKUP_LIST_ENTRY", p, "/backup load " + backup.getName(), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/backup load " + backup.getName()), backup.getName()); }); } @@ -115,34 +104,44 @@ public class BackupCommand extends SWCommand { if (checkGlobalRegion(region, p)) { return; } - List backups = listBackup(p); - List> swListEntries = new ArrayList<>(); + List backups = listBackup(p); + List> swListEntries = new ArrayList<>(); List lore = Arrays.asList(BauSystem.MESSAGE.parse("BACKUP_LORE", p)); for (int i = 0; i < backups.size(); i++) { - String s = backups.get(i); - SWItem swItem = new SWItem(Material.BRICK, BauSystem.MESSAGE.parse("BACKUP_ITEM_NAME", p, s), lore, false, clickType -> {}); + RegionBackups.Backup backup = backups.get(i); + SWItem swItem = new SWItem(Material.BRICK, BauSystem.MESSAGE.parse("BACKUP_ITEM_NAME", p, backup.getName()), lore, false, clickType -> {}); swItem.getItemStack().setAmount(i + 1); - swListEntries.add(new SWListInv.SWListEntry<>(swItem, s)); + swListEntries.add(new SWListInv.SWListEntry<>(swItem, backup)); } - SWListInv swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("BACKUP_INV_NAME", p), swListEntries, (clickType, s) -> { + SWListInv swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("BACKUP_INV_NAME", p), swListEntries, (clickType, s) -> { p.getOpenInventory().close(); p.performCommand("backup load " + s); }); swListInv.open(); } - @Mapper(value = "backupName", local = true) - public TypeMapper backupMapper() { - return SWCommandUtils.createMapper(s -> s, (commandSender, s) -> listBackup((Player) commandSender)); + @Mapper(value = "backup", local = true) + public TypeMapper backupMapper() { + return new TypeMapper() { + @Override + public RegionBackups.Backup map(CommandSender commandSender, String[] previousArguments, String s) { + return Region.getRegion(((Player) commandSender).getLocation()).getBackups().get(s); + } + + @Override + public Collection tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) { + return listBackup((Player) sender).stream().map(RegionBackups.Backup::getName).collect(Collectors.toList()); + } + }; } - private List listBackup(Player p) { + private List listBackup(Player p) { Region region = Region.getRegion(p.getLocation()); if (checkGlobalRegion(region, p)) { return Collections.emptyList(); } try { - return region.listBackup().stream().map(s -> s.substring(0, s.length() - 6).replace(' ', '_')).collect(Collectors.toList()); + return region.getBackups().list(); } catch (NullPointerException e) { return Collections.emptyList(); } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java index 7ad6dea1..2e25bafe 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.region; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.linkage.Linked; @@ -40,8 +41,6 @@ public class RegionScoreboardElement implements ScoreboardElement { @Override public String get(Region region, Player p) { if (region.getType().isGlobal()) return null; - // TODO: Fix this! - // return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + region.getName(); - return null; + return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + region.getName(); } } 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 e494ac7d..28f10595 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 @@ -57,7 +57,7 @@ public class ResetCommand extends SWCommand { PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL))) .color(region.getFlags().get(Flag.COLOR).getWithDefault()); region.getArea().reset(pasteBuilder, false); - for (Flag value : Flag.getResetFlags()) { + for (Flag value : Flag.getFlags()) { region.getFlags().set(value, value.getDefaultValue()); } RegionUtils.message(region, "REGION_RESET_RESETED"); 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 b2c2bc8c..b97127b1 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 @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.team; +import com.sk89q.worldedit.EditSession; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.team.boundary.BoundaryViewer; import de.steamwar.bausystem.region.Region; @@ -74,7 +75,7 @@ public class SkinCommand extends SWCommand { String name = String.join(" ", names); File arenaFile = new File("sections19/" + name + "/" + typeKuerzel + "Arena.schem"); - File testblockFile = region.getTestblockArea().isPresent() ? new File("sections19/" + name + "/" + typeKuerzel + "Testblock.schem") : null; + File testblockFile = !region.getTestblockArea().isEmpty() ? new File("sections19/" + name + "/" + typeKuerzel + "Testblock.schem") : null; arenaFile.getParentFile().mkdirs(); if (testblockFile != null) { @@ -89,9 +90,11 @@ public class SkinCommand extends SWCommand { return; } - Region.copy(region.getArea().getMinPoint(false), region.getArea().getMaxPoint(false), arenaFile); + EditSession editSession = region.getArea().copy(false); + // TODO: Save editSession to file if (testblockFile != null) { - Region.copy(region.getTestblockArea().getMinPoint(false), region.getTestblockArea().getMaxPoint(false), testblockFile); + editSession = region.getTestblockArea().copy(false); + // TODO: Save editSession to file } YAPIONObject yapionObject = new YAPIONObject(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java index 512c0199..902d4a6c 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java @@ -1,6 +1,5 @@ package de.steamwar.bausystem.region; -import com.sk89q.worldedit.EditSession; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.flags.ChangedMode; import de.steamwar.bausystem.region.flags.Flag; @@ -9,6 +8,7 @@ import de.steamwar.linkage.api.Enable; import org.bukkit.scheduler.BukkitRunnable; import java.util.Iterator; +import java.util.Optional; @Linked public class BackupScheduler implements Enable { @@ -41,10 +41,11 @@ public class BackupScheduler implements Enable { } Region region = regionsToBackup.next(); - EditSession editSession = region.getArea() - .copy(false); - // TODO: Implement saving EditSession to schematic! - region.getFlags().set(Flag.CHANGED, ChangedMode.NO_CHANGE); + Optional backup = region.getBackups() + .create(RegionBackups.BackupType.AUTOMATIC); + if (backup.isPresent()) { + region.getFlags().set(Flag.CHANGED, ChangedMode.NO_CHANGE); + } } }.runTaskTimer(BauSystem.getInstance(), 0, 20 * 60); } 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 e2d37c2a..a41f6593 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -35,9 +35,11 @@ public interface Region { static Stream getRegions() { return RegionSystem.INSTANCE.getRegions(); } + static Region getRegion(Location location) { return RegionSystem.INSTANCE.get(location); } + static Region getGlobalRegion() { return RegionSystem.INSTANCE.getGlobalRegion(); } @@ -58,6 +60,8 @@ public interface Region { RegionHistory getHistory(); + RegionBackups getBackups(); + interface Area { Area EMPTY = new Area() { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionBackups.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionBackups.java new file mode 100644 index 00000000..af4bf23b --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionBackups.java @@ -0,0 +1,56 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 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 lombok.Getter; +import lombok.RequiredArgsConstructor; + +import java.util.List; +import java.util.Optional; + +public interface RegionBackups { + + @RequiredArgsConstructor + enum BackupType { + MANUAL(5), + AUTOMATIC(20), + ; + + private final int maxBackups; + } + + @RequiredArgsConstructor + @Getter + abstract class Backup { + private final BackupType type; + private final String name; + private final FlagStorage flags; + + public abstract boolean load(); + + public abstract void delete(); + } + + Optional create(BackupType backupType); + + List list(); + + Backup get(String name); +} From 8fb10c92664445edef483cabc6f3391634f6100b Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 31 Jul 2025 10:25:45 +0200 Subject: [PATCH 22/56] Fix DesignEndStone and DesignEndStoneCommand Fix Region.Area.reset --- .../design/endstone/DesignEndStone.java | 28 ++++++++++++------- .../endstone/DesignEndStoneCommand.java | 4 +++ .../de/steamwar/bausystem/region/Region.java | 7 ++--- 3 files changed, 25 insertions(+), 14 deletions(-) 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 3b7645b6..35437be8 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 @@ -29,12 +29,10 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; +import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; public class DesignEndStone { @@ -44,8 +42,8 @@ public class DesignEndStone { private REntityServer entityServer = new REntityServer(); private List entities = new ArrayList<>(); private Set locations = new HashSet<>(); - private boolean wsOrAs; - private double maxBlastResistance; + private Set limited = new HashSet<>(); + private boolean calculateFromBottom; public DesignEndStone(Region region) { this.minX = region.getBuildArea().getMinPoint(false).getX(); @@ -54,8 +52,18 @@ public class DesignEndStone { 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; + + YamlConfiguration config = YamlConfiguration.loadConfiguration(region.getGameModeConfig().get()); + for(Map entry : config.getMapList("Schematic.Limited")) { + int amount = (Integer) entry.get("Amount"); + Set materials = new HashSet<>((List) entry.get("Materials")); + if(amount == 0) { + materials.forEach(s -> { + limited.add(Material.getMaterial(s)); + }); + } + } + calculateFromBottom = config.getBoolean("Arena.NoFloor", false); entityServer.setCallback((player, rEntity, entityAction) -> { if (entityAction != REntityServer.EntityAction.ATTACK) return; @@ -76,7 +84,7 @@ public class DesignEndStone { calc(minX, minY, maxZ, maxX, maxY, maxZ, 0, 0, -1, maxZ - minZ); calc(minX, minY, minZ, minX, maxY, maxZ, 1, 0, 0, maxX - minX); calc(maxX, minY, minZ, maxX, maxY, maxZ, -1, 0, 0, maxX - minX); - if (wsOrAs) { + if (calculateFromBottom) { calc(minX, minY, minZ, maxX, minY, maxZ, 0, 1, 0, maxY - minY + 1); } else { int airBlocks = 0; @@ -106,7 +114,7 @@ public class DesignEndStone { int cz = z + step * dirZ; Material material = WORLD.getBlockAt(cx, cy, cz).getType(); - if (material != Material.WATER && material != Material.LAVA && material.getBlastResistance() >= maxBlastResistance) { + if (material != Material.WATER && material != Material.LAVA && limited.contains(material)) { Location location = new Location(WORLD, cx + 0.5, cy, cz + 0.5); if (!locations.add(location)) break; RFallingBlockEntity entity = new RFallingBlockEntity(entityServer, location, Material.RED_STAINED_GLASS); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java index e50541a8..61fa0278 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java @@ -52,6 +52,10 @@ public class DesignEndStoneCommand extends SWCommand implements Listener { BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player); return; } + if (region.getGameModeConfig().isEmpty()) { + BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player); + return; + } designEndStoneMap.computeIfAbsent(region, DesignEndStone::new).toggle(player); } 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 a41f6593..6c3ba0ab 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -20,10 +20,9 @@ package de.steamwar.bausystem.region; import com.sk89q.worldedit.EditSession; -import de.steamwar.sql.SchematicNode; +import de.steamwar.bausystem.utils.PasteBuilder; import org.bukkit.Location; -import javax.annotation.Nullable; import java.io.File; import java.util.Optional; import java.util.UUID; @@ -96,7 +95,7 @@ public interface Region { } @Override - public void reset(@Nullable SchematicNode schematicNode, boolean extension) { + public void reset(PasteBuilder pasteBuilder, boolean extension) { } @Override @@ -123,7 +122,7 @@ public interface Region { EditSession copy(boolean extension); - void reset(@Nullable SchematicNode schematicNode, boolean extension); + void reset(PasteBuilder pasteBuilder, boolean extension); void forEachChunk(BiConsumer executor); From 8a438093227350f236e7961a536b4dd25d7866bd Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 31 Jul 2025 10:29:02 +0200 Subject: [PATCH 23/56] Fix RegionScoreboardElement --- .../features/region/RegionScoreboardElement.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java index 2e25bafe..b843097d 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java @@ -23,8 +23,13 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.linkage.Linked; +import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; +import java.io.File; +import java.util.List; +import java.util.Optional; + @Linked public class RegionScoreboardElement implements ScoreboardElement { @@ -41,6 +46,11 @@ public class RegionScoreboardElement implements ScoreboardElement { @Override public String get(Region region, Player p) { if (region.getType().isGlobal()) return null; - return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + region.getName(); + Optional gameModeConfig = region.getGameModeConfig(); + if (gameModeConfig.isEmpty()) return null; + YamlConfiguration config = YamlConfiguration.loadConfiguration(region.getGameModeConfig().get()); + List names = config.getStringList("Server.ChatNames"); + if (names.isEmpty()) return null; + return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + names.get(0); } } From 94e3eed6df19c0d603fe69d1136ab215ca40ec2b Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 31 Jul 2025 10:29:20 +0200 Subject: [PATCH 24/56] Fix RegionScoreboardElement --- .../bausystem/features/region/RegionScoreboardElement.java | 1 + 1 file changed, 1 insertion(+) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java index b843097d..bfc3a6e4 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java @@ -46,6 +46,7 @@ public class RegionScoreboardElement implements ScoreboardElement { @Override public String get(Region region, Player p) { if (region.getType().isGlobal()) return null; + // TODO: Improve this! Optional gameModeConfig = region.getGameModeConfig(); if (gameModeConfig.isEmpty()) return null; YamlConfiguration config = YamlConfiguration.loadConfiguration(region.getGameModeConfig().get()); From 4f24adf9fd7a1f3a243418b7298d7fbcfc6100cf Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 31 Jul 2025 12:10:49 +0200 Subject: [PATCH 25/56] Fix some more errors --- .../steamwar/bausystem/features/region/ColorCommand.java | 2 +- .../steamwar/bausystem/features/region/RegionCommand.java | 2 +- .../steamwar/bausystem/features/region/ResetCommand.java | 2 +- .../bausystem/features/region/TestblockCommand.java | 2 +- .../src/de/steamwar/bausystem/region/Region.java | 7 +++++++ 5 files changed, 11 insertions(+), 4 deletions(-) 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 adcd1f97..436564ac 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 @@ -65,7 +65,7 @@ public class ColorCommand extends SWCommand { } region.getFlags().set(Flag.COLOR, color); try { - PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL))) + PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile())) .ignoreAir(true) .onlyColors(true) .color(color); 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 b1dafb65..ccf62cdb 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 @@ -108,7 +108,7 @@ public class RegionCommand extends SWCommand { if(checkGlobalRegion(region, p)) return; try { - PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL))) + PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile())) .ignoreAir(true) .color(region.getFlags().get(Flag.COLOR).getWithDefault()); region.getArea().reset(pasteBuilder, true); 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 28f10595..c8d4d19d 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 @@ -54,7 +54,7 @@ public class ResetCommand extends SWCommand { Region region = regionCheck(p); if (region == null) return; try { - PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL))) + PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile())) .color(region.getFlags().get(Flag.COLOR).getWithDefault()); region.getArea().reset(pasteBuilder, false); for (Flag value : Flag.getFlags()) { 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 ca307e6d..7e4abc4b 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 @@ -94,7 +94,7 @@ public class TestblockCommand extends SWCommand { } try { - PasteBuilder.ClipboardProvider clipboardProvider = node == null ? new PasteBuilder.FileProvider(region.getResetFile(RegionType.TESTBLOCK)) : new PasteBuilder.SchematicProvider(node); + PasteBuilder.ClipboardProvider clipboardProvider = node == null ? new PasteBuilder.FileProvider(region.getTestblockArea().getResetFile()) : new PasteBuilder.SchematicProvider(node); PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider) .ignoreAir(ignoreAir) .onlyColors(onlyColors) 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 6c3ba0ab..59b20632 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -94,6 +94,11 @@ public interface Region { return null; } + @Override + public File getResetFile() { + return null; + } + @Override public void reset(PasteBuilder pasteBuilder, boolean extension) { } @@ -122,6 +127,8 @@ public interface Region { EditSession copy(boolean extension); + File getResetFile(); + void reset(PasteBuilder pasteBuilder, boolean extension); void forEachChunk(BiConsumer executor); From d55556cb47deab0be23d09cd9c093f3f365dc90d Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 31 Jul 2025 12:11:10 +0200 Subject: [PATCH 26/56] Fix some more errors --- .../de/steamwar/bausystem/features/region/ResetCommand.java | 6 +----- .../src/de/steamwar/bausystem/region/FlagStorage.java | 2 ++ 2 files changed, 3 insertions(+), 5 deletions(-) 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 c8d4d19d..49893d1d 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,7 @@ 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.ColorMode; 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; import de.steamwar.linkage.Linked; @@ -57,9 +55,7 @@ public class ResetCommand extends SWCommand { PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile())) .color(region.getFlags().get(Flag.COLOR).getWithDefault()); region.getArea().reset(pasteBuilder, false); - for (Flag value : Flag.getFlags()) { - region.getFlags().set(value, value.getDefaultValue()); - } + region.getFlags().clear(); 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/region/FlagStorage.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java index 922e1ab2..6d51e2ef 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java @@ -28,4 +28,6 @@ public interface FlagStorage { & Flag.Value> boolean set(Flag flag, T value); & Flag.Value> FlagOptional get(Flag flag); + + void clear(); } From 6a7849919310f6f6558110cd31b5120780cab49f Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 31 Jul 2025 12:14:14 +0200 Subject: [PATCH 27/56] Fix some more errors --- .../steamwar/bausystem/features/bau/BauInfoBauGuiItem.java | 7 +------ .../de/steamwar/bausystem/features/bau/InfoCommand.java | 4 +--- 2 files changed, 2 insertions(+), 9 deletions(-) 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 2940eac0..8a3cffb4 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 @@ -57,12 +57,7 @@ public class BauInfoBauGuiItem extends BauGuiItem { Region region = Region.getRegion(player.getLocation()); List stringList = new ArrayList<>(); for (Flag flag : Flag.getFlags()) { - if (flag == Flag.PROTECT && region.getFloorLevel() == 0) { - continue; - } - if (flag == Flag.ITEMS && Core.getVersion() < 19) { - continue; - } + if (!region.getFlags().has(flag).isApplicable()) continue; 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))); 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 40ec5d7a..6b3a1d85 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 @@ -31,9 +31,7 @@ public class InfoCommand extends SWCommand { BauSystem.MESSAGE.send("BAU_INFO_COMMAND_OWNER", p, SteamwarUser.get(bauServer.getOwnerID()).getUserName()); Region region = Region.getRegion(p.getLocation()); for (Flag flag : Flag.getFlags()) { - if (flag == Flag.PROTECT && region.getFloorLevel() == 0) { - continue; - } + if (!region.getFlags().has(flag).isApplicable()) continue; 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)); From ad87ad74954c3c35657a6638c2fc386df2536473 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 31 Jul 2025 13:53:10 +0200 Subject: [PATCH 28/56] Add RegionConfig --- .../features/autostart/AutostartListener.java | 12 +- .../design/endstone/DesignEndStone.java | 23 ++-- .../endstone/DesignEndStoneCommand.java | 2 +- .../region/RegionScoreboardElement.java | 7 +- .../features/techhider/TechHiderCommand.java | 14 +- .../bausystem/features/xray/XrayCommand.java | 21 +-- .../de/steamwar/bausystem/region/Region.java | 3 +- .../bausystem/region/RegionConfig.java | 124 ++++++++++++++++++ 8 files changed, 146 insertions(+), 60 deletions(-) create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionConfig.java diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java index 59e4fd3a..fbc6430f 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java @@ -31,8 +31,6 @@ import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.data.type.Chest; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -41,7 +39,6 @@ import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; -import java.io.File; import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -132,17 +129,10 @@ public class AutostartListener implements Listener { if (!regionStartTime.containsKey(region)) return; if (!region.getTestblockArea().inRegion(block.getLocation(), true)) return; long tickDiff = TPSUtils.currentRealTick.get() - regionStartTime.remove(region); - long preFightDurationInSeconds = getPreFightDurationInSeconds(region); + long preFightDurationInSeconds = region.getGameModeConfig().getTimes().getPreFightDuration(); RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT1", tickDiff); RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT2", preFightDurationInSeconds, ((preFightDurationInSeconds * 20) - tickDiff)); RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT3"); }); } - - private int getPreFightDurationInSeconds(Region region) { - File file = region.getGameModeConfig().orElse(null); - if (file == null) return 30; - FileConfiguration config = YamlConfiguration.loadConfiguration(file); - return config.getInt("Times.PreFightDuration", 30); - } } 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 35437be8..129ebe71 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 @@ -33,6 +33,7 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import java.util.*; +import java.util.stream.Collectors; public class DesignEndStone { @@ -42,7 +43,7 @@ public class DesignEndStone { private REntityServer entityServer = new REntityServer(); private List entities = new ArrayList<>(); private Set locations = new HashSet<>(); - private Set limited = new HashSet<>(); + private Set limited; private boolean calculateFromBottom; public DesignEndStone(Region region) { @@ -53,17 +54,15 @@ public class DesignEndStone { this.maxY = region.getBuildArea().getMaxPoint(false).getY(); this.maxZ = region.getBuildArea().getMaxPoint(false).getZ(); - YamlConfiguration config = YamlConfiguration.loadConfiguration(region.getGameModeConfig().get()); - for(Map entry : config.getMapList("Schematic.Limited")) { - int amount = (Integer) entry.get("Amount"); - Set materials = new HashSet<>((List) entry.get("Materials")); - if(amount == 0) { - materials.forEach(s -> { - limited.add(Material.getMaterial(s)); - }); - } - } - calculateFromBottom = config.getBoolean("Arena.NoFloor", false); + limited = region.getGameModeConfig() + .getSchematic() + .getLimited() + .entrySet() + .stream() + .filter(entry -> entry.getValue() == 0) + .flatMap(entry -> entry.getKey().stream()) + .collect(Collectors.toSet()); + calculateFromBottom = region.getGameModeConfig().getArena().isNoFloor(); entityServer.setCallback((player, rEntity, entityAction) -> { if (entityAction != REntityServer.EntityAction.ATTACK) return; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java index 61fa0278..6d10d479 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java @@ -52,7 +52,7 @@ public class DesignEndStoneCommand extends SWCommand implements Listener { BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player); return; } - if (region.getGameModeConfig().isEmpty()) { + if (!region.getGameModeConfig().isLoaded()) { BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player); return; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java index bfc3a6e4..b810bb1e 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java @@ -46,11 +46,8 @@ public class RegionScoreboardElement implements ScoreboardElement { @Override public String get(Region region, Player p) { if (region.getType().isGlobal()) return null; - // TODO: Improve this! - Optional gameModeConfig = region.getGameModeConfig(); - if (gameModeConfig.isEmpty()) return null; - YamlConfiguration config = YamlConfiguration.loadConfiguration(region.getGameModeConfig().get()); - List names = config.getStringList("Server.ChatNames"); + if (!region.getGameModeConfig().isLoaded()) return null; + List names = region.getGameModeConfig().getServer().getChatNames(); if (names.isEmpty()) return null; return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + names.get(0); } 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 e3510306..5f205e79 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 @@ -69,26 +69,16 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE } Optional techHider = techHiders.computeIfAbsent(region, rg -> { - File file = rg.getGameModeConfig().orElse(null); - if (file == null) { - return Optional.empty(); - } - - FileConfiguration config = YamlConfiguration.loadConfiguration(file); - if (!config.getBoolean("Techhider.Active", false)) { + if (!region.getGameModeConfig().getTechhider().isActive()) { return Optional.empty(); } hidden.put(rg, new HashSet<>()); - String obfuscateWith = config.getString("Techhider.ObfuscateWith", "end_stone"); - Set hiddenBlocks = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlocks"))); - Set hiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities"))); - TechHider current = new TechHider((p, cX, cY) -> { if (rg.getBuildArea().isChunkOutside(cX, cY)) return true; return !hidden.get(rg).contains(p); - }, Material.valueOf(obfuscateWith.toUpperCase()), hiddenBlocks.stream().map(String::toUpperCase).map(Material::valueOf).collect(Collectors.toSet()), hiddenBlockEntities); + }, region.getGameModeConfig().getTechhider().getObfuscateWith(), region.getGameModeConfig().getTechhider().getHiddenBlocks(), region.getGameModeConfig().getTechhider().getHiddenBlockEntities()); current.enable(); return Optional.of(current); 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 547e31d9..19f0a390 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 @@ -19,8 +19,8 @@ package de.steamwar.bausystem.features.xray; -import de.steamwar.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; +import de.steamwar.Reflection; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.techhider.TechHiderCommand; import de.steamwar.bausystem.region.Region; @@ -34,8 +34,6 @@ import de.steamwar.techhider.TechHider; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.Bukkit; import org.bukkit.Material; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -43,7 +41,6 @@ import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; -import java.io.File; import java.util.*; import java.util.function.BiFunction; @@ -70,24 +67,14 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen } Optional techHider = techHiders.computeIfAbsent(region, rg -> { - File file = rg.getGameModeConfig().orElse(null); - if (file == null) { + if (!region.getGameModeConfig().getTechhider().isActive()) { return Optional.empty(); } - FileConfiguration config = YamlConfiguration.loadConfiguration(file); - if (!config.getBoolean("Techhider.Active", false)) { - Set blocks = new HashSet<>(Arrays.asList(Material.END_STONE, Material.IRON_BLOCK)); - xrayedBlocks.put(region, blocks); - return Optional.of(createXray(rg, blocks)); - } - hidden.put(rg, new HashSet<>()); - String obfuscateWith = config.getString("Techhider.ObfuscateWith", "end_stone"); - - Set blocks = new HashSet<>(Arrays.asList(Material.getMaterial(obfuscateWith.toUpperCase()))); - if (obfuscateWith.equals("end_stone")) blocks.add(Material.END_STONE_BRICKS); + Set blocks = new HashSet<>(Arrays.asList(region.getGameModeConfig().getTechhider().getObfuscateWith())); + if (blocks.contains(Material.END_STONE)) blocks.add(Material.END_STONE_BRICKS); xrayedBlocks.put(region, blocks); return Optional.of(createXray(rg, blocks)); }); 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 59b20632..fb6d0f55 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -24,7 +24,6 @@ import de.steamwar.bausystem.utils.PasteBuilder; import org.bukkit.Location; import java.io.File; -import java.util.Optional; import java.util.UUID; import java.util.function.BiConsumer; import java.util.stream.Stream; @@ -55,7 +54,7 @@ public interface Region { Area getTestblockArea(); - Optional getGameModeConfig(); + RegionConfig getGameModeConfig(); RegionHistory getHistory(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionConfig.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionConfig.java new file mode 100644 index 00000000..5c7da406 --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionConfig.java @@ -0,0 +1,124 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 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 lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.bukkit.Material; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.io.File; +import java.util.*; +import java.util.stream.Collectors; + +@Getter +public class RegionConfig { + + private final boolean loaded; + + private Times Times = new Times(); + private Schematic Schematic = new Schematic(); + private Arena Arena = new Arena(); + private Server Server = new Server(); + private Techhider Techhider = new Techhider(); + + public RegionConfig(File file) { + if (file == null || !file.exists()) { + loaded = false; + return; + } + loaded = true; + + FileConfiguration config = YamlConfiguration.loadConfiguration(file); + + Times.load(config.getConfigurationSection("Times")); + Schematic.load(config.getConfigurationSection("Schematic")); + Arena.load(config.getConfigurationSection("Arena")); + Server.load(config.getConfigurationSection("Server")); + Techhider.load(config.getConfigurationSection("Techhider")); + } + + @NoArgsConstructor(access = AccessLevel.PRIVATE) + @Getter + public static class Times { + private int PreFightDuration = 30; + + private void load(ConfigurationSection section) { + PreFightDuration = section.getInt("PreFightDuration", 30); + } + } + + @NoArgsConstructor(access = AccessLevel.PRIVATE) + @Getter + public static class Schematic { + private Map, Integer> Limited = new HashMap<>(); + + private void load(ConfigurationSection section) { + for(Map entry : section.getMapList("Limited")) { + int amount = (Integer) entry.get("Amount"); + Set materials = new HashSet<>((List) entry.get("Materials")); + if (amount == 0) { + materials.forEach(material -> Limited.put(Collections.singleton(Material.getMaterial(material)), 0)); + } else { + Limited.put(materials.stream().map(Material::getMaterial).collect(Collectors.toSet()), amount); + } + } + } + } + + @NoArgsConstructor(access = AccessLevel.PRIVATE) + @Getter + public static class Arena { + private boolean NoFloor = false; + + private void load(ConfigurationSection section) { + NoFloor = section.getBoolean("NoFloor", false); + } + } + + @NoArgsConstructor(access = AccessLevel.PRIVATE) + @Getter + public static class Server { + private List ChatNames; + + private void load(ConfigurationSection section) { + ChatNames = section.getStringList("ChatNames"); + } + } + + @NoArgsConstructor(access = AccessLevel.PRIVATE) + @Getter + public static class Techhider { + private boolean Active = false; + private Material ObfuscateWith = Material.END_STONE; + private Set HiddenBlocks = new HashSet<>(); + private Set HiddenBlockEntities = new HashSet<>(); + + private void load(ConfigurationSection section) { + Active = section.getBoolean("Active", false); + ObfuscateWith = Material.getMaterial(section.getString("ObfuscateWith", "END_STONE")); + HiddenBlocks = section.getStringList("HiddenBlocks").stream().map(Material::getMaterial).collect(Collectors.toUnmodifiableSet()); + HiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(section.getStringList("HiddenBlockEntities"))); + } + } +} From 698f9178282be6082e2999f27b5ceedaa659573b Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 31 Jul 2025 14:11:03 +0200 Subject: [PATCH 29/56] Add RegionSkins --- .../features/backup/BackupCommand.java | 7 +-- .../features/region/RegionCommand.java | 34 +++++------- .../bausystem/region/FlagStorage.java | 9 ++- .../de/steamwar/bausystem/region/Region.java | 19 +++++++ .../bausystem/region/RegionBackups.java | 14 ++++- .../bausystem/region/RegionHistory.java | 3 +- .../bausystem/region/RegionSkins.java | 55 +++++++++++++++++++ .../bausystem/region/RegionSystem.java | 11 +++- 8 files changed, 118 insertions(+), 34 deletions(-) create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSkins.java 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 b2671e84..6c7708c9 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 @@ -72,12 +72,7 @@ public class BackupCommand extends SWCommand { } @Register(value = "load", description = "BACKUP_HELP_LOAD") - public void backupLoad(@Validator("owner") Player p, @Mapper("backup") RegionBackups.Backup backup) { - Region region = Region.getRegion(p.getLocation()); - if (checkGlobalRegion(region, p)) { - return; - } - + public void backupLoad(@Validator("owner") Player p, @Mapper("backup") @ErrorMessage("BACKUP_LOAD_FAILURE") RegionBackups.Backup backup) { if (backup.load()) { BauSystem.MESSAGE.send("BACKUP_LOAD", p); } 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 ccf62cdb..a0f2ca1c 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 @@ -30,9 +30,9 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.util.SelectCommand; import de.steamwar.bausystem.region.Point; import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.RegionSkins; import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.shared.Pair; import de.steamwar.bausystem.utils.FlatteningWrapper; import de.steamwar.bausystem.utils.PasteBuilder; @@ -177,8 +177,8 @@ public class RegionCommand extends SWCommand { if (checkGlobalRegion(region, p)) { return; } - BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_INFO", p, region.getSkin()); - String creator = region.getPrototype().getSkinMap().get(region.getSkin()).getCreator(); + BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_INFO", p, region.getSkins().getCurrentSkin().getName()); + String creator = region.getSkins().getCurrentSkin().getCreator(); if (creator != null) { BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_INFO_CREATOR", p, creator); } @@ -186,20 +186,12 @@ public class RegionCommand extends SWCommand { @Register(value = "changeskin", description = "REGION_REGION_HELP_CHANGESKIN") @Register("skin") - public void changeSkinCommand(@Validator Player p, @Mapper("skinTypeMapper") String s) { - Region region = Region.getRegion(p.getLocation()); - if (checkGlobalRegion(region, p)) { - return; - } - if (!region.getPrototype().getSkinMap().containsKey(s)) { - BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_UNKNOWN", p); + public void changeSkinCommand(@Validator Player p, @Mapper("skinTypeMapper") @ErrorMessage("REGION_REGION_CHANGESKIN_UNKNOWN") RegionSkins.Skin skin) { + if (skin.apply()) { + BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_CHANGE", p, skin.getName()); + BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_CHANGE_UPDATE", p, BauSystem.MESSAGE.parse("REGION_REGION_CHANGESKIN_CHANGE_UPDATE_HOVER", p), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/reset")); } else { - if (region.setSkin(s)) { - BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_CHANGE", p, s); - BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_CHANGE_UPDATE", p, BauSystem.MESSAGE.parse("REGION_REGION_CHANGESKIN_CHANGE_UPDATE_HOVER", p), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/reset")); - } else { - BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_INVALID", p); - } + BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_INVALID", p); } } @@ -296,8 +288,8 @@ public class RegionCommand extends SWCommand { @Mapper(value = "skinTypeMapper", local = true) - private TypeMapper skinTypeMapper() { - return new TypeMapper() { + private TypeMapper skinTypeMapper() { + return new TypeMapper() { @Override public List tabCompletes(CommandSender commandSender, PreviousArguments previousArguments, String s) { Player p = (Player) commandSender; @@ -305,12 +297,12 @@ public class RegionCommand extends SWCommand { if (region.getType().isGlobal()) { return Collections.emptyList(); } - return region.getPrototype().getSkinMap().keySet().stream().map(c -> c.replace(' ', '_')).collect(Collectors.toList()); + return region.getSkins().list().stream().map(skin -> skin.getName().replace(' ', '_')).collect(Collectors.toList()); } @Override - public String map(CommandSender commandSender, PreviousArguments previousArguments, String s) { - return s.replace('_', ' '); + public RegionSkins.Skin map(CommandSender commandSender, PreviousArguments previousArguments, String s) { + return Region.getRegion(((Player) commandSender).getLocation()).getSkins().get(s.replace('_', ' ')); } }; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java index 6d51e2ef..d6f1afd5 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java @@ -20,14 +20,17 @@ package de.steamwar.bausystem.region; import de.steamwar.bausystem.region.flags.Flag; +import lombok.NonNull; public interface FlagStorage { - & Flag.Value> RegionFlagPolicy has(Flag flag); + @NonNull + & Flag.Value> RegionFlagPolicy has(@NonNull Flag flag); - & Flag.Value> boolean set(Flag flag, T value); + & Flag.Value> boolean set(@NonNull Flag flag, @NonNull T value); - & Flag.Value> FlagOptional get(Flag flag); + @NonNull + & Flag.Value> FlagOptional get(@NonNull Flag flag); void clear(); } 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 fb6d0f55..d2d97ecf 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -21,8 +21,10 @@ package de.steamwar.bausystem.region; import com.sk89q.worldedit.EditSession; import de.steamwar.bausystem.utils.PasteBuilder; +import lombok.NonNull; import org.bukkit.Location; +import javax.annotation.Nullable; import java.io.File; import java.util.UUID; import java.util.function.BiConsumer; @@ -42,24 +44,36 @@ public interface Region { return RegionSystem.INSTANCE.getGlobalRegion(); } + @NonNull UUID getID(); + @NonNull RegionType getType(); + @NonNull FlagStorage getFlags(); + @NonNull Area getArea(); + @NonNull Area getBuildArea(); + @NonNull Area getTestblockArea(); + @NonNull RegionConfig getGameModeConfig(); + @NonNull RegionHistory getHistory(); + @NonNull RegionBackups getBackups(); + @NonNull + RegionSkins getSkins(); + interface Area { Area EMPTY = new Area() { @@ -116,16 +130,21 @@ public interface Region { return false; } + @NonNull Point getMinPoint(boolean extension); + @NonNull Point getMaxPoint(boolean extension); + @NonNull Point getCopyPoint(); boolean inRegion(Location location, boolean extension); + @Nullable EditSession copy(boolean extension); + @Nullable File getResetFile(); void reset(PasteBuilder pasteBuilder, boolean extension); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionBackups.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionBackups.java index af4bf23b..53b3b8a7 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionBackups.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionBackups.java @@ -20,8 +20,11 @@ package de.steamwar.bausystem.region; import lombok.Getter; +import lombok.NonNull; import lombok.RequiredArgsConstructor; +import javax.annotation.CheckReturnValue; +import javax.annotation.Nullable; import java.util.List; import java.util.Optional; @@ -33,24 +36,33 @@ public interface RegionBackups { AUTOMATIC(20), ; - private final int maxBackups; + public final int maxBackups; } @RequiredArgsConstructor @Getter abstract class Backup { + @NonNull private final BackupType type; + + @NonNull private final String name; + + @NonNull private final FlagStorage flags; + @CheckReturnValue public abstract boolean load(); public abstract void delete(); } + @CheckReturnValue Optional create(BackupType backupType); + @NonNull List list(); + @Nullable Backup get(String name); } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionHistory.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionHistory.java index 17ff9c19..9732b325 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionHistory.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionHistory.java @@ -20,10 +20,11 @@ package de.steamwar.bausystem.region; import com.sk89q.worldedit.EditSession; +import lombok.NonNull; public interface RegionHistory { - void remember(EditSession editSession); + void remember(@NonNull EditSession editSession); boolean undo(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSkins.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSkins.java new file mode 100644 index 00000000..e12f2221 --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSkins.java @@ -0,0 +1,55 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 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 lombok.Getter; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + +import javax.annotation.CheckReturnValue; +import javax.annotation.Nullable; +import java.util.List; + +public interface RegionSkins { + + @RequiredArgsConstructor + @Getter + abstract class Skin { + @NonNull + private final String name; + + @NonNull + private final String creator; + + @CheckReturnValue + public abstract boolean apply(); + } + + @NonNull + Skin getCurrentSkin(); + + @NonNull + List list(); + + boolean has(@NonNull String name); + + @Nullable + Skin get(@NonNull String name); +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java index 26ee4bc6..5222a415 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java @@ -19,8 +19,10 @@ package de.steamwar.bausystem.region; +import lombok.NonNull; import org.bukkit.Location; +import javax.annotation.CheckReturnValue; import java.lang.reflect.InvocationTargetException; import java.util.Optional; import java.util.UUID; @@ -33,11 +35,16 @@ public interface RegionSystem { void load(); void save(); + @NonNull Region getGlobalRegion(); - Region get(Location location); - Optional getRegion(UUID id); + @NonNull + Region get(@NonNull Location location); + @CheckReturnValue + Optional getRegion(@NonNull UUID id); + + @NonNull Stream getRegions(); boolean isModular(); From e6196251a62c462c76849fe8f6de2c6be43ee21d Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 31 Jul 2025 14:12:30 +0200 Subject: [PATCH 30/56] Remove SkinCommand Fix TickManager15 --- .../src/de/steamwar/bausystem/utils/TickManager15.java | 4 ++-- .../features/team/{SkinCommand.java => SkinCommand.java.txt} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/team/{SkinCommand.java => SkinCommand.java.txt} (100%) diff --git a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/TickManager15.java b/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/TickManager15.java index a56a2e35..ab279d45 100644 --- a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/TickManager15.java +++ b/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/TickManager15.java @@ -19,7 +19,7 @@ package de.steamwar.bausystem.utils; -import de.steamwar.bausystem.region.GlobalRegion; +import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.utils.bossbar.BossBarService; import de.steamwar.bausystem.utils.tps.TPSFreezeUtils; import de.steamwar.bausystem.utils.tps.TPSLimitUtils; @@ -46,7 +46,7 @@ public class TickManager15 implements TickManager, Listener { if (currentlyStepping) { currentlyStepping = false; Bukkit.getOnlinePlayers().forEach(player -> { - BossBarService.instance.remove(player, GlobalRegion.getInstance(), "TickStep"); + BossBarService.instance.remove(player, Region.getGlobalRegion(), "TickStep"); }); } TPSWarpUtils.warp(tickRate); 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.txt similarity index 100% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/team/SkinCommand.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/team/SkinCommand.java.txt From c49a212c0559d80ca761645dc1e6da2a7fe215ff Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 31 Jul 2025 14:14:12 +0200 Subject: [PATCH 31/56] Move regionold to RegionFixed module --- .../src/de/steamwar/bausystem/regionold/Prototype.java.txt | 0 .../src/de/steamwar/bausystem/regionold/Region.java.txt | 0 .../steamwar/bausystem/regionold/loader/PrototypeLoader.java.txt | 0 .../de/steamwar/bausystem/regionold/loader/RegionLoader.java.txt | 0 .../src/de/steamwar/bausystem/regionold/loader/Updater.java.txt | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename BauSystem/{BauSystem_Main => BauSystem_RegionFixed}/src/de/steamwar/bausystem/regionold/Prototype.java.txt (100%) rename BauSystem/{BauSystem_Main => BauSystem_RegionFixed}/src/de/steamwar/bausystem/regionold/Region.java.txt (100%) rename BauSystem/{BauSystem_Main => BauSystem_RegionFixed}/src/de/steamwar/bausystem/regionold/loader/PrototypeLoader.java.txt (100%) rename BauSystem/{BauSystem_Main => BauSystem_RegionFixed}/src/de/steamwar/bausystem/regionold/loader/RegionLoader.java.txt (100%) rename BauSystem/{BauSystem_Main => BauSystem_RegionFixed}/src/de/steamwar/bausystem/regionold/loader/Updater.java.txt (100%) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionold/Prototype.java.txt b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/Prototype.java.txt similarity index 100% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionold/Prototype.java.txt rename to BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/Prototype.java.txt diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionold/Region.java.txt b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/Region.java.txt similarity index 100% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionold/Region.java.txt rename to BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/Region.java.txt diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionold/loader/PrototypeLoader.java.txt b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/PrototypeLoader.java.txt similarity index 100% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionold/loader/PrototypeLoader.java.txt rename to BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/PrototypeLoader.java.txt diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionold/loader/RegionLoader.java.txt b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/RegionLoader.java.txt similarity index 100% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionold/loader/RegionLoader.java.txt rename to BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/RegionLoader.java.txt diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionold/loader/Updater.java.txt b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/Updater.java.txt similarity index 100% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/regionold/loader/Updater.java.txt rename to BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/Updater.java.txt From 01d9532aa66dab0d4ce82324ad3cb1c185fcae75 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 31 Jul 2025 14:31:16 +0200 Subject: [PATCH 32/56] Pot impl a FixedGlobalRegion --- .../bausystem/region/RegionBackups.java | 18 +++ .../bausystem/region/RegionHistory.java | 16 +++ .../bausystem/region/RegionSkins.java | 35 +++++ .../steamwar/bausystem/region/flags/Flag.java | 10 +- .../bausystem/region/FixedFlagStorage.java | 32 +++-- .../bausystem/region/FixedGlobalRegion.java | 132 ++++++++++-------- .../bausystem/region/FixedRegion.java | 111 --------------- .../bausystem/region/FixedRegionSystem.java | 10 +- 8 files changed, 171 insertions(+), 193 deletions(-) delete mode 100644 BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegion.java diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionBackups.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionBackups.java index 53b3b8a7..b49e949a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionBackups.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionBackups.java @@ -65,4 +65,22 @@ public interface RegionBackups { @Nullable Backup get(String name); + + RegionBackups EMPTY = new RegionBackups() { + @Override + public Optional create(BackupType backupType) { + return Optional.empty(); + } + + @Override + public @NonNull List list() { + return List.of(); + } + + @Nullable + @Override + public Backup get(String name) { + return null; + } + }; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionHistory.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionHistory.java index 9732b325..2eb79247 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionHistory.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionHistory.java @@ -29,4 +29,20 @@ public interface RegionHistory { boolean undo(); boolean redo(); + + RegionHistory EMPTY = new RegionHistory() { + @Override + public void remember(@NonNull EditSession editSession) { + } + + @Override + public boolean undo() { + return false; + } + + @Override + public boolean redo() { + return false; + } + }; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSkins.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSkins.java index e12f2221..b9413d9f 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSkins.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSkins.java @@ -40,6 +40,13 @@ public interface RegionSkins { @CheckReturnValue public abstract boolean apply(); + + public static final Skin GLOBAL = new Skin("Global", "§eSteam§8War") { + @Override + public boolean apply() { + return false; + } + }; } @NonNull @@ -52,4 +59,32 @@ public interface RegionSkins { @Nullable Skin get(@NonNull String name); + + RegionSkins GLOBAL = new RegionSkins() { + + @Override + public @NonNull Skin getCurrentSkin() { + return Skin.GLOBAL; + } + + @Override + public @NonNull List list() { + return List.of(Skin.GLOBAL); + } + + @Override + public boolean has(@NonNull String name) { + return Skin.GLOBAL.name.equals(name); + } + + @Nullable + @Override + public Skin get(@NonNull String name) { + if (Skin.GLOBAL.name.equals(name)) { + return Skin.GLOBAL; + } else { + return null; + } + } + }; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java index e9eb963b..c62e0748 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java @@ -29,6 +29,11 @@ import java.util.concurrent.atomic.AtomicInteger; public final class Flag & Flag.Value> implements EnumDisplay { + @Getter + private static final Set flags = new HashSet<>(); + + private static AtomicInteger counter = new AtomicInteger(0); + public static final Flag COLOR = new Flag<>("COLOR", "FLAG_COLOR", ColorMode.class, ColorMode.YELLOW); public static final Flag TNT = new Flag<>("TNT", "FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB); public static final Flag FIRE = new Flag<>("FIRE", "FLAG_FIRE", FireMode.class, FireMode.ALLOW); @@ -39,11 +44,6 @@ public final class Flag & Flag.Value> implements EnumDispla public static final Flag TESTBLOCK = new Flag<>("TESTBLOCK", "FLAG_TESTBLOCK", TestblockMode.class, TestblockMode.NO_VALUE); public static final Flag CHANGED = new Flag<>("CHANGED", "FLAG_CHANGED", ChangedMode.class, ChangedMode.NO_CHANGE); - @Getter - private static final Set flags = new HashSet<>(); - - private static AtomicInteger counter = new AtomicInteger(0); - private String name; private int ordinal; diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedFlagStorage.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedFlagStorage.java index af44866a..7f083084 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedFlagStorage.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedFlagStorage.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.region; import de.steamwar.bausystem.region.flags.Flag; +import lombok.NonNull; import java.io.File; import java.util.HashMap; @@ -29,27 +30,28 @@ public class FixedFlagStorage implements FlagStorage { private Map, Flag.Value> flagMap = new HashMap<>(); - public static FlagStorage createFromRegion(Region region) { - FlagStorage flagStorage = new FixedFlagStorage(); - Flag.getFlags().forEach(flag -> { - if (region.hasFlag(flag).isReadable()) { - flagStorage.set(flag, flag.getDefaultValue()); - } - }); - return flagStorage; - } - public static FlagStorage createFromFile(File file) { - throw new IllegalStateException("Not implemented yet"); + // throw new IllegalStateException("Not implemented yet"); + return new FixedFlagStorage(); } @Override - public & Flag.Value> boolean set(Flag flag, T value) { - return flagMap.put(flag, value) != value; + public @NonNull & Flag.Value> RegionFlagPolicy has(@NonNull Flag flag) { + return RegionFlagPolicy.NOT_APPLICABLE; } @Override - public & Flag.Value> T get(Flag flag) { - return (T) flagMap.get(flag); + public & Flag.Value> boolean set(@NonNull Flag flag, @NonNull T value) { + return false; + } + + @Override + public @NonNull & Flag.Value> FlagOptional get(@NonNull Flag flag) { + return FlagOptional.of(flag); + } + + @Override + public void clear() { + flagMap.clear(); } } diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalRegion.java index b36ddecb..b1545d48 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalRegion.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalRegion.java @@ -20,12 +20,14 @@ package de.steamwar.bausystem.region; import com.sk89q.worldedit.EditSession; -import de.steamwar.bausystem.region.flags.Flag; +import de.steamwar.bausystem.utils.PasteBuilder; import lombok.NonNull; import org.bukkit.Location; +import javax.annotation.Nullable; import java.io.File; -import java.util.Optional; +import java.util.UUID; +import java.util.function.BiConsumer; public final class FixedGlobalRegion implements Region { @@ -34,7 +36,58 @@ public final class FixedGlobalRegion implements Region { private static final Point MIN_POINT = new Point(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE); private static final Point MAX_POINT = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); - private final FlagStorage FLAG_STORAGE = FixedFlagStorage.createFromRegion(this); // TODO: Update to either File or Region creation! + private static final FlagStorage FLAG_STORAGE = FixedFlagStorage.createFromFile(null); // TODO: Update to either File or Region creation! + + private static final UUID GLOBAL_REGION_ID = new UUID(0, 0); + + private static final Area GLOBAL_AREA = new Area() { + @Override + public @NonNull Point getMinPoint(boolean extension) { + return MIN_POINT; + } + + @Override + public @NonNull Point getMaxPoint(boolean extension) { + return MAX_POINT; + } + + @Override + public @NonNull Point getCopyPoint() { + return Point.ZERO; + } + + @Override + public boolean inRegion(Location location, boolean extension) { + return true; + } + + @Nullable + @Override + public EditSession copy(boolean extension) { + return null; + } + + @Nullable + @Override + public File getResetFile() { + return null; + } + + @Override + public void reset(PasteBuilder pasteBuilder, boolean extension) { + } + + @Override + public void forEachChunk(BiConsumer executor) { + } + + @Override + public boolean isChunkOutside(int chunkX, int chunkZ) { + return false; + } + }; + + private static final RegionConfig GLOBAL_CONFIG = new RegionConfig(null); private FixedGlobalRegion() { } @@ -45,84 +98,47 @@ public final class FixedGlobalRegion implements Region { } @Override - public & Flag.Value> RegionFlagPolicy hasFlag(@NonNull Flag flag) { - if (flag.oneOf(Flag.TNT, Flag.FIRE, Flag.FREEZE, Flag.ITEMS, Flag.NO_GRAVITY)) { - return RegionFlagPolicy.WRITABLE; - } - return RegionFlagPolicy.NOT_APPLICABLE; + public @NonNull UUID getID() { + return GLOBAL_REGION_ID; } @Override - public & Flag.Value> boolean setFlag(@NonNull Flag flag, T value) { - return hasFlag(flag).isWritable() && FLAG_STORAGE.set(flag, value); + public @NonNull FlagStorage getFlags() { + return FLAG_STORAGE; } @Override - public & Flag.Value> Optional getFlag(@NonNull Flag flag) { - if (hasFlag(flag).isReadable()) { - return Optional.ofNullable(FLAG_STORAGE.get(flag)); - } else { - return Optional.empty(); - } + public @NonNull Area getArea() { + return GLOBAL_AREA; } @Override - public Point getMinPoint() { - return MIN_POINT; + public @NonNull Area getBuildArea() { + return Area.EMPTY; } @Override - public Point getMaxPoint() { - return MAX_POINT; + public @NonNull Area getTestblockArea() { + return Area.EMPTY; } @Override - public boolean inRegion(Location location) { - return true; + public @NonNull RegionConfig getGameModeConfig() { + return GLOBAL_CONFIG; } @Override - public Inner getBuildArea() { - return Inner.EMPTY; + public @NonNull RegionHistory getHistory() { + return RegionHistory.EMPTY; } @Override - public Inner getTestblockArea() { - return Inner.EMPTY; + public @NonNull RegionBackups getBackups() { + return RegionBackups.EMPTY; } @Override - public Optional getGameModeConfig() { - return Optional.empty(); - } - - @Override - public Optional copy() { - return Optional.empty(); - } - - @Override - public boolean backup(boolean automatic) { - return false; - } - - @Override - public void reset() { - - } - - @Override - public void remember(EditSession editSession) { - - } - - @Override - public boolean undo() { - return false; - } - - @Override - public boolean redo() { - return false; + public @NonNull RegionSkins getSkins() { + return RegionSkins.GLOBAL; } } diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegion.java deleted file mode 100644 index 0023060d..00000000 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegion.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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.bausystem.region.flags.Flag; -import lombok.NonNull; -import org.bukkit.Location; - -import java.io.File; -import java.util.Optional; - -public class FixedRegion implements Region { // TODO: Implement! - - @Override - public RegionType getType() { - return RegionType.NORMAL; - } - - @Override - public & Flag.Value> RegionFlagPolicy hasFlag(@NonNull Flag flag) { - return null; - } - - @Override - public & Flag.Value> boolean setFlag(@NonNull Flag flag, T value) { - return false; - } - - @Override - public & Flag.Value> Optional getFlag(@NonNull Flag flag) { - return Optional.empty(); - } - - @Override - public Point getMinPoint() { - return null; - } - - @Override - public Point getMaxPoint() { - return null; - } - - @Override - public boolean inRegion(Location location) { - return false; - } - - @Override - public Inner getBuildArea() { - return Inner.EMPTY; - } - - @Override - public Inner getTestblockArea() { - return Inner.EMPTY; - } - - @Override - public Optional getGameModeConfig() { - return Optional.empty(); - } - - @Override - public boolean backup(boolean automatic) { - return false; - } - - @Override - public Optional copy() { - return Optional.empty(); - } - - @Override - public void reset() { - - } - - @Override - public void remember(EditSession editSession) { - - } - - @Override - public boolean undo() { - return false; - } - - @Override - public boolean redo() { - return false; - } -} diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java index dfdaf3f3..473ec0d3 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java @@ -19,16 +19,18 @@ package de.steamwar.bausystem.region; +import lombok.NonNull; import org.bukkit.Location; import java.util.HashMap; import java.util.Map; import java.util.Optional; +import java.util.UUID; import java.util.stream.Stream; public class FixedRegionSystem implements RegionSystem { - private static final Map REGION_MAP = new HashMap<>(); + private static final Map REGION_MAP = new HashMap<>(); @Override public void load() { @@ -48,14 +50,14 @@ public class FixedRegionSystem implements RegionSystem { @Override public Region get(Location location) { return REGION_MAP.values().stream() - .filter(region -> region.inRegion(location)) + .filter(region -> region.getArea().inRegion(location, false)) .findFirst() .orElse(FixedGlobalRegion.INSTANCE); } @Override - public Optional getRegion(String name) { - return Optional.ofNullable(REGION_MAP.get(name)); + public Optional getRegion(@NonNull UUID id) { + return Optional.ofNullable(REGION_MAP.get(id)); } @Override From 6a5507321eb0b3c6733f9e96ae19e909531edeee Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 31 Jul 2025 18:17:38 +0200 Subject: [PATCH 33/56] Add FixedGlobalFlagStorage --- .../steamwar/bausystem/region/flags/Flag.java | 3 +- .../bausystem/region/FixedFlagStorage.java | 10 ++- .../region/FixedGlobalFlagStorage.java | 78 +++++++++++++++++++ .../bausystem/region/FixedGlobalRegion.java | 2 +- 4 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalFlagStorage.java diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java index c62e0748..ddee1806 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java @@ -20,7 +20,6 @@ package de.steamwar.bausystem.region.flags; import de.steamwar.bausystem.shared.EnumDisplay; -import lombok.AllArgsConstructor; import lombok.Getter; import java.util.HashSet; @@ -36,7 +35,7 @@ public final class Flag & Flag.Value> implements EnumDispla public static final Flag COLOR = new Flag<>("COLOR", "FLAG_COLOR", ColorMode.class, ColorMode.YELLOW); public static final Flag TNT = new Flag<>("TNT", "FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB); - public static final Flag FIRE = new Flag<>("FIRE", "FLAG_FIRE", FireMode.class, FireMode.ALLOW); + public static final Flag FIRE = new Flag<>("FIRE", "FLAG_FIRE", FireMode.class, FireMode.DENY); public static final Flag FREEZE = new Flag<>("FREEZE", "FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE); public static final Flag PROTECT = new Flag<>("PROTECT", "FLAG_PROTECT", ProtectMode.class, ProtectMode.ACTIVE); public static final Flag ITEMS = new Flag<>("ITEMS", "FLAG_ITEMS", ItemMode.class, ItemMode.INACTIVE); diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedFlagStorage.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedFlagStorage.java index 7f083084..f2c05616 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedFlagStorage.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedFlagStorage.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.region; import de.steamwar.bausystem.region.flags.Flag; +import de.steamwar.core.Core; import lombok.NonNull; import java.io.File; @@ -37,17 +38,20 @@ public class FixedFlagStorage implements FlagStorage { @Override public @NonNull & Flag.Value> RegionFlagPolicy has(@NonNull Flag flag) { - return RegionFlagPolicy.NOT_APPLICABLE; + if (flag.oneOf(Flag.ITEMS) && Core.getVersion() < 20) { + return RegionFlagPolicy.NOT_APPLICABLE; + } + return RegionFlagPolicy.WRITABLE; } @Override public & Flag.Value> boolean set(@NonNull Flag flag, @NonNull T value) { - return false; + return flagMap.put(flag, value) != value; } @Override public @NonNull & Flag.Value> FlagOptional get(@NonNull Flag flag) { - return FlagOptional.of(flag); + return FlagOptional.of(flag, (T) flagMap.get(flag)); } @Override diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalFlagStorage.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalFlagStorage.java new file mode 100644 index 00000000..f20f9a02 --- /dev/null +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalFlagStorage.java @@ -0,0 +1,78 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 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.ColorMode; +import de.steamwar.bausystem.region.flags.Flag; +import de.steamwar.bausystem.region.flags.ProtectMode; +import de.steamwar.bausystem.region.flags.TNTMode; +import de.steamwar.core.Core; +import lombok.NonNull; + +import java.util.HashMap; +import java.util.Map; + +public class FixedGlobalFlagStorage implements FlagStorage { + + private Map, Flag.Value> flagMap = new HashMap<>(); + + public FixedGlobalFlagStorage() { + flagMap.put(Flag.TNT, TNTMode.DENY); + } + + @Override + public @NonNull & Flag.Value> RegionFlagPolicy has(@NonNull Flag flag) { + if (flag.oneOf(Flag.PROTECT, Flag.TESTBLOCK, Flag.NO_GRAVITY, Flag.CHANGED)) { + return RegionFlagPolicy.NOT_APPLICABLE; + } + if (flag.oneOf(Flag.ITEMS) && Core.getVersion() < 20) { + return RegionFlagPolicy.NOT_APPLICABLE; + } + if (flag.oneOf(Flag.COLOR)) { + return RegionFlagPolicy.READ_ONLY; + } + return RegionFlagPolicy.WRITABLE; + } + + @Override + public & Flag.Value> boolean set(@NonNull Flag flag, @NonNull T value) { + if (has(flag).isWritable()) { + return flagMap.put(flag, value) != value; + } else { + return false; + } + } + + @Override + public @NonNull & Flag.Value> FlagOptional get(@NonNull Flag flag) { + if (flag.oneOf(Flag.COLOR)) { + return FlagOptional.of((Flag) flag, ColorMode.YELLOW); + } + if (flag.oneOf(Flag.PROTECT)) { + return FlagOptional.of((Flag) flag, ProtectMode.INACTIVE); + } + return FlagOptional.of(flag, (T) flagMap.get(flag)); + } + + @Override + public void clear() { + flagMap.clear(); + } +} diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalRegion.java index b1545d48..ea9eb298 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalRegion.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalRegion.java @@ -36,7 +36,7 @@ public final class FixedGlobalRegion implements Region { private static final Point MIN_POINT = new Point(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE); private static final Point MAX_POINT = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); - private static final FlagStorage FLAG_STORAGE = FixedFlagStorage.createFromFile(null); // TODO: Update to either File or Region creation! + private static final FlagStorage FLAG_STORAGE = new FixedGlobalFlagStorage(); private static final UUID GLOBAL_REGION_ID = new UUID(0, 0); From 56680119e28be021e84095c33620dda1e8b8f2fa Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 31 Jul 2025 18:20:28 +0200 Subject: [PATCH 34/56] Fix ColorCommand --- .../src/de/steamwar/bausystem/features/region/ColorCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 436564ac..6c086ded 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 @@ -59,7 +59,7 @@ public class ColorCommand extends SWCommand { return; } Region region = Region.getRegion(p.getLocation()); - if (region.getType().isGlobal()) { + if (!region.getFlags().has(Flag.COLOR).isWritable()) { BauSystem.MESSAGE.send("REGION_COLOR_NO_REGION", p); return; } From 13ef13140133be9c2989ddb556ef1f307a4e1142 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 31 Jul 2025 21:44:24 +0200 Subject: [PATCH 35/56] Remove RegionSkins --- .../features/region/RegionCommand.java | 54 ----------- .../de/steamwar/bausystem/region/Region.java | 3 - .../bausystem/region/RegionSkins.java | 90 ------------------- .../bausystem/region/FixedGlobalRegion.java | 5 -- 4 files changed, 152 deletions(-) delete mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSkins.java 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 a0f2ca1c..54337983 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 @@ -30,30 +30,22 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.util.SelectCommand; import de.steamwar.bausystem.region.Point; import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.region.RegionSkins; import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.shared.Pair; import de.steamwar.bausystem.utils.FlatteningWrapper; import de.steamwar.bausystem.utils.PasteBuilder; import de.steamwar.bausystem.utils.WorldEditUtils; -import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; -import de.steamwar.command.TypeMapper; import de.steamwar.linkage.Linked; import de.steamwar.linkage.LinkedInstance; import de.steamwar.sql.SchematicNode; -import net.md_5.bungee.api.chat.ClickEvent; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerTeleportEvent; -import java.util.Collections; -import java.util.List; import java.util.logging.Level; -import java.util.stream.Collectors; @Linked public class RegionCommand extends SWCommand { @@ -170,31 +162,6 @@ public class RegionCommand extends SWCommand { BauSystem.MESSAGE.send("REGION_REGION_TP_TEST_BLOCK", p); } - @Register(value = "changeskin", description = "REGION_REGION_HELP_CHANGESKIN_INFO") - @Register("skin") - public void changeSkinCommand(Player p) { - Region region = Region.getRegion(p.getLocation()); - if (checkGlobalRegion(region, p)) { - return; - } - BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_INFO", p, region.getSkins().getCurrentSkin().getName()); - String creator = region.getSkins().getCurrentSkin().getCreator(); - if (creator != null) { - BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_INFO_CREATOR", p, creator); - } - } - - @Register(value = "changeskin", description = "REGION_REGION_HELP_CHANGESKIN") - @Register("skin") - public void changeSkinCommand(@Validator Player p, @Mapper("skinTypeMapper") @ErrorMessage("REGION_REGION_CHANGESKIN_UNKNOWN") RegionSkins.Skin skin) { - if (skin.apply()) { - BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_CHANGE", p, skin.getName()); - BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_CHANGE_UPDATE", p, BauSystem.MESSAGE.parse("REGION_REGION_CHANGESKIN_CHANGE_UPDATE_HOVER", p), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/reset")); - } else { - BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_INVALID", p); - } - } - @Register(value = "copy", description = "REGION_REGION_HELP_COPY") public void copyCommand(@Validator Player p, @OptionalValue("") @StaticValue(value = {"", "-e", "-s"}, allowISE = true) int option) { Region region = Region.getRegion(p.getLocation()); @@ -285,25 +252,4 @@ public class RegionCommand extends SWCommand { private BlockVector3 toBlockVector3(Point point) { return BlockVector3.at(point.getX(), point.getY(), point.getZ()); } - - - @Mapper(value = "skinTypeMapper", local = true) - private TypeMapper skinTypeMapper() { - return new TypeMapper() { - @Override - public List tabCompletes(CommandSender commandSender, PreviousArguments previousArguments, String s) { - Player p = (Player) commandSender; - Region region = Region.getRegion(p.getLocation()); - if (region.getType().isGlobal()) { - return Collections.emptyList(); - } - return region.getSkins().list().stream().map(skin -> skin.getName().replace(' ', '_')).collect(Collectors.toList()); - } - - @Override - public RegionSkins.Skin map(CommandSender commandSender, PreviousArguments previousArguments, String s) { - return Region.getRegion(((Player) commandSender).getLocation()).getSkins().get(s.replace('_', ' ')); - } - }; - } } 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 d2d97ecf..76dfeee1 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -71,9 +71,6 @@ public interface Region { @NonNull RegionBackups getBackups(); - @NonNull - RegionSkins getSkins(); - interface Area { Area EMPTY = new Area() { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSkins.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSkins.java deleted file mode 100644 index b9413d9f..00000000 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSkins.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2020 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 lombok.Getter; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - -import javax.annotation.CheckReturnValue; -import javax.annotation.Nullable; -import java.util.List; - -public interface RegionSkins { - - @RequiredArgsConstructor - @Getter - abstract class Skin { - @NonNull - private final String name; - - @NonNull - private final String creator; - - @CheckReturnValue - public abstract boolean apply(); - - public static final Skin GLOBAL = new Skin("Global", "§eSteam§8War") { - @Override - public boolean apply() { - return false; - } - }; - } - - @NonNull - Skin getCurrentSkin(); - - @NonNull - List list(); - - boolean has(@NonNull String name); - - @Nullable - Skin get(@NonNull String name); - - RegionSkins GLOBAL = new RegionSkins() { - - @Override - public @NonNull Skin getCurrentSkin() { - return Skin.GLOBAL; - } - - @Override - public @NonNull List list() { - return List.of(Skin.GLOBAL); - } - - @Override - public boolean has(@NonNull String name) { - return Skin.GLOBAL.name.equals(name); - } - - @Nullable - @Override - public Skin get(@NonNull String name) { - if (Skin.GLOBAL.name.equals(name)) { - return Skin.GLOBAL; - } else { - return null; - } - } - }; -} diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalRegion.java index ea9eb298..d00b5a2c 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalRegion.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalRegion.java @@ -136,9 +136,4 @@ public final class FixedGlobalRegion implements Region { public @NonNull RegionBackups getBackups() { return RegionBackups.EMPTY; } - - @Override - public @NonNull RegionSkins getSkins() { - return RegionSkins.GLOBAL; - } } From 7aff9f08d08604e00b9ad9f1bfaa0e20ce237184 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 1 Aug 2025 22:23:37 +0200 Subject: [PATCH 36/56] Remove old simulator loading --- .../src/de/steamwar/bausystem/worlddata/WorldData.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/worlddata/WorldData.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/worlddata/WorldData.java index 36a5297d..3300692c 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/worlddata/WorldData.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/worlddata/WorldData.java @@ -69,16 +69,6 @@ public class WorldData { // Ignored } } - - // Conversion from old simulator saving to new one - if (worldData.containsKey("simulators")) { - YAPIONObject yapionObject = worldData.getObject("simulators"); - worldData.remove("simulators"); - yapionObject.forEach((s, yapionAnyType) -> { - SteamwarUser steamwarUser = SteamwarUser.get(Integer.parseInt(s)); - SimulatorData.saveSimulator(steamwarUser, new YAPIONObject().add("", yapionAnyType)); - }); - } } public void write() { From 576ce891f63e3b6ebd2e8da0d8e69093333272f4 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 1 Aug 2025 22:25:06 +0200 Subject: [PATCH 37/56] Optimize WorldData --- .../src/de/steamwar/bausystem/worlddata/WorldData.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/worlddata/WorldData.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/worlddata/WorldData.java index 3300692c..bfbca11e 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/worlddata/WorldData.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/worlddata/WorldData.java @@ -19,7 +19,6 @@ package de.steamwar.bausystem.worlddata; -import de.steamwar.sql.SteamwarUser; import lombok.experimental.UtilityClass; import org.bukkit.Bukkit; import yapion.hierarchy.output.FileOutput; @@ -59,15 +58,11 @@ public class WorldData { if (optionsFile.length() != 0) { try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(optionsFile))) { worldData = YAPIONParser.parse(bufferedInputStream, new StreamOptions().charset(InputStreamCharsets.UTF_8)); - if (!worldData.containsKey("regions")) { - YAPIONObject yapionObject = new YAPIONObject(); - yapionObject.add("regions", worldData); - worldData = yapionObject; - write(); - } } catch (IOException e) { // Ignored } + } else { + write(); } } From 91a41ccd3fc7eaf1bc4a7e8c5ce82393501cdc38 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 1 Aug 2025 22:27:00 +0200 Subject: [PATCH 38/56] Add Prototype --- .../{regionold/Prototype.java.txt => region/Prototype.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/{regionold/Prototype.java.txt => region/Prototype.java} (100%) diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/Prototype.java.txt b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/Prototype.java similarity index 100% rename from BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/Prototype.java.txt rename to BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/Prototype.java From 38b061c12c8f437e9fb99c4830a9701f4b4a9b43 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 1 Aug 2025 22:32:55 +0200 Subject: [PATCH 39/56] Add JavaDoc to RegionSystem --- .../src/de/steamwar/bausystem/BauSystem.java | 9 +++++++- .../bausystem/region/RegionSystem.java | 21 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 4774565c..af84b780 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -40,6 +40,7 @@ import de.steamwar.bausystem.worlddata.WorldData; import de.steamwar.command.AbstractValidator; import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommandUtils; +import de.steamwar.core.CRIUSleepEvent; import de.steamwar.core.Core; import de.steamwar.core.WorldEditRendererCUIEditor; import de.steamwar.linkage.LinkedInstance; @@ -54,6 +55,7 @@ import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; @@ -72,7 +74,7 @@ import java.util.function.Consumer; import java.util.logging.Level; import java.util.stream.Collectors; -public class BauSystem extends JavaPlugin { +public class BauSystem extends JavaPlugin implements Listener { // This should be treated as final! public static Message MESSAGE; @@ -212,6 +214,11 @@ public class BauSystem extends JavaPlugin { new WorldEditRendererCUIEditor(); } + @EventHandler + public void onCRIUSleep(CRIUSleepEvent event) { + RegionSystem.INSTANCE.save(); + } + @Override public void onDisable() { instances.forEach((aClass, o) -> { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java index 5222a415..4289fb1b 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java @@ -32,18 +32,39 @@ public interface RegionSystem { RegionSystem INSTANCE = init(); + /** + * Loads and initializes the Regions and anything that should be loaded on startup. + */ void load(); + + /** + * Saves anything that should be written to file on either CRIUSleepEvent or plugin disable. + */ void save(); + /** + * Returns the GlobalRegion. This Region should have their {@link Region#getID()} return the + * '00000000-0000-0000-0000-000000000000' UUID for easier retrieval with {@link #getRegion(UUID)}. + */ @NonNull Region getGlobalRegion(); + /** + * Should return a Region that is present at the specific Location or the {@link #getGlobalRegion()} + * if none are present. + */ @NonNull Region get(@NonNull Location location); + /** + * Should return the Region by their UUID. + */ @CheckReturnValue Optional getRegion(@NonNull UUID id); + /** + * Does and should not contain the GlobalRegion returned by {@link #getGlobalRegion()}. + */ @NonNull Stream getRegions(); From 0763e4b18967b30febcf34b225276c95eb27f478 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 1 Aug 2025 22:34:51 +0200 Subject: [PATCH 40/56] Move some stuff around --- .../bausystem/region/FixedRegionSystem.java | 1 + .../region/{ => fixed}/FixedFlagStorage.java | 29 ++++++++++--------- .../{ => fixed}/FixedGlobalFlagStorage.java | 5 +++- .../region/{ => fixed}/FixedGlobalRegion.java | 27 ++++++++--------- .../region/{ => fixed}/Prototype.java | 6 ++-- .../regionold/loader/PrototypeLoader.java.txt | 2 +- .../regionold/loader/RegionLoader.java.txt | 2 +- 7 files changed, 41 insertions(+), 31 deletions(-) rename BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/{ => fixed}/FixedFlagStorage.java (55%) rename BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/{ => fixed}/FixedGlobalFlagStorage.java (92%) rename BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/{ => fixed}/FixedGlobalRegion.java (77%) rename BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/{ => fixed}/Prototype.java (98%) diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java index 473ec0d3..f9ca3d13 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.region; +import de.steamwar.bausystem.region.fixed.FixedGlobalRegion; import lombok.NonNull; import org.bukkit.Location; diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedFlagStorage.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java similarity index 55% rename from BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedFlagStorage.java rename to BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java index f2c05616..3de70483 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedFlagStorage.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java @@ -1,24 +1,27 @@ /* - * This file is a part of the SteamWar software. + * This file is a part of the SteamWar software. * - * Copyright (C) 2024 SteamWar.de-Serverteam + * Copyright (C) 2020 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 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. + * 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 . + * 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; +package de.steamwar.bausystem.region.fixed; +import de.steamwar.bausystem.region.FlagOptional; +import de.steamwar.bausystem.region.FlagStorage; +import de.steamwar.bausystem.region.RegionFlagPolicy; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.core.Core; import lombok.NonNull; diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalFlagStorage.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalFlagStorage.java similarity index 92% rename from BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalFlagStorage.java rename to BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalFlagStorage.java index f20f9a02..164b40e6 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalFlagStorage.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalFlagStorage.java @@ -17,8 +17,11 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.region; +package de.steamwar.bausystem.region.fixed; +import de.steamwar.bausystem.region.FlagOptional; +import de.steamwar.bausystem.region.FlagStorage; +import de.steamwar.bausystem.region.RegionFlagPolicy; import de.steamwar.bausystem.region.flags.ColorMode; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.ProtectMode; diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegion.java similarity index 77% rename from BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalRegion.java rename to BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegion.java index d00b5a2c..3dbcbdd4 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedGlobalRegion.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegion.java @@ -1,25 +1,26 @@ /* - * This file is a part of the SteamWar software. + * This file is a part of the SteamWar software. * - * Copyright (C) 2024 SteamWar.de-Serverteam + * Copyright (C) 2020 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 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. + * 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 . + * 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; +package de.steamwar.bausystem.region.fixed; import com.sk89q.worldedit.EditSession; +import de.steamwar.bausystem.region.*; import de.steamwar.bausystem.utils.PasteBuilder; import lombok.NonNull; import org.bukkit.Location; diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/Prototype.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/Prototype.java similarity index 98% rename from BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/Prototype.java rename to BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/Prototype.java index f4aefc56..962d9a19 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/Prototype.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/Prototype.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2020 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 @@ -17,8 +17,10 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.region; +package de.steamwar.bausystem.region.fixed; +import de.steamwar.bausystem.region.FlagStorage; +import de.steamwar.bausystem.region.Region; import lombok.AllArgsConstructor; import lombok.Getter; import yapion.hierarchy.types.YAPIONObject; diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/PrototypeLoader.java.txt b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/PrototypeLoader.java.txt index 851cdcfd..001ab702 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/PrototypeLoader.java.txt +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/PrototypeLoader.java.txt @@ -19,7 +19,7 @@ package de.steamwar.bausystem.region.loader; -import de.steamwar.bausystem.region.Prototype; +import de.steamwar.bausystem.region.fixed.Prototype; import lombok.experimental.UtilityClass; import org.bukkit.Bukkit; import yapion.hierarchy.diff.DiffDelete; diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/RegionLoader.java.txt b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/RegionLoader.java.txt index 7a66dbba..0fe7a16f 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/RegionLoader.java.txt +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/RegionLoader.java.txt @@ -21,7 +21,7 @@ package de.steamwar.bausystem.region.loader; import de.steamwar.bausystem.region.FlagStorage; import de.steamwar.bausystem.region.GlobalRegion; -import de.steamwar.bausystem.region.Prototype; +import de.steamwar.bausystem.region.fixed.Prototype; import de.steamwar.bausystem.worlddata.WorldData; import lombok.experimental.UtilityClass; import org.bukkit.Bukkit; From 144975d9771ea2fd6a314d203ab779cfd73fd16e Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sat, 2 Aug 2025 07:57:19 +0200 Subject: [PATCH 41/56] Remove TNTMode.ONLY_BUILD --- .../BauSystem_Main/src/BauSystem.properties | 2 - .../src/BauSystem_de.properties | 2 - .../bausystem/features/region/TNTCommand.java | 7 +- .../features/region/TNTListener.java | 5 -- .../features/region/items/TntBauGuiItem.java | 10 --- .../features/script/lua/libs/RegionLib.java | 1 - .../de/steamwar/bausystem/region/Region.java | 26 +++++- .../bausystem/region/flags/TNTMode.java | 3 +- .../region/fixed/FixedFlagStorage.java | 20 +++-- .../bausystem/region/fixed/FixedRegion.java | 80 +++++++++++++++++++ 10 files changed, 120 insertions(+), 36 deletions(-) create mode 100644 BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java diff --git a/BauSystem/BauSystem_Main/src/BauSystem.properties b/BauSystem/BauSystem_Main/src/BauSystem.properties index e7bf15eb..7ae8298b 100644 --- a/BauSystem/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem/BauSystem_Main/src/BauSystem.properties @@ -738,12 +738,10 @@ REGION_ITEM_RESET=§eReset REGION_ITEM_TESTBLOCK=§eDummy REGION_ITEM_TNT_OFF=§7TNT: §eDeactivated REGION_ITEM_TNT_ONLY_TB=§7TNT: §eonly dummy -REGION_ITEM_TNT_ONLY_BUILD=§7TNT: §eonly build REGION_ITEM_TNT_ON=§7TNT: §eActivated REGION_ITEM_SELECTOR_TITLE=Tnt Mode REGION_ITEM_SELECTOR_ON=§eActivate REGION_ITEM_SELECTOR_ONLY_TB=§eonly dummy -REGION_ITEM_SELECTOR_ONLY_BUILD=§eonly build REGION_ITEM_SELECTOR_OFF=§eDeactivate #Region REGION_COLOR_HELP_COLOR=§8/§ecolor §8[§7Color§8] §8- §7Sets the color of the region diff --git a/BauSystem/BauSystem_Main/src/BauSystem_de.properties b/BauSystem/BauSystem_Main/src/BauSystem_de.properties index 101eba76..1bcce497 100644 --- a/BauSystem/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem/BauSystem_Main/src/BauSystem_de.properties @@ -681,12 +681,10 @@ REGION_ITEM_RESET=§eReset REGION_ITEM_TESTBLOCK=§eTestblock REGION_ITEM_TNT_OFF=§7TNT: §eAusgeschaltet REGION_ITEM_TNT_ONLY_TB=§7TNT: §enur Testblock -REGION_ITEM_TNT_ONLY_BUILD=§7TNT: §enur Baubereich REGION_ITEM_TNT_ON=§7TNT: §eEingeschaltet REGION_ITEM_SELECTOR_TITLE=Tnt Modus REGION_ITEM_SELECTOR_ON=§eEinschalten REGION_ITEM_SELECTOR_ONLY_TB=§enur Testblock -REGION_ITEM_SELECTOR_ONLY_BUILD=§enur Baubereich REGION_ITEM_SELECTOR_OFF=§eAusschalten #Region REGION_COLOR_HELP_COLOR=§8/§ecolor §8[§7Color§8] §8- §7Setze die Farbe der Region 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 df5bd796..97abf0bc 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 @@ -72,9 +72,6 @@ public class TNTCommand extends SWCommand { case ONLY_TB: requestedMessage = getTestblockEnableMessage(); break; - case ONLY_BUILD: - requestedMessage = getBuildEnableMessage(); - break; } tntToggle(region, tntMode, requestedMessage); } @@ -90,9 +87,8 @@ public class TNTCommand extends SWCommand { Map tntModeMap = new HashMap<>(tntModeMapReduced); tntModeMap.put("testblock", TNTMode.ONLY_TB); tntModeMap.put("tb", TNTMode.ONLY_TB); - tntModeMap.put("build", TNTMode.ONLY_BUILD); - return new TypeMapper() { + return new TypeMapper<>() { @Override public List tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) { Region region = Region.getRegion(((Player) sender).getLocation()); @@ -140,7 +136,6 @@ public class TNTCommand extends SWCommand { switch (region.getFlags().get(Flag.TNT).getWithDefault()) { case ALLOW: case ONLY_TB: - case ONLY_BUILD: region.getFlags().set(Flag.TNT, TNTMode.DENY); RegionUtils.actionBar(region, getDisableMessage()); break; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java index 791a9cb1..285b2a7f 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java @@ -50,11 +50,6 @@ public class TNTListener implements Listener, ScoreboardElement { RegionUtils.actionBar(region, "REGION_TNT_BUILD_DESTROY"); return true; } - } else if (value == TNTMode.ONLY_BUILD) { - if (region.getTestblockArea().inRegion(block.getLocation(), true)) { - RegionUtils.actionBar(region, "REGION_TNT_TB_DESTROY"); - return true; - } } return value == TNTMode.DENY; }); 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 c633c569..2205cf10 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 @@ -25,7 +25,6 @@ import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.TNTMode; -import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import de.steamwar.linkage.Linked; @@ -48,8 +47,6 @@ public class TntBauGuiItem extends BauGuiItem { return new SWItem(Material.MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_OFF", player)).getItemStack(); case ONLY_TB: return new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_ONLY_TB", player)).getItemStack(); - case ONLY_BUILD: - return new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_ONLY_BUILD", player)).getItemStack(); default: return new SWItem(Material.TNT, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_ON", player)).getItemStack(); } @@ -82,10 +79,6 @@ public class TntBauGuiItem extends BauGuiItem { updateTntMode(TNTMode.ONLY_TB, p); p.closeInventory(); })); - selector.setItem(5, new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_SELECTOR_ONLY_BUILD", p), clickType -> { - updateTntMode(TNTMode.ONLY_BUILD, p); - p.closeInventory(); - })); } selector.setItem(7, new SWItem(Material.MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_SELECTOR_OFF", p), clickType -> { updateTntMode(TNTMode.DENY, p); @@ -101,9 +94,6 @@ public class TntBauGuiItem extends BauGuiItem { case ONLY_TB: p.performCommand("tnt tb"); break; - case ONLY_BUILD: - p.performCommand("tnt build"); - break; case ALLOW: p.performCommand("tnt on"); break; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/RegionLib.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/RegionLib.java index 52c97c21..474a5b1f 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/RegionLib.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/RegionLib.java @@ -57,7 +57,6 @@ public class RegionLib implements LuaLib { tntLib.set("mode", getter(() -> region.get().getFlags().get(Flag.TNT).nameWithDefault())); tntLib.set("enabled", getter(() -> region.get().getFlags().get(Flag.TNT).orElse(null) != TNTMode.DENY)); tntLib.set("onlyTb", getter(() -> region.get().getFlags().get(Flag.TNT).orElse(null) == TNTMode.ONLY_TB)); - tntLib.set("onlyBuild", getter(() -> region.get().getFlags().get(Flag.TNT).orElse(null) == TNTMode.ONLY_BUILD)); table.set("tnt", tntLib); table.set("fire", getter(() -> region.get().getFlags().get(Flag.FIRE).orElse(null) == FireMode.ALLOW)); 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 76dfeee1..bad3b0ef 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -136,7 +136,14 @@ public interface Region { @NonNull Point getCopyPoint(); - boolean inRegion(Location location, boolean extension); + default boolean inRegion(Location location, boolean extension) { + Point minPoint = getMinPoint(extension); + Point maxPoint = getMaxPoint(extension); + if (location.getBlockX() < minPoint.getX() || location.getBlockX() > maxPoint.getX()) return false; + if (location.getBlockY() < minPoint.getY() || location.getBlockY() > maxPoint.getY()) return false; + if (location.getBlockZ() < minPoint.getZ() || location.getBlockZ() > maxPoint.getZ()) return false; + return true; + } @Nullable EditSession copy(boolean extension); @@ -146,8 +153,21 @@ public interface Region { void reset(PasteBuilder pasteBuilder, boolean extension); - void forEachChunk(BiConsumer executor); + default void forEachChunk(BiConsumer executor) { + Point minPoint = getMinPoint(false); + Point maxPoint = getMaxPoint(false); + for (int x = (int) Math.floor(minPoint.getX() / 16.0); x <= (int) Math.ceil(maxPoint.getX() / 16.0); x++) { + for (int z = (int) Math.floor(minPoint.getZ() / 16.0); z <= (int) Math.ceil(maxPoint.getZ() / 16.0); z++) { + executor.accept(x, z); + } + } + } - boolean isChunkOutside(int chunkX, int chunkZ); + default boolean isChunkOutside(int chunkX, int chunkZ) { + Point minPoint = getMinPoint(true); + Point maxPoint = getMaxPoint(true); + return Math.floor(minPoint.getX() / 16.0) > chunkX || chunkX >= Math.ceil(maxPoint.getX() / 16.0) || + Math.floor(minPoint.getZ() / 16.0) > chunkZ || chunkZ >= Math.ceil(maxPoint.getZ() / 16.0); + } } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/TNTMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/TNTMode.java index 0f73f81b..fe343707 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/TNTMode.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/TNTMode.java @@ -28,8 +28,7 @@ public enum TNTMode implements Flag.Value { ALLOW("FLAG_TNT_ALLOW"), DENY("FLAG_TNT_DENY"), - ONLY_TB("FLAG_TNT_ONLY_TB"), - ONLY_BUILD("FLAG_TNT_ONLY_BUILD"); + ONLY_TB("FLAG_TNT_ONLY_TB"); private static TNTMode[] values; private final String chatValue; diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java index 3de70483..6893f904 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java @@ -23,20 +23,20 @@ import de.steamwar.bausystem.region.FlagOptional; import de.steamwar.bausystem.region.FlagStorage; import de.steamwar.bausystem.region.RegionFlagPolicy; import de.steamwar.bausystem.region.flags.Flag; +import de.steamwar.bausystem.region.flags.TestblockMode; import de.steamwar.core.Core; import lombok.NonNull; -import java.io.File; import java.util.HashMap; import java.util.Map; public class FixedFlagStorage implements FlagStorage { + private TestblockMode testBlockMode; private Map, Flag.Value> flagMap = new HashMap<>(); - public static FlagStorage createFromFile(File file) { - // throw new IllegalStateException("Not implemented yet"); - return new FixedFlagStorage(); + public FixedFlagStorage(TestblockMode testblockMode) { + this.testBlockMode = testblockMode; } @Override @@ -44,16 +44,26 @@ public class FixedFlagStorage implements FlagStorage { if (flag.oneOf(Flag.ITEMS) && Core.getVersion() < 20) { return RegionFlagPolicy.NOT_APPLICABLE; } + if (flag.oneOf(Flag.TESTBLOCK)) { + return RegionFlagPolicy.READ_ONLY; + } return RegionFlagPolicy.WRITABLE; } @Override public & Flag.Value> boolean set(@NonNull Flag flag, @NonNull T value) { - return flagMap.put(flag, value) != value; + if (has(flag).isWritable()) { + return flagMap.put(flag, value) != value; + } else { + return false; + } } @Override public @NonNull & Flag.Value> FlagOptional get(@NonNull Flag flag) { + if (flag.oneOf(Flag.TESTBLOCK)) { + return FlagOptional.of((Flag) flag, testBlockMode); + } return FlagOptional.of(flag, (T) flagMap.get(flag)); } diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java new file mode 100644 index 00000000..e008fab7 --- /dev/null +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java @@ -0,0 +1,80 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 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.fixed; + +import de.steamwar.bausystem.region.*; +import lombok.NonNull; + +import java.nio.charset.StandardCharsets; +import java.util.UUID; + +public class FixedRegion implements Region { + + private UUID uuid; + + public FixedRegion(String name) { + uuid = UUID.nameUUIDFromBytes(name.getBytes(StandardCharsets.UTF_8)); + } + + @Override + public @NonNull UUID getID() { + return uuid; + } + + @Override + public @NonNull RegionType getType() { + return RegionType.NORMAL; + } + + @Override + public @NonNull FlagStorage getFlags() { + return null; + } + + @Override + public @NonNull Area getArea() { + return null; + } + + @Override + public @NonNull Area getBuildArea() { + return null; + } + + @Override + public @NonNull Area getTestblockArea() { + return null; + } + + @Override + public @NonNull RegionConfig getGameModeConfig() { + return null; + } + + @Override + public @NonNull RegionHistory getHistory() { + return null; + } + + @Override + public @NonNull RegionBackups getBackups() { + return null; + } +} From bc371df796b54b288cca07b7cd56ab53b34e72ee Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sat, 2 Aug 2025 08:01:25 +0200 Subject: [PATCH 42/56] Rework FixedFlagStorage and FixedGlobalFlagStorage to not be sensitive on adding a new Flag --- .../bausystem/region/fixed/FixedFlagStorage.java | 9 ++++++--- .../region/fixed/FixedGlobalFlagStorage.java | 14 +++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java index 6893f904..b9abc5b3 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java @@ -41,13 +41,16 @@ public class FixedFlagStorage implements FlagStorage { @Override public @NonNull & Flag.Value> RegionFlagPolicy has(@NonNull Flag flag) { - if (flag.oneOf(Flag.ITEMS) && Core.getVersion() < 20) { - return RegionFlagPolicy.NOT_APPLICABLE; + if (flag.oneOf(Flag.COLOR, Flag.TNT, Flag.FIRE, Flag.FREEZE, Flag.PROTECT, Flag.NO_GRAVITY, Flag.CHANGED)) { + return RegionFlagPolicy.WRITABLE; + } + if (flag.oneOf(Flag.ITEMS) && Core.getVersion() >= 20) { + return RegionFlagPolicy.WRITABLE; } if (flag.oneOf(Flag.TESTBLOCK)) { return RegionFlagPolicy.READ_ONLY; } - return RegionFlagPolicy.WRITABLE; + return RegionFlagPolicy.NOT_APPLICABLE; } @Override diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalFlagStorage.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalFlagStorage.java index 164b40e6..9017cf96 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalFlagStorage.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalFlagStorage.java @@ -42,16 +42,16 @@ public class FixedGlobalFlagStorage implements FlagStorage { @Override public @NonNull & Flag.Value> RegionFlagPolicy has(@NonNull Flag flag) { - if (flag.oneOf(Flag.PROTECT, Flag.TESTBLOCK, Flag.NO_GRAVITY, Flag.CHANGED)) { - return RegionFlagPolicy.NOT_APPLICABLE; - } - if (flag.oneOf(Flag.ITEMS) && Core.getVersion() < 20) { - return RegionFlagPolicy.NOT_APPLICABLE; - } if (flag.oneOf(Flag.COLOR)) { return RegionFlagPolicy.READ_ONLY; } - return RegionFlagPolicy.WRITABLE; + if (flag.oneOf(Flag.ITEMS) && Core.getVersion() >= 20) { + return RegionFlagPolicy.WRITABLE; + } + if (flag.oneOf(Flag.TNT, Flag.FIRE, Flag.FREEZE)) { + return RegionFlagPolicy.WRITABLE; + } + return RegionFlagPolicy.NOT_APPLICABLE; } @Override From 811bd00ed2f343659d32ec0e75215f67a87d674d Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sat, 2 Aug 2025 08:13:21 +0200 Subject: [PATCH 43/56] Fix Flag.Value to have enum methods for save/load --- .../src/de/steamwar/bausystem/region/FlagStorage.java | 4 ++++ .../src/de/steamwar/bausystem/region/flags/Flag.java | 4 ++++ .../steamwar/bausystem/region/fixed/FixedFlagStorage.java | 5 +++++ .../bausystem/region/fixed/FixedGlobalFlagStorage.java | 5 +++++ .../de/steamwar/bausystem/region/fixed/FixedRegion.java | 8 ++++++-- 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java index d6f1afd5..72e80301 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java @@ -22,6 +22,8 @@ package de.steamwar.bausystem.region; import de.steamwar.bausystem.region.flags.Flag; import lombok.NonNull; +import java.util.Map; + public interface FlagStorage { @NonNull @@ -33,4 +35,6 @@ public interface FlagStorage { & Flag.Value> FlagOptional get(@NonNull Flag flag); void clear(); + + Map, Flag.Value> getBackedMap(); } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java index ddee1806..2be75d1f 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java @@ -89,6 +89,10 @@ public final class Flag & Flag.Value> implements EnumDispla public interface Value & Value> extends EnumDisplay { + String name(); + + int ordinal(); + T getValue(); T getValueOf(final String name); diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java index b9abc5b3..71aee78e 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java @@ -74,4 +74,9 @@ public class FixedFlagStorage implements FlagStorage { public void clear() { flagMap.clear(); } + + @Override + public Map, Flag.Value> getBackedMap() { + return flagMap; + } } diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalFlagStorage.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalFlagStorage.java index 9017cf96..acf9975a 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalFlagStorage.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalFlagStorage.java @@ -78,4 +78,9 @@ public class FixedGlobalFlagStorage implements FlagStorage { public void clear() { flagMap.clear(); } + + @Override + public Map, Flag.Value> getBackedMap() { + return flagMap; + } } diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java index e008fab7..2f914dc5 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java @@ -28,9 +28,13 @@ import java.util.UUID; public class FixedRegion implements Region { private UUID uuid; + private FixedFlagStorage flagStorage; + private Prototype prototype; - public FixedRegion(String name) { + public FixedRegion(String name, FixedFlagStorage flagStorage, Prototype prototype) { uuid = UUID.nameUUIDFromBytes(name.getBytes(StandardCharsets.UTF_8)); + this.flagStorage = flagStorage; + this.prototype = prototype; } @Override @@ -45,7 +49,7 @@ public class FixedRegion implements Region { @Override public @NonNull FlagStorage getFlags() { - return null; + return flagStorage; } @Override From 5550aa49305c51953cc4f02135c464de3ed08507 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sat, 2 Aug 2025 08:31:38 +0200 Subject: [PATCH 44/56] Make FixedGlobalFlagStorage load the options from file --- .../steamwar/bausystem/region/flags/Flag.java | 19 +++++++++++++ .../bausystem/region/FixedRegionSystem.java | 6 +++-- .../region/fixed/FixedGlobalFlagStorage.java | 17 +++++++++++- .../region/fixed/FixedGlobalRegion.java | 4 ++- .../bausystem/region/fixed/Prototype.java | 27 ++++++++++--------- .../fixed/loader/PrototypeLoader.java} | 4 +-- .../fixed/loader/RegionLoader.java} | 16 ++++------- 7 files changed, 63 insertions(+), 30 deletions(-) rename BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/{regionold/loader/PrototypeLoader.java.txt => region/fixed/loader/PrototypeLoader.java} (95%) rename BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/{regionold/loader/RegionLoader.java.txt => region/fixed/loader/RegionLoader.java} (85%) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java index 2be75d1f..305d046c 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.region.flags; import de.steamwar.bausystem.shared.EnumDisplay; import lombok.Getter; +import lombok.NonNull; import java.util.HashSet; import java.util.Set; @@ -70,6 +71,24 @@ public final class Flag & Flag.Value> implements EnumDispla this.values = defaultValue.getValues(); } + public static Flag valueOf(@NonNull String name) { + for (Flag flag : flags) { + if (flag.name.equalsIgnoreCase(name)) { + return flag; + } + } + throw new IllegalArgumentException("No enum constant Flag." + name); + } + + public Flag.Value valueOfValue(@NonNull String name) { + for (Flag.Value value : values) { + if (value.name().equalsIgnoreCase(name)) { + return value; + } + } + throw new IllegalArgumentException("No enum constant Flag." + this.name + "." + name); + } + public String name() { return name; } diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java index f9ca3d13..68f3cd18 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java @@ -20,6 +20,8 @@ package de.steamwar.bausystem.region; import de.steamwar.bausystem.region.fixed.FixedGlobalRegion; +import de.steamwar.bausystem.region.fixed.loader.PrototypeLoader; +import de.steamwar.bausystem.region.fixed.loader.RegionLoader; import lombok.NonNull; import org.bukkit.Location; @@ -35,12 +37,12 @@ public class FixedRegionSystem implements RegionSystem { @Override public void load() { - // TODO: Implement + PrototypeLoader.load(); + RegionLoader.load(); } @Override public void save() { - // TODO: Implement } @Override diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalFlagStorage.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalFlagStorage.java index acf9975a..910483cb 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalFlagStorage.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalFlagStorage.java @@ -26,8 +26,10 @@ import de.steamwar.bausystem.region.flags.ColorMode; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.ProtectMode; import de.steamwar.bausystem.region.flags.TNTMode; +import de.steamwar.bausystem.worlddata.WorldData; import de.steamwar.core.Core; import lombok.NonNull; +import yapion.hierarchy.types.YAPIONObject; import java.util.HashMap; import java.util.Map; @@ -35,9 +37,20 @@ import java.util.Map; public class FixedGlobalFlagStorage implements FlagStorage { private Map, Flag.Value> flagMap = new HashMap<>(); + private YAPIONObject data; - public FixedGlobalFlagStorage() { + public FixedGlobalFlagStorage(YAPIONObject data) { flagMap.put(Flag.TNT, TNTMode.DENY); + this.data = data; + for (final Flag flag : Flag.getFlags()) { + if (!has(flag).isWritable()) continue; + try { + String s = data.getPlainValue(flag.name()); + flagMap.put(flag, flag.valueOfValue(s)); + } catch (Exception e) { + flagMap.put(flag, (Flag.Value) flag.getDefaultValue()); + } + } } @Override @@ -57,6 +70,8 @@ public class FixedGlobalFlagStorage implements FlagStorage { @Override public & Flag.Value> boolean set(@NonNull Flag flag, @NonNull T value) { if (has(flag).isWritable()) { + data.put(flag.name(), value.name()); + WorldData.write(); return flagMap.put(flag, value) != value; } else { return false; diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegion.java index 3dbcbdd4..9204489e 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegion.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegion.java @@ -23,6 +23,7 @@ import com.sk89q.worldedit.EditSession; import de.steamwar.bausystem.region.*; import de.steamwar.bausystem.utils.PasteBuilder; import lombok.NonNull; +import lombok.Setter; import org.bukkit.Location; import javax.annotation.Nullable; @@ -37,7 +38,8 @@ public final class FixedGlobalRegion implements Region { private static final Point MIN_POINT = new Point(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE); private static final Point MAX_POINT = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); - private static final FlagStorage FLAG_STORAGE = new FixedGlobalFlagStorage(); + @Setter + private static FlagStorage FLAG_STORAGE; private static final UUID GLOBAL_REGION_ID = new UUID(0, 0); diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/Prototype.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/Prototype.java index 962d9a19..2569b03c 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/Prototype.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/Prototype.java @@ -127,11 +127,11 @@ public class Prototype { skinMap.put(displayName, new Skin(defaultSkin, null, schematicFile, testblockSchematicFile, buildSchematicFile)); } - if (PROTOTYPE_MAP.containsKey(name)) { - Region.getRegion(PROTOTYPE_MAP.remove(name)).forEach(region -> { - region._setPrototype(this); - }); - } + // if (PROTOTYPE_MAP.containsKey(name)) { + // Region.getRegion(PROTOTYPE_MAP.remove(name)).forEach(region -> { + // region._setPrototype(this); + // }); + // } PROTOTYPE_MAP.put(name, this); } @@ -210,19 +210,20 @@ public class Prototype { } } - public static Region generateRegion(String name, YAPIONObject regionConfig, YAPIONObject regionData) { + public static void generateRegion(String name, YAPIONObject regionConfig, YAPIONObject regionData) { Prototype prototype; if (regionData.containsKey("prototype", String.class)) { prototype = PROTOTYPE_MAP.get(regionData.getPlainValue("prototype")); } else { prototype = PROTOTYPE_MAP.get(regionConfig.getPlainValue("prototype")); } - FlagStorage flagStorage; - if (regionData.containsKey("flagStorage", YAPIONType.OBJECT)) { - flagStorage = FlagStorage.createStorage(regionData.getObject("flagStorage")); - } else { - flagStorage = new FlagStorage(); - } - return new Region(name, prototype, regionConfig, flagStorage, regionData); + System.out.println(name + " " + prototype); + // FlagStorage flagStorage; + // if (regionData.containsKey("flagStorage", YAPIONType.OBJECT)) { + // flagStorage = FlagStorage.createStorage(regionData.getObject("flagStorage")); + // } else { + // flagStorage = new FlagStorage(); + // } + // return new Region(name, prototype, regionConfig, flagStorage, regionData); } } diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/PrototypeLoader.java.txt b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/loader/PrototypeLoader.java similarity index 95% rename from BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/PrototypeLoader.java.txt rename to BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/loader/PrototypeLoader.java index 001ab702..3bcdefff 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/PrototypeLoader.java.txt +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/loader/PrototypeLoader.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2020 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 @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.region.loader; +package de.steamwar.bausystem.region.fixed.loader; import de.steamwar.bausystem.region.fixed.Prototype; import lombok.experimental.UtilityClass; diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/RegionLoader.java.txt b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/loader/RegionLoader.java similarity index 85% rename from BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/RegionLoader.java.txt rename to BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/loader/RegionLoader.java index 0fe7a16f..e88c24e6 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/RegionLoader.java.txt +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/loader/RegionLoader.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2020 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 @@ -17,10 +17,10 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.region.loader; +package de.steamwar.bausystem.region.fixed.loader; -import de.steamwar.bausystem.region.FlagStorage; -import de.steamwar.bausystem.region.GlobalRegion; +import de.steamwar.bausystem.region.fixed.FixedGlobalFlagStorage; +import de.steamwar.bausystem.region.fixed.FixedGlobalRegion; import de.steamwar.bausystem.region.fixed.Prototype; import de.steamwar.bausystem.worlddata.WorldData; import lombok.experimental.UtilityClass; @@ -80,12 +80,6 @@ public class RegionLoader { globalOptions = new YAPIONObject(); optionsYapionObject.add("global", globalOptions); } - FlagStorage flagStorage; - if (globalOptions.containsKey("flagStorage", YAPIONType.OBJECT)) { - flagStorage = FlagStorage.createStorage(globalOptions.getObject("flagStorage")); - } else { - flagStorage = new FlagStorage(); - } - new GlobalRegion(flagStorage, globalOptions); + FixedGlobalRegion.setFLAG_STORAGE(new FixedGlobalFlagStorage(globalOptions.getObjectOrSetDefault("flagStorage", new YAPIONObject()))); } } From 0a4dccd95a87830186d93680ba7fee0a13525d8f Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sat, 2 Aug 2025 08:33:14 +0200 Subject: [PATCH 45/56] Fix WarpListener --- .../src/de/steamwar/bausystem/features/warp/WarpListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 655b36f9..1d06c9e4 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,10 +91,10 @@ public class WarpListener implements Listener { locations.put(warp.getName(), warp.getLocation()); }); Region region = Region.getRegion(p.getLocation()); - if (region.getBuildArea().getCopyPoint() != null) { + if (!region.getBuildArea().isEmpty()) { locations.put("Copy", region.getBuildArea().getCopyPoint().toLocation(p).add(0.5, 0, 0.5)); } - if (region.getTestblockArea().getCopyPoint() != null) { + if (!region.getTestblockArea().isEmpty()) { locations.put("TestBlock", region.getTestblockArea().getCopyPoint().toLocation(p).add(0.5, 0, 0.5)); } } From 30db0bb7184aefb467579bbacf76b19bce950efd Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sat, 2 Aug 2025 08:35:44 +0200 Subject: [PATCH 46/56] Fix Warp.enable --- .../src/de/steamwar/bausystem/features/warp/Warp.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/Warp.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/Warp.java index a1392917..0417bb28 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/Warp.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/Warp.java @@ -20,7 +20,6 @@ package de.steamwar.bausystem.features.warp; import de.steamwar.bausystem.worlddata.WorldData; -import de.steamwar.core.Core; import lombok.Getter; import org.bukkit.*; import org.bukkit.entity.Player; @@ -36,7 +35,8 @@ public class Warp { public static void enable() { Warp worldSpawn = new Warp("WorldSpawn"); - worldSpawn.setLocation(Bukkit.getWorlds().get(0).getSpawnLocation().clone().add(0.5, Core.getVersion() >= 20 ? 124 : 1, 0.5)); + Location spawnPoint = Bukkit.getWorlds().get(0).getHighestBlockAt(org.bukkit.Bukkit.getWorlds().get(0).getSpawnLocation()).getLocation(); + worldSpawn.setLocation(spawnPoint.add(0.5, 1, 0.5)); worldSpawn.setMat(Material.NETHER_STAR); warpMap.put("WorldSpawn", worldSpawn); } From 06de120fe12a98b5ab7a1e5068b44cf9cee6a842 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sat, 2 Aug 2025 08:39:46 +0200 Subject: [PATCH 47/56] Add RegionSystem.getWorldSpawn Fix Warp Update FixedRegionSystem --- .../src/de/steamwar/bausystem/features/warp/Warp.java | 4 ++-- .../src/de/steamwar/bausystem/region/RegionSystem.java | 6 ++++++ .../de/steamwar/bausystem/region/FixedRegionSystem.java | 8 ++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/Warp.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/Warp.java index 0417bb28..8b1b1ee7 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/Warp.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/Warp.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.warp; +import de.steamwar.bausystem.region.RegionSystem; import de.steamwar.bausystem.worlddata.WorldData; import lombok.Getter; import org.bukkit.*; @@ -35,8 +36,7 @@ public class Warp { public static void enable() { Warp worldSpawn = new Warp("WorldSpawn"); - Location spawnPoint = Bukkit.getWorlds().get(0).getHighestBlockAt(org.bukkit.Bukkit.getWorlds().get(0).getSpawnLocation()).getLocation(); - worldSpawn.setLocation(spawnPoint.add(0.5, 1, 0.5)); + worldSpawn.setLocation(RegionSystem.INSTANCE.getWorldSpawn()); worldSpawn.setMat(Material.NETHER_STAR); warpMap.put("WorldSpawn", worldSpawn); } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java index 4289fb1b..b476bfd2 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java @@ -42,6 +42,12 @@ public interface RegionSystem { */ void save(); + /** + * Returns the Location to teleport players to when they first join or Warp to "WorldSpawn" + */ + @NonNull + Location getWorldSpawn(); + /** * Returns the GlobalRegion. This Region should have their {@link Region#getID()} return the * '00000000-0000-0000-0000-000000000000' UUID for easier retrieval with {@link #getRegion(UUID)}. diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java index 68f3cd18..22ca45c5 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java @@ -23,6 +23,7 @@ import de.steamwar.bausystem.region.fixed.FixedGlobalRegion; import de.steamwar.bausystem.region.fixed.loader.PrototypeLoader; import de.steamwar.bausystem.region.fixed.loader.RegionLoader; import lombok.NonNull; +import org.bukkit.Bukkit; import org.bukkit.Location; import java.util.HashMap; @@ -45,6 +46,13 @@ public class FixedRegionSystem implements RegionSystem { public void save() { } + @Override + public @NonNull Location getWorldSpawn() { + Location spawnLocation = Bukkit.getWorlds().get(0).getSpawnLocation(); + Location spawnPoint = Bukkit.getWorlds().get(0).getHighestBlockAt(spawnLocation).getLocation(); + return spawnPoint.add(0.5, 1, 0.5); + } + @Override public Region getGlobalRegion() { return FixedGlobalRegion.INSTANCE; From 9e0e3392779dd5535941ecae156655825cd755c8 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sat, 2 Aug 2025 08:43:48 +0200 Subject: [PATCH 48/56] Finish FixedFlagStorage --- .../region/fixed/FixedFlagStorage.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java index 71aee78e..c382f547 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java @@ -24,8 +24,10 @@ import de.steamwar.bausystem.region.FlagStorage; import de.steamwar.bausystem.region.RegionFlagPolicy; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.TestblockMode; +import de.steamwar.bausystem.worlddata.WorldData; import de.steamwar.core.Core; import lombok.NonNull; +import yapion.hierarchy.types.YAPIONObject; import java.util.HashMap; import java.util.Map; @@ -34,9 +36,20 @@ public class FixedFlagStorage implements FlagStorage { private TestblockMode testBlockMode; private Map, Flag.Value> flagMap = new HashMap<>(); + private YAPIONObject data; - public FixedFlagStorage(TestblockMode testblockMode) { + public FixedFlagStorage(TestblockMode testblockMode, YAPIONObject data) { this.testBlockMode = testblockMode; + this.data = data; + for (final Flag flag : Flag.getFlags()) { + if (!has(flag).isWritable()) continue; + try { + String s = data.getPlainValue(flag.name()); + flagMap.put(flag, flag.valueOfValue(s)); + } catch (Exception e) { + flagMap.put(flag, (Flag.Value) flag.getDefaultValue()); + } + } } @Override @@ -56,6 +69,8 @@ public class FixedFlagStorage implements FlagStorage { @Override public & Flag.Value> boolean set(@NonNull Flag flag, @NonNull T value) { if (has(flag).isWritable()) { + data.put(flag.name(), value.name()); + WorldData.write(); return flagMap.put(flag, value) != value; } else { return false; From ecb9571624836fe6893c3df6acf4fb7a4c459cb8 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sat, 2 Aug 2025 08:49:56 +0200 Subject: [PATCH 49/56] Add toString() methods --- .../de/steamwar/bausystem/region/RegionSystem.java | 5 +++++ .../src/de/steamwar/bausystem/region/flags/Flag.java | 5 +++++ .../bausystem/region/fixed/FixedFlagStorage.java | 7 +++++++ .../region/fixed/FixedGlobalFlagStorage.java | 7 +++++++ .../de/steamwar/bausystem/region/fixed/Prototype.java | 11 +++-------- 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java index b476bfd2..bc37f66f 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java @@ -92,6 +92,11 @@ public interface RegionSystem { throw new UnsupportedOperationException(); } + @Override + public @NonNull Location getWorldSpawn() { + throw new UnsupportedOperationException(); + } + @Override public Region getGlobalRegion() { throw new UnsupportedOperationException(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java index 305d046c..19a5082f 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java @@ -106,6 +106,11 @@ public final class Flag & Flag.Value> implements EnumDispla return false; } + @Override + public String toString() { + return name; + } + public interface Value & Value> extends EnumDisplay { String name(); diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java index c382f547..5a26c0fa 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java @@ -94,4 +94,11 @@ public class FixedFlagStorage implements FlagStorage { public Map, Flag.Value> getBackedMap() { return flagMap; } + + @Override + public String toString() { + return "FixedFlagStorage{" + + "flagMap=" + flagMap + + '}'; + } } diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalFlagStorage.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalFlagStorage.java index 910483cb..d699eb08 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalFlagStorage.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalFlagStorage.java @@ -98,4 +98,11 @@ public class FixedGlobalFlagStorage implements FlagStorage { public Map, Flag.Value> getBackedMap() { return flagMap; } + + @Override + public String toString() { + return "FixedGlobalFlagStorage{" + + "flagMap=" + flagMap + + '}'; + } } diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/Prototype.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/Prototype.java index 2569b03c..804e25f4 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/Prototype.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/Prototype.java @@ -20,7 +20,7 @@ package de.steamwar.bausystem.region.fixed; import de.steamwar.bausystem.region.FlagStorage; -import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.flags.TestblockMode; import lombok.AllArgsConstructor; import lombok.Getter; import yapion.hierarchy.types.YAPIONObject; @@ -217,13 +217,8 @@ public class Prototype { } else { prototype = PROTOTYPE_MAP.get(regionConfig.getPlainValue("prototype")); } - System.out.println(name + " " + prototype); - // FlagStorage flagStorage; - // if (regionData.containsKey("flagStorage", YAPIONType.OBJECT)) { - // flagStorage = FlagStorage.createStorage(regionData.getObject("flagStorage")); - // } else { - // flagStorage = new FlagStorage(); - // } + FlagStorage flagStorage = new FixedFlagStorage(TestblockMode.NO_VALUE, regionData.getObjectOrSetDefault("flagStorage", new YAPIONObject())); + System.out.println(name + " " + prototype + " " + flagStorage); // return new Region(name, prototype, regionConfig, flagStorage, regionData); } } From 06333d634e3f28a81786bb474819c821463f67c4 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sat, 2 Aug 2025 12:35:11 +0200 Subject: [PATCH 50/56] Fix RegionConfig Implement FixedRegion Add RegionHistory.Impl --- .../bausystem/region/RegionConfig.java | 3 +- .../bausystem/region/RegionHistory.java | 44 ++++ .../steamwar/bausystem/shared/SizedStack.java | 6 + .../bausystem/region/FixedRegionSystem.java | 4 + .../region/fixed/FixedFlagStorage.java | 8 +- .../bausystem/region/fixed/FixedRegion.java | 204 +++++++++++++++++- .../bausystem/region/fixed/Prototype.java | 8 +- 7 files changed, 257 insertions(+), 20 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionConfig.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionConfig.java index 5c7da406..71e347c6 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionConfig.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionConfig.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.region; +import de.steamwar.core.FlatteningWrapper; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -117,7 +118,7 @@ public class RegionConfig { private void load(ConfigurationSection section) { Active = section.getBoolean("Active", false); ObfuscateWith = Material.getMaterial(section.getString("ObfuscateWith", "END_STONE")); - HiddenBlocks = section.getStringList("HiddenBlocks").stream().map(Material::getMaterial).collect(Collectors.toUnmodifiableSet()); + HiddenBlocks = section.getStringList("HiddenBlocks").stream().map(FlatteningWrapper.impl::getMaterial).filter(Objects::nonNull).collect(Collectors.toUnmodifiableSet()); HiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(section.getStringList("HiddenBlockEntities"))); } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionHistory.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionHistory.java index 2eb79247..ef597cd2 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionHistory.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionHistory.java @@ -20,7 +20,11 @@ package de.steamwar.bausystem.region; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.bukkit.BukkitWorld; +import de.steamwar.bausystem.shared.SizedStack; import lombok.NonNull; +import org.bukkit.Bukkit; public interface RegionHistory { @@ -45,4 +49,44 @@ public interface RegionHistory { return false; } }; + + class Impl implements RegionHistory { + + private SizedStack undoSessions; + private SizedStack redoSessions; + + public Impl(int size) { + this.undoSessions = new SizedStack<>(size); + this.redoSessions = new SizedStack<>(size); + } + + @Override + public void remember(@NonNull EditSession editSession) { + undoSessions.push(editSession); + if (redoSessions.empty()) return; + redoSessions.clear(); + } + + @Override + public boolean undo() { + EditSession session = undoSessions.pop(); + if (session == null) return false; + try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) { + session.undo(e); + redoSessions.push(e); + } + return true; + } + + @Override + public boolean redo() { + EditSession session = redoSessions.pop(); + if (session == null) return false; + try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) { + session.redo(e); + undoSessions.push(e); + } + return true; + } + } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/shared/SizedStack.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/shared/SizedStack.java index 7d503b2e..6aa7b619 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/shared/SizedStack.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/shared/SizedStack.java @@ -130,6 +130,12 @@ public class SizedStack { return size; } + public void clear() { + this.data = (T[]) new Object[this.maxSize]; + this.head = 0; + this.size = 0; + } + @Override public String toString() { final StringBuilder result = new StringBuilder("["); diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java index 22ca45c5..8a817870 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java @@ -36,6 +36,10 @@ public class FixedRegionSystem implements RegionSystem { private static final Map REGION_MAP = new HashMap<>(); + public static void addRegion(Region region) { + REGION_MAP.put(region.getID(), region); + } + @Override public void load() { PrototypeLoader.load(); diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java index 5a26c0fa..c860f903 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedFlagStorage.java @@ -23,7 +23,6 @@ import de.steamwar.bausystem.region.FlagOptional; import de.steamwar.bausystem.region.FlagStorage; import de.steamwar.bausystem.region.RegionFlagPolicy; import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.bausystem.region.flags.TestblockMode; import de.steamwar.bausystem.worlddata.WorldData; import de.steamwar.core.Core; import lombok.NonNull; @@ -34,12 +33,10 @@ import java.util.Map; public class FixedFlagStorage implements FlagStorage { - private TestblockMode testBlockMode; private Map, Flag.Value> flagMap = new HashMap<>(); private YAPIONObject data; - public FixedFlagStorage(TestblockMode testblockMode, YAPIONObject data) { - this.testBlockMode = testblockMode; + public FixedFlagStorage(YAPIONObject data) { this.data = data; for (final Flag flag : Flag.getFlags()) { if (!has(flag).isWritable()) continue; @@ -79,9 +76,6 @@ public class FixedFlagStorage implements FlagStorage { @Override public @NonNull & Flag.Value> FlagOptional get(@NonNull Flag flag) { - if (flag.oneOf(Flag.TESTBLOCK)) { - return FlagOptional.of((Flag) flag, testBlockMode); - } return FlagOptional.of(flag, (T) flagMap.get(flag)); } diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java index 2f914dc5..7409de36 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java @@ -19,9 +19,18 @@ package de.steamwar.bausystem.region.fixed; +import com.sk89q.worldedit.EditSession; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.*; +import de.steamwar.bausystem.region.flags.Flag; +import de.steamwar.bausystem.region.flags.TestblockMode; +import de.steamwar.bausystem.utils.PasteBuilder; +import de.steamwar.core.Core; import lombok.NonNull; +import yapion.hierarchy.types.YAPIONObject; +import javax.annotation.Nullable; +import java.io.File; import java.nio.charset.StandardCharsets; import java.util.UUID; @@ -31,10 +40,191 @@ public class FixedRegion implements Region { private FixedFlagStorage flagStorage; private Prototype prototype; - public FixedRegion(String name, FixedFlagStorage flagStorage, Prototype prototype) { + private final Area area; + private final Area build; + private final Area testblock; + private final int floorLevel; + private final int waterLevel; + private final RegionConfig regionConfig; + private final RegionHistory regionHistory = new RegionHistory.Impl(20); + + public FixedRegion(String name, FixedFlagStorage flagStorage, Prototype prototype, YAPIONObject regionConfig, YAPIONObject regionData) { uuid = UUID.nameUUIDFromBytes(name.getBytes(StandardCharsets.UTF_8)); this.flagStorage = flagStorage; this.prototype = prototype; + System.out.println(name + " " + prototype + " " + flagStorage); + + Point minPoint; + if (regionConfig.containsKey("minX", Integer.class) && regionConfig.containsKey("minY", Integer.class) && regionConfig.containsKey("minZ", Integer.class)) { + minPoint = new Point(regionConfig.getInt("minX"), regionConfig.getInt("minY"), regionConfig.getInt("minZ")); + } else { + throw new IllegalArgumentException("minX and minY and minZ are required"); + } + Point maxPoint = minPoint.add(prototype.getSizeX() - 1, prototype.getSizeY() - 1, prototype.getSizeZ() - 1); + + area = new Area() { + @Override + public @NonNull Point getMinPoint(boolean extension) { + return minPoint; + } + + @Override + public @NonNull Point getMaxPoint(boolean extension) { + return maxPoint; + } + + @Override + public @NonNull Point getCopyPoint() { + return minPoint; + } + + @Nullable + @Override + public EditSession copy(boolean extension) { + return null; // TODO: Implement + } + + @Nullable + @Override + public File getResetFile() { + return null; // TODO: Implement + } + + @Override + public void reset(PasteBuilder pasteBuilder, boolean extension) { + // TODO: Implement + } + }; + + if (prototype.getBuild() != null) { + Point minPointBuild = minPoint.add(prototype.getBuild().getOffsetX(), prototype.getBuild().getOffsetY(), prototype.getBuild().getOffsetZ()); + Point maxPointBuild = minPointBuild.add(prototype.getBuild().getSizeX() - 1, prototype.getBuild().getSizeY() - 1, prototype.getBuild().getSizeZ() - 1); + + Point minPointBuildExtension = minPointBuild.subtract(prototype.getBuild().getExtensionNegativeX(), prototype.getBuild().getExtensionNegativeY(), prototype.getBuild().getExtensionNegativeZ()); + Point maxPointBuildExtension = maxPointBuild.add(prototype.getBuild().getExtensionPositiveX(), prototype.getBuild().getExtensionPositiveY(), prototype.getBuild().getExtensionPositiveZ()); + + Point copyPoint; + if (!prototype.getBuild().isHasCopyPoint() && (prototype.getCopyPointOffsetX() != 0 || prototype.getCopyPointOffsetY() != 0 || prototype.getCopyPointOffsetZ() != 0)) { + copyPoint = minPoint.add(prototype.getCopyPointOffsetX(), prototype.getCopyPointOffsetY(), prototype.getCopyPointOffsetZ()); + } else if (prototype.getBuild().getCopyOffsetX() != 0 || prototype.getBuild().getCopyOffsetY() != 0 || prototype.getBuild().getCopyOffsetZ() != 0) { + copyPoint = minPointBuild.add(prototype.getBuild().getCopyOffsetX(), prototype.getBuild().getCopyOffsetY(), prototype.getBuild().getCopyOffsetZ()); + } else { + copyPoint = minPointBuild.add(prototype.getBuild().getSizeX() / 2, 0, prototype.getBuild().getSizeZ()); + } + + build = new Area() { + @Override + public @NonNull Point getMinPoint(boolean extension) { + return extension ? minPointBuildExtension : minPointBuild; + } + + @Override + public @NonNull Point getMaxPoint(boolean extension) { + return extension ? maxPointBuildExtension : maxPointBuild; + } + + @Override + public @NonNull Point getCopyPoint() { + return copyPoint; + } + + @Nullable + @Override + public EditSession copy(boolean extension) { + return null; // TODO: Implement + } + + @Nullable + @Override + public File getResetFile() { + return null; // TODO: Implement + } + + @Override + public void reset(PasteBuilder pasteBuilder, boolean extension) { + // TODO: Implement + } + }; + } else { + build = Area.EMPTY; + } + + if (prototype.getTestblock() != null) { + Point minPointTestblock = minPoint.add(prototype.getTestblock().getOffsetX(), prototype.getTestblock().getOffsetY(), prototype.getTestblock().getOffsetZ()); + Point maxPointTestblock = minPointTestblock.add(prototype.getTestblock().getSizeX() - 1, prototype.getTestblock().getSizeY() - 1, prototype.getTestblock().getSizeZ() - 1); + + Point minPointTestblockExtension = minPointTestblock.subtract(prototype.getTestblock().getExtensionNegativeX(), prototype.getTestblock().getExtensionNegativeY(), prototype.getTestblock().getExtensionNegativeZ()); + Point maxPointTestblockExtension = maxPointTestblock.add(prototype.getTestblock().getExtensionPositiveX(), prototype.getTestblock().getExtensionPositiveY(), prototype.getTestblock().getExtensionPositiveZ()); + + Point copyPoint; + if (!prototype.getTestblock().isHasCopyPoint() && (prototype.getCopyPointOffsetX() != 0 || prototype.getCopyPointOffsetY() != 0 || prototype.getCopyPointOffsetZ() != 0)) { + copyPoint = minPoint.add(prototype.getCopyPointOffsetX(), prototype.getCopyPointOffsetY(), prototype.getCopyPointOffsetZ()); + } else if (prototype.getTestblock().getCopyOffsetX() != 0 || prototype.getTestblock().getCopyOffsetY() != 0 || prototype.getTestblock().getCopyOffsetZ() != 0) { + copyPoint = minPointTestblock.add(prototype.getTestblock().getCopyOffsetX(), prototype.getTestblock().getCopyOffsetY(), prototype.getTestblock().getCopyOffsetZ()); + } else { + copyPoint = minPointTestblock.add(prototype.getTestblock().getSizeX() / 2, 0, prototype.getTestblock().getSizeZ()); + } + + testblock = new Area() { + @Override + public @NonNull Point getMinPoint(boolean extension) { + return extension ? minPointTestblockExtension : minPointTestblock; + } + + @Override + public @NonNull Point getMaxPoint(boolean extension) { + return extension ? maxPointTestblockExtension : maxPointTestblock; + } + + @Override + public @NonNull Point getCopyPoint() { + return copyPoint; + } + + @Nullable + @Override + public EditSession copy(boolean extension) { + return null; // TODO: Implement + } + + @Nullable + @Override + public File getResetFile() { + return null; // TODO: Implement + } + + @Override + public void reset(PasteBuilder pasteBuilder, boolean extension) { + // TODO: Implement + } + }; + } else { + testblock = Area.EMPTY; + } + + if (!testblock.isEmpty() && !build.isEmpty()) { + if (testblock.getMinPoint(false).getZ() > build.getMinPoint(false).getZ()) { + flagStorage.getBackedMap().put(Flag.TESTBLOCK, TestblockMode.SOUTH); + } else { + flagStorage.getBackedMap().put(Flag.TESTBLOCK, TestblockMode.NORTH); + } + } else { + flagStorage.getBackedMap().put(Flag.TESTBLOCK, TestblockMode.NO_VALUE); + } + + floorLevel = prototype.getFloorOffset() != 0 ? minPoint.getY() + prototype.getFloorOffset() : 0; + waterLevel = prototype.getWaterOffset() != 0 ? minPoint.getX() + prototype.getWaterOffset() : 0; + + File found = null; + File baseFile = new File(BauSystem.getInstance().getDataFolder().getParentFile(), "FightSystem"); + for (int version = Core.getVersion(); version >= 15; version--) { + File specific = new File(baseFile, prototype.getDisplayName() + version + ".yml"); + if (specific.exists()) { + found = specific; + break; + } + } + this.regionConfig = new RegionConfig(found); } @Override @@ -54,31 +244,31 @@ public class FixedRegion implements Region { @Override public @NonNull Area getArea() { - return null; + return area; } @Override public @NonNull Area getBuildArea() { - return null; + return build; } @Override public @NonNull Area getTestblockArea() { - return null; + return testblock; } @Override public @NonNull RegionConfig getGameModeConfig() { - return null; + return regionConfig; } @Override public @NonNull RegionHistory getHistory() { - return null; + return regionHistory; } @Override public @NonNull RegionBackups getBackups() { - return null; + return RegionBackups.EMPTY; } } diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/Prototype.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/Prototype.java index 804e25f4..3e4a7248 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/Prototype.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/Prototype.java @@ -19,8 +19,7 @@ package de.steamwar.bausystem.region.fixed; -import de.steamwar.bausystem.region.FlagStorage; -import de.steamwar.bausystem.region.flags.TestblockMode; +import de.steamwar.bausystem.region.FixedRegionSystem; import lombok.AllArgsConstructor; import lombok.Getter; import yapion.hierarchy.types.YAPIONObject; @@ -217,8 +216,7 @@ public class Prototype { } else { prototype = PROTOTYPE_MAP.get(regionConfig.getPlainValue("prototype")); } - FlagStorage flagStorage = new FixedFlagStorage(TestblockMode.NO_VALUE, regionData.getObjectOrSetDefault("flagStorage", new YAPIONObject())); - System.out.println(name + " " + prototype + " " + flagStorage); - // return new Region(name, prototype, regionConfig, flagStorage, regionData); + FixedFlagStorage flagStorage = new FixedFlagStorage(regionData.getObjectOrSetDefault("flagStorage", new YAPIONObject())); + FixedRegionSystem.addRegion(new FixedRegion(name, flagStorage, prototype, regionConfig, regionData)); } } From 830ca93105ddc28efe48697030189cc8c81930da Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sat, 2 Aug 2025 13:53:52 +0200 Subject: [PATCH 51/56] Implement Area for FixedRegion --- .../de/steamwar/bausystem/region/Region.java | 9 ++- .../bausystem/region/fixed/FixedRegion.java | 80 ++++++++++++------- 2 files changed, 58 insertions(+), 31 deletions(-) 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 bad3b0ef..609364a1 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -19,7 +19,8 @@ package de.steamwar.bausystem.region; -import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.extent.clipboard.Clipboard; +import de.steamwar.bausystem.utils.FlatteningWrapper; import de.steamwar.bausystem.utils.PasteBuilder; import lombok.NonNull; import org.bukkit.Location; @@ -100,7 +101,7 @@ public interface Region { } @Override - public EditSession copy(boolean extension) { + public Clipboard copy(boolean extension) { return null; } @@ -146,7 +147,9 @@ public interface Region { } @Nullable - EditSession copy(boolean extension); + default Clipboard copy(boolean extension) { + return FlatteningWrapper.impl.copy(getMinPoint(extension), getMaxPoint(extension), getCopyPoint()); + } @Nullable File getResetFile(); diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java index 7409de36..d89095c3 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java @@ -26,6 +26,7 @@ import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.TestblockMode; import de.steamwar.bausystem.utils.PasteBuilder; import de.steamwar.core.Core; +import de.steamwar.sql.SchematicType; import lombok.NonNull; import yapion.hierarchy.types.YAPIONObject; @@ -36,9 +37,10 @@ import java.util.UUID; public class FixedRegion implements Region { - private UUID uuid; - private FixedFlagStorage flagStorage; - private Prototype prototype; + private final UUID uuid; + private final FixedFlagStorage flagStorage; + private final Prototype prototype; + private final String skin; private final Area area; private final Area build; @@ -52,7 +54,7 @@ public class FixedRegion implements Region { uuid = UUID.nameUUIDFromBytes(name.getBytes(StandardCharsets.UTF_8)); this.flagStorage = flagStorage; this.prototype = prototype; - System.out.println(name + " " + prototype + " " + flagStorage); + this.skin = prototype.getDefaultSkin(); Point minPoint; if (regionConfig.containsKey("minX", Integer.class) && regionConfig.containsKey("minY", Integer.class) && regionConfig.containsKey("minZ", Integer.class)) { @@ -78,21 +80,24 @@ public class FixedRegion implements Region { return minPoint; } - @Nullable - @Override - public EditSession copy(boolean extension) { - return null; // TODO: Implement - } - @Nullable @Override public File getResetFile() { - return null; // TODO: Implement + return prototype.getSkinMap().get(skin).getSchematicFile(); } @Override public void reset(PasteBuilder pasteBuilder, boolean extension) { - // TODO: Implement + pasteBuilder.reset(extension) + .minPoint(getMinPoint(extension)) + .maxPoint(getMaxPoint(extension)) + .waterLevel(waterLevel); + if (pasteBuilder.getClipboardProvider().is(PasteBuilder.SchematicProvider.class)) { + SchematicType schematicType = pasteBuilder.getClipboardProvider().as(PasteBuilder.SchematicProvider.class).getSchematic().getSchemtype(); + pasteBuilder.rotate(schematicType.fightType() || schematicType.check()); + } + pasteBuilder.pastePoint(minPoint.add(prototype.getSizeX() / 2, 0, prototype.getSizeY() / 2)); + regionHistory.remember(pasteBuilder.run()); } }; @@ -128,21 +133,24 @@ public class FixedRegion implements Region { return copyPoint; } - @Nullable - @Override - public EditSession copy(boolean extension) { - return null; // TODO: Implement - } - @Nullable @Override public File getResetFile() { - return null; // TODO: Implement + return prototype.getSkinMap().get(skin).getBuildSchematicFile(); } @Override public void reset(PasteBuilder pasteBuilder, boolean extension) { - // TODO: Implement + pasteBuilder.reset(extension) + .minPoint(getMinPoint(extension)) + .maxPoint(getMaxPoint(extension)) + .waterLevel(waterLevel); + if (pasteBuilder.getClipboardProvider().is(PasteBuilder.SchematicProvider.class)) { + SchematicType schematicType = pasteBuilder.getClipboardProvider().as(PasteBuilder.SchematicProvider.class).getSchematic().getSchemtype(); + pasteBuilder.rotate(schematicType.fightType() || schematicType.check()); + } + pasteBuilder.pastePoint(minPointBuild.add(prototype.getBuild().getSizeX() / 2, 0, prototype.getBuild().getSizeZ() / 2)); + regionHistory.remember(pasteBuilder.run()); } }; } else { @@ -181,21 +189,37 @@ public class FixedRegion implements Region { return copyPoint; } - @Nullable - @Override - public EditSession copy(boolean extension) { - return null; // TODO: Implement - } - @Nullable @Override public File getResetFile() { - return null; // TODO: Implement + return prototype.getSkinMap().get(skin).getTestblockSchematicFile(); } @Override public void reset(PasteBuilder pasteBuilder, boolean extension) { - // TODO: Implement + pasteBuilder.reset(extension) + .minPoint(getMinPoint(extension)) + .maxPoint(getMaxPoint(extension)) + .waterLevel(waterLevel); + if (pasteBuilder.getClipboardProvider().is(PasteBuilder.SchematicProvider.class)) { + SchematicType schematicType = pasteBuilder.getClipboardProvider().as(PasteBuilder.SchematicProvider.class).getSchematic().getSchemtype(); + pasteBuilder.rotate(schematicType.fightType() || schematicType.check()); + } + Point pastePoint = minPointTestblock.add(prototype.getTestblock().getSizeX() / 2, 0, prototype.getTestblock().getSizeZ() / 2); + if (pasteBuilder.getClipboardProvider().is(PasteBuilder.SchematicProvider.class)) { + SchematicType schematicType = pasteBuilder.getClipboardProvider().as(PasteBuilder.SchematicProvider.class).getSchematic().getSchemtype(); + if (schematicType.getKuerzel().equalsIgnoreCase("wg")) { + pastePoint = pastePoint.add(0, 0, 1); + } + if (schematicType.getKuerzel().equalsIgnoreCase("ws")) { + pastePoint = pastePoint.add(-1, 0, 1); + } + if (schematicType.getKuerzel().equalsIgnoreCase("as")) { + pastePoint = pastePoint.add(-1, 0, 1); + } + } + pasteBuilder.pastePoint(pastePoint); + regionHistory.remember(pasteBuilder.run()); } }; } else { From 0a3ae7117dea8dd92acb5aeb282a7a322f1a764e Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sat, 2 Aug 2025 13:55:22 +0200 Subject: [PATCH 52/56] Fix FixedGlobalRegion --- .../de/steamwar/bausystem/region/fixed/FixedGlobalRegion.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegion.java index 9204489e..8edc97db 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegion.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegion.java @@ -19,7 +19,7 @@ package de.steamwar.bausystem.region.fixed; -import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.extent.clipboard.Clipboard; import de.steamwar.bausystem.region.*; import de.steamwar.bausystem.utils.PasteBuilder; import lombok.NonNull; @@ -66,7 +66,7 @@ public final class FixedGlobalRegion implements Region { @Nullable @Override - public EditSession copy(boolean extension) { + public Clipboard copy(boolean extension) { return null; } From b14c39683a9365730aa1ce011010fdd3fdb219c6 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sat, 2 Aug 2025 14:31:46 +0200 Subject: [PATCH 53/56] Implement FixedRegion.regionBackups --- .../features/backup/BackupCommand.java | 4 +- .../bausystem/region/fixed/FixedRegion.java | 92 ++++++++++++++++++- 2 files changed, 92 insertions(+), 4 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 6c7708c9..393549b7 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 @@ -120,12 +120,12 @@ public class BackupCommand extends SWCommand { return new TypeMapper() { @Override public RegionBackups.Backup map(CommandSender commandSender, String[] previousArguments, String s) { - return Region.getRegion(((Player) commandSender).getLocation()).getBackups().get(s); + return Region.getRegion(((Player) commandSender).getLocation()).getBackups().get(s.replace('_', ' ')); } @Override public Collection tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) { - return listBackup((Player) sender).stream().map(RegionBackups.Backup::getName).collect(Collectors.toList()); + return listBackup((Player) sender).stream().map(RegionBackups.Backup::getName).map(name -> name.replace(' ', '_')).collect(Collectors.toList()); } }; } diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java index d89095c3..ed109105 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java @@ -24,19 +24,28 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.*; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.TestblockMode; +import de.steamwar.bausystem.utils.FlatteningWrapper; import de.steamwar.bausystem.utils.PasteBuilder; import de.steamwar.core.Core; import de.steamwar.sql.SchematicType; import lombok.NonNull; +import org.bukkit.Bukkit; import yapion.hierarchy.types.YAPIONObject; import javax.annotation.Nullable; import java.io.File; import java.nio.charset.StandardCharsets; -import java.util.UUID; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.stream.Collectors; public class FixedRegion implements Region { + private static final File backupFolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "backup"); + private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd' 'HH:mm:ss"); + + private final String name; private final UUID uuid; private final FixedFlagStorage flagStorage; private final Prototype prototype; @@ -50,7 +59,86 @@ public class FixedRegion implements Region { private final RegionConfig regionConfig; private final RegionHistory regionHistory = new RegionHistory.Impl(20); + private final RegionBackups regionBackups = new RegionBackups() { + @Override + public Optional create(BackupType backupType) { + final File definedBackupFolder = new File(new File(backupFolder, prototype.getName()), name); + //noinspection ResultOfMethodCallIgnored + definedBackupFolder.mkdirs(); + + File[] currentBackups = definedBackupFolder.listFiles(); + if (currentBackups != null && currentBackups.length >= 20) { + List files = new ArrayList<>(Arrays.asList(currentBackups)); + files.sort(Comparator.comparingLong(File::lastModified)); + while (files.size() >= 20) files.remove(0).delete(); + } + + final File backupFile = new File(definedBackupFolder, LocalDateTime.now().format(formatter) + ".schem"); + Point minPoint = area.getMinPoint(false); + Point maxPoint = area.getMaxPoint(false); + if (!FlatteningWrapper.impl.backup(minPoint, maxPoint, backupFile)) { + return Optional.empty(); + } + return Optional.of(new BackupImpl(backupFile)); + } + + @Override + public @NonNull List list() { + final File definedBackupFolder = new File(new File(backupFolder, prototype.getName()), name); + //noinspection ResultOfMethodCallIgnored + definedBackupFolder.mkdirs(); + + File[] currentBackups = definedBackupFolder.listFiles(); + if (currentBackups == null || currentBackups.length == 0) { + return Collections.emptyList(); + } + List files = new ArrayList<>(Arrays.asList(currentBackups)); + files.sort(Comparator.comparingLong(File::lastModified)); + return files.stream().map(BackupImpl::new).collect(Collectors.toList()); + } + + @Nullable + @Override + public Backup get(String name) { + final File definedBackupFolder = new File(new File(backupFolder, prototype.getName()), name); + //noinspection ResultOfMethodCallIgnored + definedBackupFolder.mkdirs(); + File[] files = definedBackupFolder.listFiles((dir, s) -> s.equals(name + ".schem")); + if (files == null || files.length == 0) return null; + return new BackupImpl(files[0]); + } + }; + + private class BackupImpl extends RegionBackups.Backup { + + private final File file; + + public BackupImpl(File file) { + super(RegionBackups.BackupType.AUTOMATIC, file.getName(), flagStorage); + this.file = file; + } + + @Override + public boolean load() { + if (!file.exists()) return false; + EditSession editSession = new PasteBuilder(new PasteBuilder.FileProvider(file)) + .pastePoint(area.getMinPoint(false).add(prototype.getSizeX() / 2, 0, prototype.getSizeZ() / 2)) + .minPoint(area.getMinPoint(false)) + .maxPoint(area.getMaxPoint(false)) + .waterLevel(waterLevel) + .run(); + regionHistory.remember(editSession); + return true; + } + + @Override + public void delete() { + file.delete(); + } + } + public FixedRegion(String name, FixedFlagStorage flagStorage, Prototype prototype, YAPIONObject regionConfig, YAPIONObject regionData) { + this.name = name; uuid = UUID.nameUUIDFromBytes(name.getBytes(StandardCharsets.UTF_8)); this.flagStorage = flagStorage; this.prototype = prototype; @@ -293,6 +381,6 @@ public class FixedRegion implements Region { @Override public @NonNull RegionBackups getBackups() { - return RegionBackups.EMPTY; + return regionBackups; } } From a3801790a4d74d96fbe2fd4e50a59cc0ef782f73 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sat, 2 Aug 2025 14:32:24 +0200 Subject: [PATCH 54/56] Remove old stuff --- .../bausystem/regionold/Region.java.txt | 584 ------------------ .../regionold/loader/Updater.java.txt | 47 -- 2 files changed, 631 deletions(-) delete mode 100644 BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/Region.java.txt delete mode 100644 BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/Updater.java.txt diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/Region.java.txt b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/Region.java.txt deleted file mode 100644 index c6f8b5c7..00000000 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/Region.java.txt +++ /dev/null @@ -1,584 +0,0 @@ -/* - * 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.EditSession; -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.bukkit.BukkitWorld; -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.bausystem.region.flags.flagvalues.TNTMode; -import de.steamwar.bausystem.region.tags.Tag; -import de.steamwar.bausystem.region.utils.RegionExtensionType; -import de.steamwar.bausystem.region.utils.RegionType; -import de.steamwar.bausystem.shared.SizedStack; -import de.steamwar.bausystem.utils.FlatteningWrapper; -import de.steamwar.bausystem.utils.PasteBuilder; -import de.steamwar.core.Core; -import de.steamwar.sql.SchematicType; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NonNull; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import yapion.hierarchy.types.YAPIONObject; -import yapion.hierarchy.types.YAPIONType; -import yapion.hierarchy.types.YAPIONValue; - -import java.io.File; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.*; -import java.util.function.ObjIntConsumer; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -@Getter -public class Region { - - @Getter - private static final Map REGION_MAP = new HashMap<>(); - private static final File backupFolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "backup"); - private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd' 'HH:mm:ss"); - - public static Region getRegion(Location location) { - return REGION_MAP.values().stream() - .filter(r -> r.inRegion(location, r.minPoint, r.maxPoint)) - .findFirst() - .orElse(GlobalRegion.instance); - } - - public static Set getRegion(Prototype prototype) { - return REGION_MAP.values().stream() - .filter(r -> r.getPrototype() == prototype) - .collect(Collectors.toSet()); - } - - public static void setGlobal(Flag flagType, Flag.Value value) { - REGION_MAP.values().forEach(region -> region.set(flagType, value)); - } - - YAPIONObject regionData; - - private String name; - private Prototype prototype; - private Set prototypes; - private String skin; - - private Point minPoint; - private Point maxPoint; - - private Point minPointTestblock; - private Point maxPointTestblock; - - private Point minPointTestblockExtension; - private Point maxPointTestblockExtension; - - private Point minPointBuild; - private Point maxPointBuild; - - private Point minPointBuildExtension; - private Point maxPointBuildExtension; - - private int floorLevel; - private int waterLevel; - - private Point copyPoint; // Nullable - private Point testBlockPoint; // Nullable - - private String linkedRegionName = null; // Nullable - private Region linkedRegion = null; // Nullable - - private FlagStorage flagStorage; - - @Getter(AccessLevel.PRIVATE) - private SizedStack undoSessions; - - @Getter(AccessLevel.PRIVATE) - private SizedStack redoSessions; - - public Region(String name, Prototype prototype, YAPIONObject regionConfig, FlagStorage flagStorage, YAPIONObject regionData) { - this.name = name; - this.regionData = regionData; - if (prototype != null) { - REGION_MAP.put(name, this); - } - - linkedRegionName = regionConfig.getPlainValueOrDefault("optionsLinkedWith", null); - - prototypes = new HashSet<>(); - if (regionConfig.containsKey("prototypes", YAPIONType.ARRAY)) { - regionConfig.getArray("prototypes").forEach(yapionAnyType -> { - if (yapionAnyType instanceof YAPIONValue) { - prototypes.add(((YAPIONValue) yapionAnyType).get()); - } - }); - } - if (regionConfig.containsKey("prototype")) { - prototypes.add(regionConfig.getPlainValue("prototype")); - } - - this.flagStorage = flagStorage; - Point point = null; - if (regionConfig.containsKey("minX", Integer.class) && regionConfig.containsKey("minY", Integer.class) && regionConfig.containsKey("minZ", Integer.class)) { - point = new Point(regionConfig.getPlainValue("minX"), regionConfig.getPlainValue("minY"), regionConfig.getPlainValue("minZ")); - } - if (prototype != null && prototypes.contains(prototype.getName())) { - generatePrototypeData(prototype, point); - } else if (regionConfig.containsKey("prototype")) { - generatePrototypeData(Prototype.getByName(regionConfig.getPlainValue("prototype")), point); - } - if (prototype != null) { - skin = regionData.getPlainValueOrDefault("skin", prototype.getDefaultSkin()); - if (!prototype.getSkinMap().containsKey(skin)) { - skin = prototype.getDefaultSkin(); - } - } - regionData.add("skin", skin); - - if (!hasType(RegionType.BUILD) || !hasType(RegionType.TESTBLOCK)) { - flagStorage.set(Flag.TNT, TNTMode.DENY); - } - } - - private void generatePrototypeData(Prototype prototype, Point point) { - if (prototype == null) { - return; - } - - this.prototype = prototype; - this.skin = prototype.getDefaultSkin(); - - this.minPoint = point; - this.maxPoint = point.add(prototype.getSizeX() - 1, prototype.getSizeY() - 1, prototype.getSizeZ() - 1); - - if (prototype.getTestblock() != null) { - this.minPointTestblock = point.add(prototype.getTestblock().getOffsetX(), prototype.getTestblock().getOffsetY(), prototype.getTestblock().getOffsetZ()); - this.maxPointTestblock = this.minPointTestblock.add(prototype.getTestblock().getSizeX() - 1, prototype.getTestblock().getSizeY() - 1, prototype.getTestblock().getSizeZ() - 1); - - this.minPointTestblockExtension = this.minPointTestblock.subtract(prototype.getTestblock().getExtensionNegativeX(), prototype.getTestblock().getExtensionNegativeY(), prototype.getTestblock().getExtensionNegativeZ()); - this.maxPointTestblockExtension = this.maxPointTestblock.add(prototype.getTestblock().getExtensionPositiveX(), prototype.getTestblock().getExtensionPositiveY(), prototype.getTestblock().getExtensionPositiveZ()); - - if (prototype.getTestblock().getCopyOffsetX() != 0 || prototype.getTestblock().getCopyOffsetY() != 0 || prototype.getTestblock().getCopyOffsetZ() != 0) { - this.testBlockPoint = this.minPointTestblock.add(prototype.getTestblock().getCopyOffsetX(), prototype.getTestblock().getCopyOffsetY(), prototype.getTestblock().getCopyOffsetZ()); - } else { - this.testBlockPoint = this.minPointTestblock.add(prototype.getTestblock().getSizeX() / 2, 0, -1); - } - } - - if (prototype.getBuild() != null) { - this.minPointBuild = point.add(prototype.getBuild().getOffsetX(), prototype.getBuild().getOffsetY(), prototype.getBuild().getOffsetZ()); - this.maxPointBuild = this.minPointBuild.add(prototype.getBuild().getSizeX() - 1, prototype.getBuild().getSizeY() - 1, prototype.getBuild().getSizeZ() - 1); - - this.minPointBuildExtension = this.minPointBuild.subtract(prototype.getBuild().getExtensionNegativeX(), prototype.getBuild().getExtensionNegativeY(), prototype.getBuild().getExtensionNegativeZ()); - this.maxPointBuildExtension = this.maxPointBuild.add(prototype.getBuild().getExtensionPositiveX(), prototype.getBuild().getExtensionPositiveY(), prototype.getBuild().getExtensionPositiveZ()); - - if (!prototype.getBuild().isHasCopyPoint() && (prototype.getCopyPointOffsetX() != 0 || prototype.getCopyPointOffsetY() != 0 || prototype.getCopyPointOffsetZ() != 0)) { - this.copyPoint = minPoint.add(prototype.getCopyPointOffsetX(), prototype.getCopyPointOffsetY(), prototype.getCopyPointOffsetZ()); - } else if (prototype.getBuild().getCopyOffsetX() != 0 || prototype.getBuild().getCopyOffsetY() != 0 || prototype.getBuild().getCopyOffsetZ() != 0) { - this.copyPoint = this.minPointBuild.add(prototype.getBuild().getCopyOffsetX(), prototype.getBuild().getCopyOffsetY(), prototype.getBuild().getCopyOffsetZ()); - } else { - this.copyPoint = this.minPointBuild.add(prototype.getBuild().getSizeX() / 2, 0, prototype.getBuild().getSizeZ()); - } - } else if (prototype.getCopyPointOffsetX() != 0 || prototype.getCopyPointOffsetY() != 0 || prototype.getCopyPointOffsetZ() != 0) { - this.copyPoint = minPoint.add(prototype.getCopyPointOffsetX(), prototype.getCopyPointOffsetY(), prototype.getCopyPointOffsetZ()); - } - - if (prototype.getFloorOffset() != 0) { - floorLevel = minPoint.getY() + prototype.getFloorOffset(); - } else { - floorLevel = 0; - } - - if (prototype.getWaterOffset() != 0) { - waterLevel = minPoint.getY() + prototype.getWaterOffset(); - } else { - waterLevel = 0; - } - } - - public boolean inRegion(Location location, RegionType regionType, RegionExtensionType regionExtensionType) { - if (!hasType(regionType)) { - return false; - } - switch (regionType) { - case BUILD: - Point minBPoint = regionExtensionType == RegionExtensionType.EXTENSION ? minPointBuildExtension : minPointBuild; - Point maxBPoint = regionExtensionType == RegionExtensionType.EXTENSION ? maxPointBuildExtension : maxPointBuild; - return inRegion(location, minBPoint, maxBPoint); - case TESTBLOCK: - Point minTBPoint = regionExtensionType == RegionExtensionType.EXTENSION ? minPointTestblockExtension : minPointTestblock; - Point maxTBPoint = regionExtensionType == RegionExtensionType.EXTENSION ? maxPointTestblockExtension : maxPointTestblock; - return inRegion(location, minTBPoint, maxTBPoint); - default: - case NORMAL: - return inRegion(location, minPoint, maxPoint); - } - } - - private boolean inRegion(Location location, Point minPoint, Point maxPoint) { - int blockX = location.getBlockX(); - int blockY = location.getBlockY(); - int blockZ = location.getBlockZ(); - return blockX >= minPoint.getX() && blockX <= maxPoint.getX() && - blockY >= minPoint.getY() && blockY <= maxPoint.getY() && - blockZ >= minPoint.getZ() && blockZ <= maxPoint.getZ(); - } - - public boolean hasType(RegionType regionType) { - if (prototype == null) { - return false; - } - if (regionType == null) { - return false; - } - switch (regionType) { - case BUILD: - return prototype.getBuild() != null; - case TESTBLOCK: - return prototype.getTestblock() != null; - default: - case NORMAL: - return true; - } - } - - public boolean hasExtensionType(RegionType regionType) { - if (!hasType(regionType)) { - return false; - } - switch (regionType) { - case BUILD: - return prototype.getBuild().isExtensionRegistered(); - case TESTBLOCK: - return prototype.getTestblock().isExtensionRegistered(); - default: - case NORMAL: - return false; - } - } - - public String getDisplayName() { - return prototype != null ? prototype.getSkinMap().get(skin).getName() : ""; - } - - private void setLinkedRegion(Predicate regionConsumer) { - if (linkedRegionName == null) { - return; - } - if (linkedRegion != null) { - if (regionConsumer.test(linkedRegion)) { - RegionUtils.save(linkedRegion); - } - return; - } - for (Region region : REGION_MAP.values()) { - if (region.name.equals(linkedRegionName)) { - linkedRegion = region; - if (regionConsumer.test(linkedRegion)) { - RegionUtils.save(linkedRegion); - } - return; - } - } - } - - public Region getLinkedRegion() { - if (linkedRegion == null && linkedRegionName != null) { - setLinkedRegion(region -> false); - } - return linkedRegion; - } - - public boolean setPrototype(@NonNull Prototype prototype) { - if (!prototypes.contains(prototype.getName())) { - return false; - } - return _setPrototype(prototype); - } - - boolean _setPrototype(@NonNull Prototype prototype) { - generatePrototypeData(prototype, minPoint); - RegionUtils.save(this); - return true; - } - - public boolean setSkin(@NonNull String skinName) { - if (!prototype.getSkinMap().containsKey(skinName)) { - return false; - } - this.skin = skinName; - setLinkedRegion(region -> { - region.skin = skinName; - return true; - }); - regionData.add("skin", skin); - return true; - } - - public void set(Flag flagType, Flag.Value value) { - if (flagStorage.set(flagType, value)) { - RegionUtils.save(this); - } - setLinkedRegion(region -> region.flagStorage.set(flagType, value)); - } - - public void set(Tag tag) { - if (flagStorage.set(tag)) { - RegionUtils.save(this); - } - setLinkedRegion(region -> region.flagStorage.set(tag)); - } - - public void remove(Tag tag) { - if (flagStorage.remove(tag)) { - RegionUtils.save(this); - } - } - - public Flag.Value get(Flag flagType) { - return flagStorage.get(flagType); - } - - public boolean get(Tag tagType) { - return flagStorage.is(tagType); - } - - public & Flag.Value> T getPlain(Flag flagType) { - return (T) flagStorage.get(flagType).getValue(); - } - - public & Flag.Value> T getPlain(Flag flagType, Class type) { - return (T) flagStorage.get(flagType).getValue(); - } - - public Point getMinPoint(RegionType regionType, RegionExtensionType regionExtensionType) { - switch (regionType) { - case TESTBLOCK: - return (regionExtensionType == null || regionExtensionType == RegionExtensionType.NORMAL) ? minPointTestblock : minPointTestblockExtension; - case BUILD: - return (regionExtensionType == null || regionExtensionType == RegionExtensionType.NORMAL) ? minPointBuild : minPointBuildExtension; - default: - case NORMAL: - return minPoint; - } - } - - public Point getMaxPoint(RegionType regionType, RegionExtensionType regionExtensionType) { - switch (regionType) { - case TESTBLOCK: - return (regionExtensionType == null || regionExtensionType == RegionExtensionType.NORMAL) ? maxPointTestblock : maxPointTestblockExtension; - case BUILD: - return (regionExtensionType == null || regionExtensionType == RegionExtensionType.NORMAL) ? maxPointBuild : maxPointBuildExtension; - default: - case NORMAL: - return maxPoint; - } - } - - boolean hasReset(RegionType regionType) { - if (!hasType(regionType)) { - return false; - } - switch (regionType) { - case TESTBLOCK: - return prototype.getSkinMap().get(skin).getTestblockSchematicFile() != null; - case BUILD: - return prototype.getSkinMap().get(skin).getBuildSchematicFile() != null; - default: - case NORMAL: - return prototype.getSkinMap().get(skin).getSchematicFile() != null; - } - } - - public File getResetFile(RegionType regionType) { - if (!hasReset(regionType)) { - return null; - } - switch (regionType) { - case TESTBLOCK: - return prototype.getSkinMap().get(skin).getTestblockSchematicFile(); - case BUILD: - return prototype.getSkinMap().get(skin).getBuildSchematicFile(); - default: - case NORMAL: - return prototype.getSkinMap().get(skin).getSchematicFile(); - } - } - - public void reset(PasteBuilder pasteBuilder, RegionType regionType, RegionExtensionType regionExtensionType) { - if (!hasReset(regionType)) { - return; - } - if (regionExtensionType == RegionExtensionType.EXTENSION && !hasExtensionType(regionType)) { - regionExtensionType = RegionExtensionType.NORMAL; - } - - pasteBuilder.reset(regionExtensionType == RegionExtensionType.EXTENSION) - .minPoint(getMinPoint(regionType, regionExtensionType)) - .maxPoint(getMaxPoint(regionType, regionExtensionType)) - .waterLevel(waterLevel); - if (pasteBuilder.getClipboardProvider().is(PasteBuilder.SchematicProvider.class)) { - SchematicType schematicType = pasteBuilder.getClipboardProvider().as(PasteBuilder.SchematicProvider.class).getSchematic().getSchemtype(); - pasteBuilder.rotate(schematicType.fightType() || schematicType.check()); - } - - switch (regionType) { - case BUILD: - pasteBuilder.pastePoint(minPointBuild.add(prototype.getBuild().getSizeX() / 2, 0, prototype.getBuild().getSizeZ() / 2)); - break; - case TESTBLOCK: - Point pastePoint = minPointTestblock.add(prototype.getTestblock().getSizeX() / 2, 0, prototype.getTestblock().getSizeZ() / 2); - if (pasteBuilder.getClipboardProvider().is(PasteBuilder.SchematicProvider.class)) { - SchematicType schematicType = pasteBuilder.getClipboardProvider().as(PasteBuilder.SchematicProvider.class).getSchematic().getSchemtype(); - if (schematicType.getKuerzel().equalsIgnoreCase("wg")) { - pastePoint = pastePoint.add(0, 0, 1); - } - if (schematicType.getKuerzel().equalsIgnoreCase("ws")) { - pastePoint = pastePoint.add(-1, 0, 1); - } - if (schematicType.getKuerzel().equalsIgnoreCase("as")) { - pastePoint = pastePoint.add(-1, 0, 1); - } - } - pasteBuilder.pastePoint(pastePoint); - break; - default: - case NORMAL: - pasteBuilder.pastePoint(minPoint.add(prototype.getSizeX() / 2, 0, prototype.getSizeZ() / 2)); - break; - } - - initSessions(); - undoSessions.push(pasteBuilder.run()); - } - - public void remember(EditSession editSession) { - initSessions(); - undoSessions.push(editSession); - } - - public boolean isGlobal() { - return this == GlobalRegion.getInstance(); - } - - private void initSessions() { - if (undoSessions == null) { - undoSessions = new SizedStack<>(20); - redoSessions = new SizedStack<>(20); - } - } - - public boolean undo() { - initSessions(); - EditSession session = undoSessions.pop(); - if (session == null) - return false; - - try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) { - session.undo(e); - redoSessions.push(e); - } - return true; - } - - public boolean redo() { - initSessions(); - EditSession session = redoSessions.pop(); - if (session == null) - return false; - - try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) { - session.redo(e); - undoSessions.push(e); - } - return true; - } - - public boolean backup() { - final File definedBackupFolder = new File(new File(backupFolder, prototype.getName()), name); - //noinspection ResultOfMethodCallIgnored - definedBackupFolder.mkdirs(); - - File[] currentBackups = definedBackupFolder.listFiles(); - if (currentBackups != null && currentBackups.length >= 20) { - List files = new ArrayList<>(Arrays.asList(currentBackups)); - files.sort(Comparator.comparingLong(File::lastModified)); - while (files.size() >= 20) files.remove(0).delete(); - } - - final File backupFile = new File(definedBackupFolder, LocalDateTime.now().format(formatter) + ".schem"); - return FlatteningWrapper.impl.backup(minPoint, maxPoint, backupFile); - } - - public static boolean copy(Point minPoint, Point maxPoint, File file) { - return FlatteningWrapper.impl.backup(minPoint, maxPoint, file); - } - - public List listBackup() { - final File definedBackupFolder = new File(new File(backupFolder, prototype.getName()), name); - //noinspection ResultOfMethodCallIgnored - definedBackupFolder.mkdirs(); - - File[] currentBackups = definedBackupFolder.listFiles(); - List files = new ArrayList<>(Arrays.asList(currentBackups)); - files.sort(Comparator.comparingLong(File::lastModified)); - return files.stream().map(File::getName).collect(Collectors.toList()); - } - - public File getBackupFile(String backupName) { - final File definedBackupFolder = new File(new File(backupFolder, prototype.getName()), name); - //noinspection ResultOfMethodCallIgnored - definedBackupFolder.mkdirs(); - File[] files = definedBackupFolder.listFiles((dir, name) -> name.equals(backupName + ".schem")); - if (files == null || files.length == 0) return null; - return files[0]; - } - - public void forEachChunk(ObjIntConsumer executor) { - for (int x = (int) Math.floor(minPoint.getX() / 16.0); x <= (int) Math.ceil(maxPoint.getX() / 16.0); x++) { - for (int z = (int) Math.floor(minPoint.getZ() / 16.0); z <= (int) Math.ceil(maxPoint.getZ() / 16.0); z++) { - executor.accept(x, z); - } - } - } - - public boolean buildChunkOutside(int chunkX, int chunkY) { - if (!hasType(RegionType.BUILD)) { - return Math.floor(minPoint.getX() / 16.0) > chunkX || chunkX >= Math.ceil(maxPoint.getX() / 16.0) || - Math.floor(minPoint.getZ() / 16.0) > chunkY || chunkY >= Math.ceil(maxPoint.getZ() / 16.0); - } - if (!hasExtensionType(RegionType.BUILD)) { - return Math.floor(minPointBuild.getX() / 16.0) > chunkX || chunkX >= Math.ceil(maxPointBuild.getX() / 16.0) || - Math.floor(minPointBuild.getZ() / 16.0) > chunkY || chunkY >= Math.ceil(maxPointBuild.getZ() / 16.0); - } - return Math.floor(minPointBuildExtension.getX() / 16.0) > chunkX || chunkX >= Math.ceil(maxPointBuildExtension.getX() / 16.0) || - Math.floor(minPointBuildExtension.getZ() / 16.0) > chunkY || chunkY >= Math.ceil(maxPointBuildExtension.getZ() / 16.0); - } - - public File gameModeConfig() { - File baseFile = new File(BauSystem.getInstance().getDataFolder().getParentFile(), "FightSystem"); - for (int version = Core.getVersion(); version >= 15; version--) { - File specific = new File(baseFile, prototype.getDisplayName() + version + ".yml"); - if (specific.exists()) return specific; - } - return null; - } -} \ No newline at end of file diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/Updater.java.txt b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/Updater.java.txt deleted file mode 100644 index 5e33350a..00000000 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/regionold/loader/Updater.java.txt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.loader; - -import de.steamwar.bausystem.BauSystem; -import org.bukkit.Bukkit; - -import java.io.File; -import java.util.logging.Level; - -public class Updater { - - private long lastUpdate; - - public Updater(File file, Runnable updaterCode) { - this.lastUpdate = file.lastModified(); - Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { - if (file.lastModified() > lastUpdate + 10) { - try { - updaterCode.run(); - Bukkit.getLogger().log(Level.INFO, "Update complete of " + file.getAbsolutePath()); - } catch (Exception e) { - Bukkit.getLogger().log(Level.INFO, "Error while loading file " + file.getAbsolutePath() + " for config: " + e.getMessage(), e); - } - lastUpdate = file.lastModified(); - } - }, 20, 20); - } - -} From bbd2bcae35a1bedc214ad9ff58fbd3c02293c1fa Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 3 Aug 2025 13:06:07 +0200 Subject: [PATCH 55/56] Fix BackupCommand Fix FixedRegion --- .../steamwar/bausystem/features/backup/BackupCommand.java | 4 ++-- .../src/de/steamwar/bausystem/region/fixed/FixedRegion.java | 6 +++--- 2 files changed, 5 insertions(+), 5 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 393549b7..6c7708c9 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 @@ -120,12 +120,12 @@ public class BackupCommand extends SWCommand { return new TypeMapper() { @Override public RegionBackups.Backup map(CommandSender commandSender, String[] previousArguments, String s) { - return Region.getRegion(((Player) commandSender).getLocation()).getBackups().get(s.replace('_', ' ')); + return Region.getRegion(((Player) commandSender).getLocation()).getBackups().get(s); } @Override public Collection tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) { - return listBackup((Player) sender).stream().map(RegionBackups.Backup::getName).map(name -> name.replace(' ', '_')).collect(Collectors.toList()); + return listBackup((Player) sender).stream().map(RegionBackups.Backup::getName).collect(Collectors.toList()); } }; } diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java index ed109105..7d58262c 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java @@ -100,10 +100,10 @@ public class FixedRegion implements Region { @Nullable @Override public Backup get(String name) { - final File definedBackupFolder = new File(new File(backupFolder, prototype.getName()), name); + final File definedBackupFolder = new File(new File(backupFolder, prototype.getName()), FixedRegion.this.name); //noinspection ResultOfMethodCallIgnored definedBackupFolder.mkdirs(); - File[] files = definedBackupFolder.listFiles((dir, s) -> s.equals(name + ".schem")); + File[] files = definedBackupFolder.listFiles((dir, s) -> s.equals(name.replace('_', ' ') + ".schem")); if (files == null || files.length == 0) return null; return new BackupImpl(files[0]); } @@ -114,7 +114,7 @@ public class FixedRegion implements Region { private final File file; public BackupImpl(File file) { - super(RegionBackups.BackupType.AUTOMATIC, file.getName(), flagStorage); + super(RegionBackups.BackupType.AUTOMATIC, file.getName().replace(' ', '_'), flagStorage); this.file = file; } From b695a7e089823f56007a9b4c8b5f323562210928 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Tue, 5 Aug 2025 20:59:43 +0200 Subject: [PATCH 56/56] Update stuff from peer review --- .../bausystem/features/tracer/TraceRepository.java | 2 +- .../region/{RegionConfig.java => GameModeConfig.java} | 7 +++++-- .../src/de/steamwar/bausystem/region/Region.java | 2 +- .../src/de/steamwar/bausystem/region/RegionSystem.java | 7 ------- .../de/steamwar/bausystem/region/flags/ChangedMode.java | 5 ++++- .../src/de/steamwar/bausystem/region/flags/ColorMode.java | 5 ++++- .../src/de/steamwar/bausystem/region/flags/FireMode.java | 5 ++++- .../de/steamwar/bausystem/region/flags/FreezeMode.java | 5 ++++- .../src/de/steamwar/bausystem/region/flags/ItemMode.java | 5 ++++- .../de/steamwar/bausystem/region/flags/NoGravityMode.java | 5 ++++- .../de/steamwar/bausystem/region/flags/ProtectMode.java | 5 ++++- .../src/de/steamwar/bausystem/region/flags/TNTMode.java | 5 ++++- .../de/steamwar/bausystem/region/flags/TestblockMode.java | 5 ++++- .../de/steamwar/bausystem/region/FixedRegionSystem.java | 5 ----- .../bausystem/region/fixed/FixedGlobalRegion.java | 4 ++-- .../de/steamwar/bausystem/region/fixed/FixedRegion.java | 8 ++++---- 16 files changed, 49 insertions(+), 31 deletions(-) rename BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/{RegionConfig.java => GameModeConfig.java} (97%) 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 0765d92b..209dee9a 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 @@ -18,7 +18,7 @@ public class TraceRepository { /** * Increment this when changing serialisation format */ - public static final int SERIALISATION_VERSION = 2; + public static final int SERIALISATION_VERSION = 3; public static final int WRITE_TICK_DATA = 0b00000001; public static final int EXPLOSION = 0b00000010; public static final int IN_WATER = 0b00000100; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionConfig.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/GameModeConfig.java similarity index 97% rename from BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionConfig.java rename to BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/GameModeConfig.java index 71e347c6..e0197661 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionConfig.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/GameModeConfig.java @@ -33,17 +33,20 @@ import java.util.*; import java.util.stream.Collectors; @Getter -public class RegionConfig { +public class GameModeConfig { private final boolean loaded; + /** + * See gamemode config Times key + */ private Times Times = new Times(); private Schematic Schematic = new Schematic(); private Arena Arena = new Arena(); private Server Server = new Server(); private Techhider Techhider = new Techhider(); - public RegionConfig(File file) { + public GameModeConfig(File file) { if (file == null || !file.exists()) { loaded = false; 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 609364a1..d00cb4e1 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -64,7 +64,7 @@ public interface Region { Area getTestblockArea(); @NonNull - RegionConfig getGameModeConfig(); + GameModeConfig getGameModeConfig(); @NonNull RegionHistory getHistory(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java index bc37f66f..5d967f1a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java @@ -74,8 +74,6 @@ public interface RegionSystem { @NonNull Stream getRegions(); - boolean isModular(); - private static RegionSystem init() { try { return (RegionSystem) Class.forName("de.steamwar.bausystem.region.FixedRegionSystem").getConstructor().newInstance(); @@ -116,11 +114,6 @@ public interface RegionSystem { public Stream getRegions() { throw new UnsupportedOperationException(); } - - @Override - public boolean isModular() { - throw new UnsupportedOperationException(); - } }; } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ChangedMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ChangedMode.java index ee7e7399..07b054b7 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ChangedMode.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ChangedMode.java @@ -22,6 +22,9 @@ package de.steamwar.bausystem.region.flags; import lombok.AllArgsConstructor; import lombok.Getter; +/** + * ChangedMode defines that a Region has changed or not + */ @Getter @AllArgsConstructor public enum ChangedMode implements Flag.Value { @@ -36,7 +39,7 @@ public enum ChangedMode implements Flag.Value { @Override public ChangedMode[] getValues() { if (ChangedMode.values == null) { - ChangedMode.values = ChangedMode.values(); //NOSONAR + ChangedMode.values = ChangedMode.values(); } return ChangedMode.values; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ColorMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ColorMode.java index 1f7db755..60d8abfa 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ColorMode.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ColorMode.java @@ -22,6 +22,9 @@ package de.steamwar.bausystem.region.flags; import lombok.AllArgsConstructor; import lombok.Getter; +/** + * ColorMode defines the colors a Region can have + */ @Getter @AllArgsConstructor public enum ColorMode implements Flag.Value { @@ -49,7 +52,7 @@ public enum ColorMode implements Flag.Value { @Override public ColorMode[] getValues() { if (ColorMode.values == null) { - ColorMode.values = ColorMode.values(); //NOSONAR + ColorMode.values = ColorMode.values(); } return ColorMode.values; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/FireMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/FireMode.java index 48deb0b7..1c48b649 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/FireMode.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/FireMode.java @@ -22,6 +22,9 @@ package de.steamwar.bausystem.region.flags; import lombok.AllArgsConstructor; import lombok.Getter; +/** + * FireMode defines if fire should be enabled or disabled in a Region + */ @Getter @AllArgsConstructor public enum FireMode implements Flag.Value { @@ -35,7 +38,7 @@ public enum FireMode implements Flag.Value { @Override public FireMode[] getValues() { if (FireMode.values == null) { - FireMode.values = FireMode.values(); //NOSONAR + FireMode.values = FireMode.values(); } return FireMode.values; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/FreezeMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/FreezeMode.java index 4f80ca57..ad3f0d09 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/FreezeMode.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/FreezeMode.java @@ -23,6 +23,9 @@ package de.steamwar.bausystem.region.flags; import lombok.AllArgsConstructor; import lombok.Getter; +/** + * FreezeMode defines if freeze should be enabled or disabled in a Region + */ @Getter @AllArgsConstructor public enum FreezeMode implements Flag.Value { @@ -36,7 +39,7 @@ public enum FreezeMode implements Flag.Value { @Override public FreezeMode[] getValues() { if (FreezeMode.values == null) { - FreezeMode.values = FreezeMode.values(); //NOSONAR + FreezeMode.values = FreezeMode.values(); } return FreezeMode.values; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ItemMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ItemMode.java index a846a53c..60235e4f 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ItemMode.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ItemMode.java @@ -22,6 +22,9 @@ package de.steamwar.bausystem.region.flags; import lombok.AllArgsConstructor; import lombok.Getter; +/** + * ItemMode defines if items should be droppable or deleted in a Region + */ @Getter @AllArgsConstructor public enum ItemMode implements Flag.Value { @@ -35,7 +38,7 @@ public enum ItemMode implements Flag.Value { @Override public ItemMode[] getValues() { if (ItemMode.values == null) { - ItemMode.values = ItemMode.values(); //NOSONAR + ItemMode.values = ItemMode.values(); } return ItemMode.values; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/NoGravityMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/NoGravityMode.java index 921d36ea..98bd0b5f 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/NoGravityMode.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/NoGravityMode.java @@ -22,6 +22,9 @@ package de.steamwar.bausystem.region.flags; import lombok.AllArgsConstructor; import lombok.Getter; +/** + * NoGravityMode defines if entities and items should have gravity or not in a Region + */ @Getter @AllArgsConstructor public enum NoGravityMode implements Flag.Value { @@ -35,7 +38,7 @@ public enum NoGravityMode implements Flag.Value { @Override public NoGravityMode[] getValues() { if (NoGravityMode.values == null) { - NoGravityMode.values = NoGravityMode.values(); //NOSONAR + NoGravityMode.values = NoGravityMode.values(); } return NoGravityMode.values; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ProtectMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ProtectMode.java index be4f6132..7805d49b 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ProtectMode.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ProtectMode.java @@ -22,6 +22,9 @@ package de.steamwar.bausystem.region.flags; import lombok.AllArgsConstructor; import lombok.Getter; +/** + * ProtectMode defines if the floor should be protected inside a Region + */ @Getter @AllArgsConstructor public enum ProtectMode implements Flag.Value { @@ -35,7 +38,7 @@ public enum ProtectMode implements Flag.Value { @Override public ProtectMode[] getValues() { if (ProtectMode.values == null) { - ProtectMode.values = ProtectMode.values(); //NOSONAR + ProtectMode.values = ProtectMode.values(); } return ProtectMode.values; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/TNTMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/TNTMode.java index fe343707..8c7d61f5 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/TNTMode.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/TNTMode.java @@ -22,6 +22,9 @@ package de.steamwar.bausystem.region.flags; import lombok.AllArgsConstructor; import lombok.Getter; +/** + * TNTMode defines what TNT Explosions should destroy in a Region + */ @Getter @AllArgsConstructor public enum TNTMode implements Flag.Value { @@ -36,7 +39,7 @@ public enum TNTMode implements Flag.Value { @Override public TNTMode[] getValues() { if (TNTMode.values == null) { - TNTMode.values = TNTMode.values(); //NOSONAR + TNTMode.values = TNTMode.values(); } return TNTMode.values; } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/TestblockMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/TestblockMode.java index ba1b8f61..e89ab19f 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/TestblockMode.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/TestblockMode.java @@ -22,6 +22,9 @@ package de.steamwar.bausystem.region.flags; import lombok.AllArgsConstructor; import lombok.Getter; +/** + * TestblockMode defines where the Testblock should be inside a Region + */ @Getter @AllArgsConstructor public enum TestblockMode implements Flag.Value { @@ -37,7 +40,7 @@ public enum TestblockMode implements Flag.Value { @Override public TestblockMode[] getValues() { if (TestblockMode.values == null) { - TestblockMode.values = TestblockMode.values(); //NOSONAR + TestblockMode.values = TestblockMode.values(); } return TestblockMode.values; } diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java index 8a817870..df41ac6f 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/FixedRegionSystem.java @@ -79,9 +79,4 @@ public class FixedRegionSystem implements RegionSystem { public Stream getRegions() { return REGION_MAP.values().stream(); } - - @Override - public boolean isModular() { - return false; - } } diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegion.java index 8edc97db..39e8ca1f 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegion.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegion.java @@ -90,7 +90,7 @@ public final class FixedGlobalRegion implements Region { } }; - private static final RegionConfig GLOBAL_CONFIG = new RegionConfig(null); + private static final GameModeConfig GLOBAL_CONFIG = new GameModeConfig(null); private FixedGlobalRegion() { } @@ -126,7 +126,7 @@ public final class FixedGlobalRegion implements Region { } @Override - public @NonNull RegionConfig getGameModeConfig() { + public @NonNull GameModeConfig getGameModeConfig() { return GLOBAL_CONFIG; } diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java index 7d58262c..ab6ae1cb 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java @@ -56,7 +56,7 @@ public class FixedRegion implements Region { private final Area testblock; private final int floorLevel; private final int waterLevel; - private final RegionConfig regionConfig; + private final GameModeConfig gameModeConfig; private final RegionHistory regionHistory = new RegionHistory.Impl(20); private final RegionBackups regionBackups = new RegionBackups() { @@ -336,7 +336,7 @@ public class FixedRegion implements Region { break; } } - this.regionConfig = new RegionConfig(found); + this.gameModeConfig = new GameModeConfig(found); } @Override @@ -370,8 +370,8 @@ public class FixedRegion implements Region { } @Override - public @NonNull RegionConfig getGameModeConfig() { - return regionConfig; + public @NonNull GameModeConfig getGameModeConfig() { + return gameModeConfig; } @Override