mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-02-17 04:41:32 +01:00
Fixed an issue with flags getting double registered.
This commit is contained in:
parent
b10cf6adbc
commit
e7ff99ae96
@ -179,5 +179,8 @@ public static Flag<?> fuzzyMatchFlag(FlagRegistry flagRegistry, String id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dummy method to call that initialises the class.
|
||||
*/
|
||||
public static void registerAll() {}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
@ -122,6 +123,9 @@ private Flag<?> getOrCreate(String name) {
|
||||
public Map<Flag<?>, Object> unmarshal(Map<String, Object> rawValues, boolean createUnknown) {
|
||||
checkNotNull(rawValues, "rawValues");
|
||||
|
||||
// Ensure that flags are registered.
|
||||
Flags.registerAll();
|
||||
|
||||
ConcurrentMap<Flag<?>, Object> values = Maps.newConcurrentMap();
|
||||
ConcurrentMap<String, Object> regionFlags = Maps.newConcurrentMap();
|
||||
|
||||
|
@ -103,13 +103,13 @@ public String getName() {
|
||||
|
||||
@Override
|
||||
public Set<ProtectedRegion> loadAll(FlagRegistry flagRegistry) throws StorageException {
|
||||
Map<String, ProtectedRegion> loaded = new HashMap<String, ProtectedRegion>();
|
||||
Map<String, ProtectedRegion> loaded = new HashMap<>();
|
||||
|
||||
YAMLProcessor config = createYamlProcessor(file);
|
||||
try {
|
||||
config.load();
|
||||
} catch (FileNotFoundException e) {
|
||||
return new HashSet<ProtectedRegion>(loaded.values());
|
||||
return new HashSet<>(loaded.values());
|
||||
} catch (IOException e) {
|
||||
throw new StorageException("Failed to load region data from '" + file + "'", e);
|
||||
}
|
||||
@ -120,7 +120,7 @@ public Set<ProtectedRegion> loadAll(FlagRegistry flagRegistry) throws StorageExc
|
||||
return Collections.emptySet(); // No regions are even configured
|
||||
}
|
||||
|
||||
Map<ProtectedRegion, String> parentSets = new LinkedHashMap<ProtectedRegion, String>();
|
||||
Map<ProtectedRegion, String> parentSets = new LinkedHashMap<>();
|
||||
|
||||
for (Map.Entry<String, YAMLNode> entry : regionData.entrySet()) {
|
||||
String id = entry.getKey();
|
||||
@ -176,7 +176,7 @@ public Set<ProtectedRegion> loadAll(FlagRegistry flagRegistry) throws StorageExc
|
||||
// Relink parents
|
||||
RegionDatabaseUtils.relinkParents(loaded, parentSets);
|
||||
|
||||
return new HashSet<ProtectedRegion>(loaded.values());
|
||||
return new HashSet<>(loaded.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -192,7 +192,7 @@ public void saveAll(Set<ProtectedRegion> regions) throws StorageException {
|
||||
Map<String, Object> map = regionsNode.getMap();
|
||||
|
||||
for (ProtectedRegion region : regions) {
|
||||
Map<String, Object> nodeMap = new HashMap<String, Object>();
|
||||
Map<String, Object> nodeMap = new HashMap<>();
|
||||
map.put(region.getId(), nodeMap);
|
||||
YAMLNode node = new YAMLNode(nodeMap, false);
|
||||
|
||||
@ -207,9 +207,9 @@ public void saveAll(Set<ProtectedRegion> regions) throws StorageException {
|
||||
node.setProperty("min-y", poly.getMinimumPoint().getBlockY());
|
||||
node.setProperty("max-y", poly.getMaximumPoint().getBlockY());
|
||||
|
||||
List<Map<String, Object>> points = new ArrayList<Map<String, Object>>();
|
||||
List<Map<String, Object>> points = new ArrayList<>();
|
||||
for (BlockVector2D point : poly.getPoints()) {
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("x", point.getBlockX());
|
||||
data.put("z", point.getBlockZ());
|
||||
points.add(data);
|
||||
@ -290,7 +290,7 @@ private void setFlags(FlagRegistry flagRegistry, ProtectedRegion region, YAMLNod
|
||||
}
|
||||
|
||||
private Map<String, Object> getDomainData(DefaultDomain domain) {
|
||||
Map<String, Object> domainData = new HashMap<String, Object>();
|
||||
Map<String, Object> domainData = new HashMap<>();
|
||||
|
||||
//noinspection deprecation
|
||||
setDomainData(domainData, "players", domain.getPlayers());
|
||||
@ -305,7 +305,7 @@ private void setDomainData(Map<String, Object> domainData, String key, Set<?> do
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
List<String> list = new ArrayList<>();
|
||||
|
||||
for (Object str : domain) {
|
||||
list.add(String.valueOf(str));
|
||||
|
Loading…
Reference in New Issue
Block a user