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