geforkt von Mirrors/Paper
Correctly report bad values for children perms in plugin.yml
By: Dinnerbone <dinnerbone@dinnerbone.com>
Dieser Commit ist enthalten in:
Ursprung
2b6b449dbc
Commit
c9d867579e
@ -3,6 +3,8 @@ package org.bukkit.permissions;
|
|||||||
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a unique permission that may be attached to a {@link Permissible}
|
* Represents a unique permission that may be attached to a {@link Permissible}
|
||||||
@ -127,7 +129,7 @@ public class Permission {
|
|||||||
|
|
||||||
if (data.containsKey("children")) {
|
if (data.containsKey("children")) {
|
||||||
try {
|
try {
|
||||||
children = (Map<String, Boolean>)data.get("children");
|
children = extractChildren(data);
|
||||||
} catch (ClassCastException ex) {
|
} catch (ClassCastException ex) {
|
||||||
throw new IllegalArgumentException("'children' key is of wrong type", ex);
|
throw new IllegalArgumentException("'children' key is of wrong type", ex);
|
||||||
}
|
}
|
||||||
@ -143,4 +145,17 @@ public class Permission {
|
|||||||
|
|
||||||
return new Permission(name, desc, def, children);
|
return new Permission(name, desc, def, children);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Map<String, Boolean> extractChildren(Map<String, Object> data) {
|
||||||
|
Map<String, Boolean> input = (Map<String, Boolean>)data.get("children");
|
||||||
|
Set<Entry<String, Boolean>> entries = input.entrySet();
|
||||||
|
|
||||||
|
for (Map.Entry<String, Boolean> entry : entries) {
|
||||||
|
if (!(entry.getValue() instanceof Boolean)) {
|
||||||
|
throw new IllegalArgumentException("Child '" + entry.getKey() + "' contains invalid value");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return input;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren