Search in sources :

Example 16 with ImmutableContextSet

use of me.lucko.luckperms.api.context.ImmutableContextSet in project LuckPerms by lucko.

the class NodeMap method add.

void add(Node node) {
    this.lock.lock();
    try {
        ImmutableContextSet context = node.getFullContexts().makeImmutable();
        this.map.put(context, node);
        if (node.isGroupNode() && node.getValuePrimitive()) {
            this.inheritanceMap.put(context, node);
        }
    } finally {
        this.lock.unlock();
    }
}
Also used : ImmutableContextSet(me.lucko.luckperms.api.context.ImmutableContextSet)

Example 17 with ImmutableContextSet

use of me.lucko.luckperms.api.context.ImmutableContextSet in project LuckPerms by lucko.

the class OptionClear method execute.

@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List<String> args, String label) {
    ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(0, args);
    if (contextSet.isEmpty()) {
        subjectData.clearOptions();
        MessageUtils.sendPluginMessage(sender, "&aCleared options matching contexts &bANY&a.");
    } else {
        subjectData.clearOptions(contextSet);
        MessageUtils.sendPluginMessage(sender, "&aCleared options matching contexts &b" + SpongeCommandUtils.contextToString(contextSet));
    }
    return CommandResult.SUCCESS;
}
Also used : ImmutableContextSet(me.lucko.luckperms.api.context.ImmutableContextSet)

Example 18 with ImmutableContextSet

use of me.lucko.luckperms.api.context.ImmutableContextSet in project LuckPerms by lucko.

the class WebEditor method deserializePermissions.

public static Set<NodeModel> deserializePermissions(JsonArray permissionsSection) {
    Set<NodeModel> nodes = new HashSet<>();
    for (JsonElement ent : permissionsSection) {
        if (!ent.isJsonObject()) {
            continue;
        }
        JsonObject data = ent.getAsJsonObject();
        String permission = data.get("permission").getAsString();
        boolean value = true;
        String server = "global";
        String world = "global";
        long expiry = 0L;
        ImmutableContextSet context = ImmutableContextSet.empty();
        if (data.has("value")) {
            value = data.get("value").getAsBoolean();
        }
        if (data.has("server")) {
            server = data.get("server").getAsString();
        }
        if (data.has("world")) {
            world = data.get("world").getAsString();
        }
        if (data.has("expiry")) {
            expiry = data.get("expiry").getAsLong();
        }
        if (data.has("context") && data.get("context").isJsonObject()) {
            JsonObject contexts = data.get("context").getAsJsonObject();
            context = ContextSetJsonSerializer.deserializeContextSet(contexts).makeImmutable();
        }
        nodes.add(NodeModel.of(permission, value, server, world, expiry, context));
    }
    return nodes;
}
Also used : NodeModel(me.lucko.luckperms.common.node.NodeModel) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) ImmutableContextSet(me.lucko.luckperms.api.context.ImmutableContextSet) HashSet(java.util.HashSet)

Example 19 with ImmutableContextSet

use of me.lucko.luckperms.api.context.ImmutableContextSet in project LuckPerms by lucko.

the class ParentClear method execute.

@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List<String> args, String label) {
    ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(0, args);
    if (contextSet.isEmpty()) {
        subjectData.clearParents();
        MessageUtils.sendPluginMessage(sender, "&aCleared parents matching contexts &bANY&a.");
    } else {
        subjectData.clearParents(contextSet);
        MessageUtils.sendPluginMessage(sender, "&aCleared parents matching contexts &b" + SpongeCommandUtils.contextToString(contextSet));
    }
    return CommandResult.SUCCESS;
}
Also used : ImmutableContextSet(me.lucko.luckperms.api.context.ImmutableContextSet)

Example 20 with ImmutableContextSet

use of me.lucko.luckperms.api.context.ImmutableContextSet in project LuckPerms by lucko.

the class ParentInfo method execute.

@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List<String> args, String label) {
    ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(0, args);
    if (contextSet.isEmpty()) {
        MessageUtils.sendPluginMessage(sender, "&aShowing parents matching contexts &bANY&a.");
        Map<ImmutableContextSet, ImmutableList<LPSubjectReference>> parents = subjectData.getAllParents();
        if (parents.isEmpty()) {
            MessageUtils.sendPluginMessage(sender, "That subject does not have any parents defined.");
            return CommandResult.SUCCESS;
        }
        for (Map.Entry<ImmutableContextSet, ImmutableList<LPSubjectReference>> e : parents.entrySet()) {
            MessageUtils.sendPluginMessage(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey()) + "\n" + SpongeCommandUtils.parentsToString(e.getValue()));
        }
    } else {
        List<LPSubjectReference> parents = subjectData.getParents(contextSet);
        if (parents.isEmpty()) {
            MessageUtils.sendPluginMessage(sender, "That subject does not have any parents defined in those contexts.");
            return CommandResult.SUCCESS;
        }
        MessageUtils.sendPluginMessage(sender, "&aShowing parents matching contexts &b" + SpongeCommandUtils.contextToString(contextSet) + "&a.\n" + SpongeCommandUtils.parentsToString(parents));
    }
    return CommandResult.SUCCESS;
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) LPSubjectReference(me.lucko.luckperms.sponge.service.model.LPSubjectReference) ImmutableContextSet(me.lucko.luckperms.api.context.ImmutableContextSet) Map(java.util.Map)

Aggregations

ImmutableContextSet (me.lucko.luckperms.api.context.ImmutableContextSet)27 Map (java.util.Map)10 ImmutableMap (com.google.common.collect.ImmutableMap)9 HashMap (java.util.HashMap)6 LPSubjectReference (me.lucko.luckperms.sponge.service.model.LPSubjectReference)6 Node (me.lucko.luckperms.api.Node)5 ImmutableList (com.google.common.collect.ImmutableList)4 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 List (java.util.List)3 LPSubject (me.lucko.luckperms.sponge.service.model.LPSubject)3 JsonObject (com.google.gson.JsonObject)2 LinkedHashSet (java.util.LinkedHashSet)2 Set (java.util.Set)2 SortedMap (java.util.SortedMap)2 TreeMap (java.util.TreeMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Tristate (me.lucko.luckperms.api.Tristate)2 ContextSet (me.lucko.luckperms.api.context.ContextSet)2 NodeModel (me.lucko.luckperms.common.node.NodeModel)2