mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-08-05 16:49:39 +00:00
Correctly report bad values for children perms in plugin.yml
This commit is contained in:
parent
d894e11b51
commit
40bbf19ca2
1 changed files with 16 additions and 1 deletions
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue