diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java index d7d68dcd..432a8f64 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -38,6 +38,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.function.Consumer; +import java.util.function.Predicate; @Getter public class Region { @@ -92,9 +93,7 @@ public class Region { REGION_LIST.add(this); } - if (regionConfig.containsKey("linkedWith")) { - linkedRegionName = regionConfig.getPlainValue("linkedWith"); - } + linkedRegionName = regionConfig.getPlainValueOrDefault("optionsLinkedWith", null); prototypes = new HashSet<>(); if (regionConfig.containsKey("prototypes", YAPIONType.ARRAY)) { @@ -199,18 +198,24 @@ public class Region { return prototype != null ? prototype.getDisplayName() : ""; } - private void setLinkedRegion(Consumer regionConsumer) { + private void setLinkedRegion(Predicate regionConsumer) { if (linkedRegionName == null) { return; } if (linkedRegion != null) { - regionConsumer.accept(linkedRegion); + if (regionConsumer.test(linkedRegion)) { + linkedRegion.regionData.add("flagStorage", FlagStorage.toYAPION(linkedRegion.flagStorage)); + RegionLoader.save(); + } return; } for (Region region : REGION_LIST) { - if (region.name.equals(name)) { + if (region.name.equals(linkedRegionName)) { linkedRegion = region; - regionConsumer.accept(linkedRegion); + if (regionConsumer.test(linkedRegion)) { + linkedRegion.regionData.add("flagStorage", FlagStorage.toYAPION(linkedRegion.flagStorage)); + RegionLoader.save(); + } return; } } @@ -220,11 +225,15 @@ public class Region { if (this.prototype == null) { return; } + if (!prototypes.contains(prototype)) { + return; + } regionData.add("prototype", prototype.getName()); generatePrototypeData(prototype, minPoint); setLinkedRegion(region -> { region.regionData.add("prototype", prototype.getName()); region.generatePrototypeData(prototype, region.minPoint); + return true; }); } @@ -233,7 +242,7 @@ public class Region { regionData.add("flagStorage", FlagStorage.toYAPION(flagStorage)); RegionLoader.save(); } - setLinkedRegion(region -> region.set(flagType, value)); + setLinkedRegion(region -> region.flagStorage.set(flagType, value)); } public & Flag.Value> Flag.Value get(Flag flagType) {