/** * Create a new node tree with the given values, and the specified root * fallback value. * * @param values The values to be contained in this node tree * @param defaultValue The fallback value for any completely undefined nodes * @return The newly created node tree */ public static NodeTree of(Map<String, Boolean> values, Tristate defaultValue) { NodeTree newTree = new NodeTree(defaultValue); for (Map.Entry<String, Boolean> value : values.entrySet()) { Iterable<String> parts = NODE_SPLITTER.split(value.getKey().toLowerCase()); Node currentNode = newTree.rootNode; for (String part : parts) { if (currentNode.children.containsKey(part)) { currentNode = currentNode.children.get(part); } else { Node newNode = new Node(new HashMap<>()); currentNode.children.put(part, newNode); currentNode = newNode; } } currentNode.value = Tristate.fromBoolean(value.getValue()); } return newTree; }
/** * Create a new node tree with the given values, and the specified root fallback value. * * @param values The values to be contained in this node tree * @param defaultValue The fallback value for any completely undefined nodes * @return The newly created node tree */ public static NodeTree of(Map<String, Boolean> values, Tristate defaultValue) { NodeTree newTree = new NodeTree(defaultValue); for (Map.Entry<String, Boolean> value : values.entrySet()) { String[] parts = SPLIT_REGEX.split(value.getKey().toLowerCase()); Node currentNode = newTree.rootNode; for (String part : parts) { if (currentNode.children.containsKey(part)) { currentNode = currentNode.children.get(part); } else { Node newNode = new Node(new HashMap<>()); currentNode.children.put(part, newNode); currentNode = newNode; } } currentNode.value = Tristate.fromBoolean(value.getValue()); } return newTree; }
public void unprotect(Player player) { //notify BungeeCord plugins for the login channel.sendTo(player, buf -> buf.writeUTF(LOGIN_ACTION)); ProtectionData data = protections.remove(player.getUniqueId()); if (data == null) { return; } //teleport if (config.getGeneral().getTeleport().isEnabled()) { safeTeleport(player, data.getOldLocation()); } //restore permissions SubjectData subjectData = player.getTransientSubjectData(); Map<Set<Context>, Map<String, Boolean>> oldPermissions = data.getPermissions(); for (Entry<Set<Context>, Map<String, Boolean>> permission : oldPermissions.entrySet()) { Set<Context> context = permission.getKey(); for (Entry<String, Boolean> perm : permission.getValue().entrySet()) { subjectData.setPermission(context, perm.getKey(), Tristate.fromBoolean(perm.getValue())); } } }