mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-10-31 07:51:05 +01:00
YAML/JSON batch permission defining (#337)
This commit is contained in:
parent
8e224c4a27
commit
26ce8b8ab7
@ -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;
|
||||
|
@ -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)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user