YAML/JSON batch permission defining (#337)

This commit is contained in:
Chris N 2017-06-22 05:41:29 -04:00 committed by Luck
parent 8e224c4a27
commit 26ce8b8ab7
2 changed files with 18 additions and 2 deletions

View File

@ -548,7 +548,15 @@ public class JSONBacking extends FlatfileBacking {
context = NodeModel.deserializeContextSet(contexts).makeImmutable();
}
nodes.add(NodeModel.of(permission, value, server, world, expiry, context));
final JsonElement batchAttribute = attributes.get("permissions");
if (permission.startsWith("luckperms.batch") && batchAttribute != null && batchAttribute.isJsonArray()) {
for (JsonElement element : batchAttribute.getAsJsonArray()) {
nodes.add(NodeModel.of(element.getAsString(), value, server, world, expiry, context));
}
} else {
nodes.add(NodeModel.of(permission, value, server, world, expiry, context));
}
}
return nodes;

View File

@ -556,7 +556,15 @@ public class YAMLBacking extends FlatfileBacking {
context = map.build();
}
nodes.add(NodeModel.of(permission, value, server, world, expiry, ImmutableContextSet.fromMultimap(context)));
if (permission.startsWith("luckperms.batch") && attributes.get("permissions") instanceof List) {
final List<String> batchPerms = (List<String>) attributes.get("permissions");
for (String rawPerm : batchPerms) {
nodes.add(NodeModel.of(rawPerm, value, server, world, expiry, ImmutableContextSet.fromMultimap(context)));
}
} else {
nodes.add(NodeModel.of(permission, value, server, world, expiry, ImmutableContextSet.fromMultimap(context)));
}
}
}