mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-28 05:35:26 +01:00
YAML/JSON batch permission defining (#337)
This commit is contained in:
parent
8e224c4a27
commit
26ce8b8ab7
@ -548,9 +548,17 @@ public class JSONBacking extends FlatfileBacking {
|
||||
context = NodeModel.deserializeContextSet(contexts).makeImmutable();
|
||||
}
|
||||
|
||||
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,8 +556,16 @@ public class YAMLBacking extends FlatfileBacking {
|
||||
context = map.build();
|
||||
}
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return nodes;
|
||||
|
Loading…
Reference in New Issue
Block a user