diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionData.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionData.java index 2d662f5c..a950a24b 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionData.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionData.java @@ -109,9 +109,14 @@ public abstract class RegionData { @Override public final String toString() { - return getClass().getSimpleName() + "{" + - "flagMap=" + flagMap + - '}'; + StringBuilder st = new StringBuilder(); + st.append(getClass().getSimpleName()).append("{"); + st.append("flagMap=").append(flagMap); + for (Property p : properties) { + st.append(p); + } + st.append("}"); + return st.toString(); } private final class Property { @@ -148,5 +153,12 @@ public abstract class RegionData { flagData.put(field, writer.apply(value)); } } + + @Override + public String toString() { + Object value = this.value; + if (value != null) value = writer.apply((T) value); + return ", " + field + "=" + value; + } } } 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 index 6f4f3f21..4c44308d 100644 --- 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 @@ -86,6 +86,8 @@ public class GlobalRegion implements Region { } }; + private static final GlobalRegionData REGION_DATA = new GlobalRegionData(); + @Override public @NonNull UUID getID() { return RegionSystem.GLOBAL_REGION_ID; @@ -98,7 +100,7 @@ public class GlobalRegion implements Region { @Override public @NonNull RegionData getRegionData() { - return null; // TODO: Implement! + return REGION_DATA; } @Override diff --git a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/global/GlobalRegionData.java b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/global/GlobalRegionData.java new file mode 100644 index 00000000..1a85c5d2 --- /dev/null +++ b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/global/GlobalRegionData.java @@ -0,0 +1,54 @@ +/* + * 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 de.steamwar.bausystem.region.RegionData; +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; +import de.steamwar.bausystem.region.flags.TNTMode; +import de.steamwar.core.Core; +import lombok.NonNull; +import yapion.hierarchy.types.YAPIONObject; + +public class GlobalRegionData extends RegionData { + + public GlobalRegionData() { + super(new YAPIONObject(), () -> {}); // TODO: Implement loading of data and saving! + flagMap.put(Flag.TNT, TNTMode.DENY); + flagMap.put(Flag.COLOR, ColorMode.YELLOW); + flagMap.put(Flag.PROTECT, ProtectMode.INACTIVE); + } + + @Override + public @NonNull & Flag.Value> RegionFlagPolicy has(@NonNull Flag flag) { + if (flag.oneOf(Flag.COLOR)) { + return RegionFlagPolicy.READ_ONLY; + } + 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; + } +}