Fix unmarshalling of region group flags.

Fixes WORLDGUARD-3708.
This commit is contained in:
wizjany 2016-06-13 22:18:04 -04:00
parent ab55137f59
commit e0df194ff2
3 changed files with 15 additions and 4 deletions

View File

@ -20,10 +20,8 @@
package com.sk89q.worldguard.protection.flags;
import com.google.common.collect.Iterators;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.FlagValueCalculator;
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
import org.bukkit.command.CommandSender;
import javax.annotation.Nullable;
import java.util.Collection;

View File

@ -115,7 +115,13 @@ public Map<Flag<?>, Object> unmarshal(Map<String, Object> rawValues, boolean cre
checkNotNull(rawValues, "rawValues");
ConcurrentMap<Flag<?>, Object> values = Maps.newConcurrentMap();
ConcurrentMap<String, Object> regionFlags = Maps.newConcurrentMap();
for (Entry<String, Object> entry : rawValues.entrySet()) {
if (entry.getKey().endsWith("-group")) {
regionFlags.put(entry.getKey(), entry.getValue());
continue;
}
Flag<?> flag = createUnknown ? getOrCreate(entry.getKey()) : get(entry.getKey());
if (flag != null) {
@ -132,6 +138,15 @@ public Map<Flag<?>, Object> unmarshal(Map<String, Object> rawValues, boolean cre
}
}
}
for (Entry<String, Object> entry : regionFlags.entrySet()) {
String parentName = entry.getKey().replaceAll("-group", "");
Flag<?> parent = get(parentName);
if (parent == null || parent instanceof UnknownFlag) {
forceRegister(new UnknownFlag(entry.getKey()));
} else {
parent.getRegionGroupFlag().unmarshal(entry.getValue());
}
}
return values;
}

View File

@ -19,11 +19,9 @@
package com.sk89q.worldguard.protection.managers.storage;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regions.ProtectedRegion.CircularInheritanceException;
import javax.annotation.Nullable;
import java.util.Map;
import java.util.logging.Logger;