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 30acd6cc..33d5bafc 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 @@ -175,15 +175,15 @@ public class TestblockCommand extends SWCommand { private Region regionCheck(Player player) { Region region = Region.getRegion(player.getLocation()); - if (region.getFlags().has(Flag.TESTBLOCK).isWritable() && region.getFlags().get(Flag.TESTBLOCK).isWithDefault(TestblockMode.NO_VALUE)) { + if (region.getRegionData().has(Flag.TESTBLOCK).isWritable() && region.getRegionData().get(Flag.TESTBLOCK).isWithDefault(TestblockMode.NO_VALUE)) { Point minPoint = region.getArea().getMinPoint(false); Point maxPoint = region.getArea().getMaxPoint(false); // TODO: Check if empty! int half = minPoint.getZ() + (maxPoint.getZ() - minPoint.getZ()) / 2; if (player.getLocation().getBlockZ() <= half) { - region.getFlags().set(Flag.TESTBLOCK, TestblockMode.SOUTH); + region.getRegionData().set(Flag.TESTBLOCK, TestblockMode.SOUTH); } else { - region.getFlags().set(Flag.TESTBLOCK, TestblockMode.NORTH); + region.getRegionData().set(Flag.TESTBLOCK, TestblockMode.NORTH); } } if (region.getTestblockArea().isEmpty()) { 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 1dcd9223..dba69038 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 @@ -121,8 +121,8 @@ public class BauScoreboard implements Listener { Region region = Region.getRegion(player.getLocation()); if (region.getType().isGlobal()) return "§eSteam§8War"; String colorCode = "§e"; - if (region.getFlags().has(Flag.COLOR).isReadable()) { - colorCode = "§" + region.getFlags().get(Flag.COLOR).getWithDefault().getColorCode(); + if (region.getRegionData().has(Flag.COLOR).isReadable()) { + colorCode = "§" + region.getRegionData().get(Flag.COLOR).getWithDefault().getColorCode(); } return colorCode + "■ §eSteam§8War " + colorCode + "■"; // ■ } 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 a1d94ed4..2d662f5c 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionData.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionData.java @@ -37,44 +37,8 @@ public abstract class RegionData { protected final YAPIONObject data; protected final YAPIONObject flagData; protected final Runnable onChange; + protected final Map, Flag.Value> flagMap = new HashMap<>(); - - private final class Property { - private final String field; - private final Function loader; - private final Function writer; - - private T value; - - public Property(String field, Function loader, Function writer) { - this.field = field; - this.loader = loader; - this.writer = writer; - properties.add(this); - } - - public void load() { - if (flagData.containsKey(field)) { - value = loader.apply(flagData.getPlainValue(field)); - } else { - value = null; - } - } - - public T get() { - return value; - } - - public void set(T value) { - this.value = value; - if (value == null) { - flagData.remove(field); - } else { - flagData.put(field, writer.apply(value)); - } - } - } - private Property testblockSchematic = new Property<>("testblockSchematic", SchematicNode::byId, SchematicNode::getId); protected RegionData(YAPIONObject data, Runnable onChange) { @@ -149,4 +113,40 @@ public abstract class RegionData { "flagMap=" + flagMap + '}'; } + + private final class Property { + private final String field; + private final Function loader; + private final Function writer; + + private T value; + + public Property(String field, Function loader, Function writer) { + this.field = field; + this.loader = loader; + this.writer = writer; + properties.add(this); + } + + public void load() { + if (flagData.containsKey(field)) { + value = loader.apply(flagData.getPlainValue(field)); + } else { + value = null; + } + } + + public T get() { + return value; + } + + public void set(T value) { + this.value = value; + if (value == null) { + flagData.remove(field); + } else { + flagData.put(field, writer.apply(value)); + } + } + } }