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;
}
Aggregations