Search in sources :

Example 1 with PermissionNode

use of net.luckperms.api.node.types.PermissionNode in project LuckPerms by lucko.

the class CalculatedSubjectData method resolvePermissions.

public Map<String, Node> resolvePermissions(QueryOptions filter) {
    // get relevant entries
    SortedMap<ImmutableContextSet, Map<String, Node>> sorted = new TreeMap<>(ContextSetComparator.reverse());
    for (Map.Entry<ImmutableContextSet, Map<String, Boolean>> entry : this.permissions.entrySet()) {
        if (!filter.satisfies(entry.getKey(), defaultSatisfyMode())) {
            continue;
        }
        Map<String, Node> nodeMap = new HashMap<>();
        entry.getValue().forEach((key, value) -> {
            PermissionNode node = Permission.builder().permission(key).value(value).context(entry.getKey()).withMetadata(InheritanceOriginMetadata.KEY, this.inheritanceOrigin).build();
            nodeMap.put(key, node);
        });
        sorted.put(entry.getKey(), nodeMap);
    }
    // flatten
    Map<String, Node> result = new HashMap<>();
    for (Map<String, Node> map : sorted.values()) {
        for (Map.Entry<String, Node> e : map.entrySet()) {
            result.putIfAbsent(e.getKey(), e.getValue());
        }
    }
    return result;
}
Also used : HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Node(net.luckperms.api.node.Node) PermissionNode(net.luckperms.api.node.types.PermissionNode) MetaNode(net.luckperms.api.node.types.MetaNode) ImmutableContextSet(net.luckperms.api.context.ImmutableContextSet) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) PermissionNode(net.luckperms.api.node.types.PermissionNode)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ImmutableContextSet (net.luckperms.api.context.ImmutableContextSet)1 Node (net.luckperms.api.node.Node)1 MetaNode (net.luckperms.api.node.types.MetaNode)1 PermissionNode (net.luckperms.api.node.types.PermissionNode)1