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