use of me.lucko.luckperms.common.node.NodeModel in project LuckPerms by lucko.
the class ConfigurateDao method loadGroup.
@Override
public Optional<Group> loadGroup(String name) throws Exception {
Group group = this.plugin.getGroupManager().getIfLoaded(name);
if (group != null) {
group.getIoLock().lock();
}
try {
ConfigurationNode object = readFile(StorageLocation.GROUP, name);
if (object == null) {
return Optional.empty();
}
if (group == null) {
group = this.plugin.getGroupManager().getOrMake(name);
group.getIoLock().lock();
}
Set<NodeModel> data = readNodes(object);
Set<Node> nodes = data.stream().map(NodeModel::toNode).collect(Collectors.toSet());
group.setEnduringNodes(nodes);
} catch (Exception e) {
throw reportException(name, e);
} finally {
if (group != null) {
group.getIoLock().unlock();
}
}
group.getRefreshBuffer().requestDirectly();
return Optional.of(group);
}
use of me.lucko.luckperms.common.node.NodeModel 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;
}
Aggregations