diff --git a/paper-api/src/main/java/org/bukkit/permissions/Permission.java b/paper-api/src/main/java/org/bukkit/permissions/Permission.java index d219832ab1..5acbe220f3 100644 --- a/paper-api/src/main/java/org/bukkit/permissions/Permission.java +++ b/paper-api/src/main/java/org/bukkit/permissions/Permission.java @@ -3,6 +3,8 @@ package org.bukkit.permissions; import java.util.LinkedHashMap; 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} @@ -127,7 +129,7 @@ public class Permission { if (data.containsKey("children")) { try { - children = (Map)data.get("children"); + children = extractChildren(data); } catch (ClassCastException 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); } + + private static Map extractChildren(Map data) { + Map input = (Map)data.get("children"); + Set> entries = input.entrySet(); + + for (Map.Entry entry : entries) { + if (!(entry.getValue() instanceof Boolean)) { + throw new IllegalArgumentException("Child '" + entry.getKey() + "' contains invalid value"); + } + } + + return input; + } }