Search in sources :

Example 11 with LocalizedNode

use of me.lucko.luckperms.api.LocalizedNode in project LuckPerms by lucko.

the class PermissionHolder method getAllEntries.

private List<LocalizedNode> getAllEntries(Contexts context) {
    List<LocalizedNode> entries = new LinkedList<>();
    if (context.hasSetting(LookupSetting.RESOLVE_INHERITANCE)) {
        accumulateInheritancesTo(entries, context);
    } else {
        for (Node n : getOwnNodes(context.getContexts())) {
            ImmutableLocalizedNode localizedNode = ImmutableLocalizedNode.of(n, getObjectName());
            entries.add(localizedNode);
        }
    }
    if (!context.hasSetting(LookupSetting.INCLUDE_NODES_SET_WITHOUT_SERVER)) {
        entries.removeIf(n -> !n.isGroupNode() && !n.isServerSpecific());
    }
    if (!context.hasSetting(LookupSetting.INCLUDE_NODES_SET_WITHOUT_WORLD)) {
        entries.removeIf(n -> !n.isGroupNode() && !n.isWorldSpecific());
    }
    return entries;
}
Also used : ImmutableLocalizedNode(me.lucko.luckperms.common.node.ImmutableLocalizedNode) LocalizedNode(me.lucko.luckperms.api.LocalizedNode) ImmutableLocalizedNode(me.lucko.luckperms.common.node.ImmutableLocalizedNode) Node(me.lucko.luckperms.api.Node) LocalizedNode(me.lucko.luckperms.api.LocalizedNode) ImmutableLocalizedNode(me.lucko.luckperms.common.node.ImmutableLocalizedNode) LinkedList(java.util.LinkedList)

Example 12 with LocalizedNode

use of me.lucko.luckperms.api.LocalizedNode in project LuckPerms by lucko.

the class PermissionHolder method exportNodesAndShorthand.

public Map<String, Boolean> exportNodesAndShorthand(boolean lowerCase) {
    List<LocalizedNode> entries = resolveInheritances();
    Map<String, Boolean> perms = new HashMap<>();
    boolean applyShorthand = this.plugin.getConfiguration().get(ConfigKeys.APPLYING_SHORTHAND);
    for (Node node : entries) {
        String perm = lowerCase ? node.getPermission().toLowerCase().intern() : node.getPermission();
        if (perms.putIfAbsent(perm, node.getValuePrimitive()) == null && applyShorthand) {
            List<String> shorthand = node.resolveShorthand();
            if (!shorthand.isEmpty()) {
                for (String s : shorthand) {
                    perms.putIfAbsent((lowerCase ? s.toLowerCase() : s).intern(), node.getValuePrimitive());
                }
            }
        }
    }
    return ImmutableMap.copyOf(perms);
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) LocalizedNode(me.lucko.luckperms.api.LocalizedNode) ImmutableLocalizedNode(me.lucko.luckperms.common.node.ImmutableLocalizedNode) Node(me.lucko.luckperms.api.Node) LocalizedNode(me.lucko.luckperms.api.LocalizedNode) ImmutableLocalizedNode(me.lucko.luckperms.common.node.ImmutableLocalizedNode)

Aggregations

LocalizedNode (me.lucko.luckperms.api.LocalizedNode)12 Node (me.lucko.luckperms.api.Node)6 ImmutableLocalizedNode (me.lucko.luckperms.common.node.ImmutableLocalizedNode)5 TextComponent (net.kyori.text.TextComponent)5 List (java.util.List)4 HashSet (java.util.HashSet)3 TreeSet (java.util.TreeSet)3 Maps (com.google.common.collect.Maps)2 ArrayList (java.util.ArrayList)2 Comparator (java.util.Comparator)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Set (java.util.Set)2 SortedSet (java.util.SortedSet)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Consumer (java.util.function.Consumer)2 ChatMetaType (me.lucko.luckperms.api.ChatMetaType)2 CommandManager (me.lucko.luckperms.common.command.CommandManager)2 CommandResult (me.lucko.luckperms.common.command.CommandResult)2 SharedSubCommand (me.lucko.luckperms.common.command.abstraction.SharedSubCommand)2