use of me.lucko.luckperms.api.context.ImmutableContextSet in project LuckPerms by lucko.
the class ConfigurateDao method readAttributes.
private static Collection<NodeModel> readAttributes(ConfigurationNode attributes, String permission) {
boolean value = attributes.getNode("value").getBoolean(true);
String server = attributes.getNode("server").getString("global");
String world = attributes.getNode("world").getString("global");
long expiry = attributes.getNode("expiry").getLong(0L);
ImmutableContextSet context = ImmutableContextSet.empty();
ConfigurationNode contextMap = attributes.getNode("context");
if (!contextMap.isVirtual() && contextMap.hasMapChildren()) {
context = ContextSetConfigurateSerializer.deserializeContextSet(contextMap).makeImmutable();
}
ConfigurationNode batchAttribute = attributes.getNode("permissions");
if (permission.startsWith("luckperms.batch") && !batchAttribute.isVirtual() && batchAttribute.hasListChildren()) {
List<NodeModel> nodes = new ArrayList<>();
for (ConfigurationNode element : batchAttribute.getChildrenList()) {
nodes.add(NodeModel.of(element.getString(), value, server, world, expiry, context));
}
return nodes;
} else {
return Collections.singleton(NodeModel.of(permission, value, server, world, expiry, context));
}
}
use of me.lucko.luckperms.api.context.ImmutableContextSet in project LuckPerms by lucko.
the class ConfigurateDao method readAttributes.
private static NodeModel readAttributes(ConfigurationNode attributes, Function<ConfigurationNode, String> permissionFunction) {
boolean value = attributes.getNode("value").getBoolean(true);
String server = attributes.getNode("server").getString("global");
String world = attributes.getNode("world").getString("global");
long expiry = attributes.getNode("expiry").getLong(0L);
ImmutableContextSet context = ImmutableContextSet.empty();
ConfigurationNode contextMap = attributes.getNode("context");
if (!contextMap.isVirtual() && contextMap.hasMapChildren()) {
context = ContextSetConfigurateSerializer.deserializeContextSet(contextMap).makeImmutable();
}
return NodeModel.of(permissionFunction.apply(attributes), value, server, world, expiry, context);
}
use of me.lucko.luckperms.api.context.ImmutableContextSet in project LuckPerms by lucko.
the class MongoDao method nodeFromDoc.
private static NodeModel nodeFromDoc(Document document) {
String permission = document.getString("permission");
boolean value = true;
String server = "global";
String world = "global";
long expiry = 0L;
ImmutableContextSet context = ImmutableContextSet.empty();
if (document.containsKey("value")) {
value = document.getBoolean("value");
}
if (document.containsKey("server")) {
server = document.getString("server");
}
if (document.containsKey("world")) {
world = document.getString("world");
}
if (document.containsKey("expiry")) {
expiry = document.getLong("expiry");
}
if (document.containsKey("context") && document.get("context") instanceof List) {
// noinspection unchecked
List<Document> contexts = (List<Document>) document.get("context");
context = docsToContextSet(contexts).makeImmutable();
}
return NodeModel.of(permission, value, server, world, expiry, context);
}
use of me.lucko.luckperms.api.context.ImmutableContextSet in project LuckPerms by lucko.
the class OptionInfo 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 options matching contexts &bANY&a.");
Map<ImmutableContextSet, ImmutableMap<String, String>> options = subjectData.getAllOptions();
if (options.isEmpty()) {
MessageUtils.sendPluginMessage(sender, "That subject does not have any options defined.");
return CommandResult.SUCCESS;
}
for (Map.Entry<ImmutableContextSet, ImmutableMap<String, String>> e : options.entrySet()) {
MessageUtils.sendPluginMessage(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey()) + "\n" + SpongeCommandUtils.optionsToString(e.getValue()));
}
} else {
Map<String, String> options = subjectData.getOptions(contextSet);
if (options.isEmpty()) {
MessageUtils.sendPluginMessage(sender, "That subject does not have any options defined in those contexts.");
return CommandResult.SUCCESS;
}
MessageUtils.sendPluginMessage(sender, "&aShowing options matching contexts &b" + SpongeCommandUtils.contextToString(contextSet) + "&a.\n" + SpongeCommandUtils.optionsToString(options));
}
return CommandResult.SUCCESS;
}
use of me.lucko.luckperms.api.context.ImmutableContextSet in project LuckPerms by lucko.
the class OptionSet method execute.
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List<String> args, String label) {
String key = args.get(0);
String value = args.get(1);
ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(2, args);
if (subjectData.setOption(contextSet, key, value).join()) {
MessageUtils.sendPluginMessage(sender, "&aSet &f\"" + key + "&f\"&a to &f\"" + value + "&f\"&a in context " + SpongeCommandUtils.contextToString(contextSet));
} else {
MessageUtils.sendPluginMessage(sender, "Unable to set option. Does the Subject already have it set?");
}
return CommandResult.SUCCESS;
}
Aggregations