Search in sources :

Example 6 with ImmutableContextSet

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

the class OptionUnset method execute.

@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List<String> args, String label) {
    String key = args.get(0);
    ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(1, args);
    if (subjectData.unsetOption(contextSet, key).join()) {
        MessageUtils.sendPluginMessage(sender, "&aUnset &f\"" + key + "&f\"&a in context " + SpongeCommandUtils.contextToString(contextSet));
    } else {
        MessageUtils.sendPluginMessage(sender, "Unable to unset option. Are you sure the Subject has it set?");
    }
    return CommandResult.SUCCESS;
}
Also used : ImmutableContextSet(me.lucko.luckperms.api.context.ImmutableContextSet)

Example 7 with ImmutableContextSet

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

the class ParentAdd method execute.

@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List<String> args, String label) {
    String collection = args.get(0);
    String name = args.get(1);
    ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(2, args);
    LPPermissionService service = Sponge.getServiceManager().provideUnchecked(LPPermissionService.class);
    if (service.getLoadedCollections().keySet().stream().map(String::toLowerCase).noneMatch(s -> s.equalsIgnoreCase(collection))) {
        MessageUtils.sendPluginMessage(sender, "Warning: SubjectCollection '&4" + collection + "&c' doesn't already exist.");
    }
    LPSubjectCollection c = service.getCollection(collection);
    if (!c.hasRegistered(name).join()) {
        MessageUtils.sendPluginMessage(sender, "Warning: Subject '&4" + name + "&c' doesn't already exist.");
    }
    LPSubject subject = c.loadSubject(name).join();
    if (subjectData.addParent(contextSet, subject.toReference()).join()) {
        MessageUtils.sendPluginMessage(sender, "&aAdded parent &b" + subject.getParentCollection().getIdentifier() + "&a/&b" + subject.getIdentifier() + "&a in context " + SpongeCommandUtils.contextToString(contextSet));
    } else {
        MessageUtils.sendPluginMessage(sender, "Unable to add parent. Does the Subject already have it added?");
    }
    return CommandResult.SUCCESS;
}
Also used : LPPermissionService(me.lucko.luckperms.sponge.service.model.LPPermissionService) LPSubject(me.lucko.luckperms.sponge.service.model.LPSubject) ImmutableContextSet(me.lucko.luckperms.api.context.ImmutableContextSet) LPSubjectCollection(me.lucko.luckperms.sponge.service.model.LPSubjectCollection)

Example 8 with ImmutableContextSet

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

the class PermissionClear 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.clearPermissions();
        MessageUtils.sendPluginMessage(sender, "&aCleared permissions matching contexts &bANY&a.");
    } else {
        subjectData.clearPermissions(contextSet);
        MessageUtils.sendPluginMessage(sender, "&aCleared permissions matching contexts &b" + SpongeCommandUtils.contextToString(contextSet));
    }
    return CommandResult.SUCCESS;
}
Also used : ImmutableContextSet(me.lucko.luckperms.api.context.ImmutableContextSet)

Example 9 with ImmutableContextSet

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

the class PermissionSet method execute.

@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List<String> args, String label) throws CommandException {
    String node = args.get(0);
    Tristate tristate = SpongeCommandUtils.parseTristate(1, args);
    ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(2, args);
    if (subjectData.setPermission(contextSet, node, tristate).join()) {
        MessageUtils.sendPluginMessage(sender, "&aSet &b" + node + "&a to &b" + tristate.toString().toLowerCase() + "&a in context " + SpongeCommandUtils.contextToString(contextSet));
    } else {
        MessageUtils.sendPluginMessage(sender, "Unable to set permission. Does the Subject already have it set?");
    }
    return CommandResult.SUCCESS;
}
Also used : Tristate(me.lucko.luckperms.api.Tristate) ImmutableContextSet(me.lucko.luckperms.api.context.ImmutableContextSet)

Example 10 with ImmutableContextSet

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

the class NodeMap method removeIf.

boolean removeIf(ContextSet contextSet, Predicate<? super Node> predicate) {
    this.lock.lock();
    try {
        ImmutableContextSet context = contextSet.makeImmutable();
        SortedSet<Node> nodes = this.map.get(context);
        boolean ret = nodes.removeIf(predicate);
        if (ret) {
            this.inheritanceMap.get(context).removeIf(predicate);
        }
        return ret;
    } finally {
        this.lock.unlock();
    }
}
Also used : LocalizedNode(me.lucko.luckperms.api.LocalizedNode) ImmutableLocalizedNode(me.lucko.luckperms.common.node.ImmutableLocalizedNode) Node(me.lucko.luckperms.api.Node) ImmutableContextSet(me.lucko.luckperms.api.context.ImmutableContextSet)

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