Fix Region.linkedRegion
Dieser Commit ist enthalten in:
Ursprung
cf551cdbab
Commit
a36267a14e
@ -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<Region> regionConsumer) {
|
||||
private void setLinkedRegion(Predicate<Region> 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 <T extends Enum<T> & Flag.Value<T>> Flag.Value<T> get(Flag flagType) {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren