From 7cee11a1ef5baf41eb9c0e3923fab001e8315d3f Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 19 Dec 2025 11:45:51 +0100 Subject: [PATCH] Add GlobalRegion --- .../bausystem/region/DynamicRegionSystem.java | 4 +- .../region/dynamic/global/GlobalRegion.java | 133 ++++++++++++++++++ 2 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/global/GlobalRegion.java diff --git a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionSystem.java b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionSystem.java index 038af844..70505246 100644 --- a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionSystem.java +++ b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionSystem.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.region; import de.steamwar.bausystem.region.dynamic.Tile; +import de.steamwar.bausystem.region.dynamic.global.GlobalRegion; import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -49,7 +50,6 @@ public class DynamicRegionSystem implements RegionSystem { @Override public void save() { - } @Override @@ -59,7 +59,7 @@ public class DynamicRegionSystem implements RegionSystem { @Override public @NonNull Region getGlobalRegion() { - return null; + return GlobalRegion.INSTANCE; } private Region get(int x, int z, boolean fastCache, Collection regions) { diff --git a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/global/GlobalRegion.java b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/global/GlobalRegion.java new file mode 100644 index 00000000..6f4f3f21 --- /dev/null +++ b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/global/GlobalRegion.java @@ -0,0 +1,133 @@ +/* + * This file is a part of the SteamWar software. + * + * 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 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.dynamic.global; + +import com.sk89q.worldedit.extent.clipboard.Clipboard; +import de.steamwar.bausystem.region.*; +import de.steamwar.bausystem.utils.PasteBuilder; +import de.steamwar.sql.GameModeConfig; +import lombok.NonNull; +import org.bukkit.Location; +import org.bukkit.Material; + +import javax.annotation.Nullable; +import java.io.File; +import java.util.UUID; +import java.util.function.BiConsumer; + +public class GlobalRegion implements Region { + + public static final GlobalRegion INSTANCE = new GlobalRegion(); + + 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 Region.Area GLOBAL_AREA = new Region.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 Clipboard 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; + } + }; + + @Override + public @NonNull UUID getID() { + return RegionSystem.GLOBAL_REGION_ID; + } + + @Override + public @NonNull RegionType getType() { + return RegionType.GLOBAL; + } + + @Override + public @NonNull RegionData getRegionData() { + return null; // TODO: Implement! + } + + @Override + public @NonNull Area getArea() { + return GLOBAL_AREA; + } + + @Override + public @NonNull Area getBuildArea() { + return Area.EMPTY; + } + + @Override + public @NonNull Area getTestblockArea() { + return Area.EMPTY; + } + + @Override + public @NonNull GameModeConfig getGameModeConfig() { + return GameModeConfig.getDefaults(); + } + + @Override + public @NonNull RegionHistory getHistory() { + return RegionHistory.EMPTY; + } + + @Override + public @NonNull RegionBackups getBackups() { + return RegionBackups.EMPTY; + } +}