use of ninja.leaping.configurate.Types in project LuckPerms by lucko.
the class ConfigurateDao method readNodes.
private static Set<NodeModel> readNodes(ConfigurationNode data) {
Set<NodeModel> nodes = new HashSet<>();
if (data.getNode("permissions").hasListChildren()) {
List<? extends ConfigurationNode> children = data.getNode("permissions").getChildrenList();
for (ConfigurationNode appended : children) {
String plainValue = appended.getValue(Types::strictAsString);
if (plainValue != null) {
nodes.add(NodeModel.of(plainValue));
continue;
}
Map.Entry<String, ConfigurationNode> entry = parseEntry(appended);
if (entry == null) {
continue;
}
nodes.addAll(readAttributes(entry.getValue(), entry.getKey()));
}
}
if (data.getNode("parents").hasListChildren()) {
List<? extends ConfigurationNode> children = data.getNode("parents").getChildrenList();
for (ConfigurationNode appended : children) {
String stringValue = appended.getValue(Types::strictAsString);
if (stringValue != null) {
nodes.add(NodeModel.of(NodeFactory.groupNode(stringValue)));
continue;
}
Map.Entry<String, ConfigurationNode> entry = parseEntry(appended);
if (entry == null) {
continue;
}
nodes.add(readAttributes(entry.getValue(), c -> NodeFactory.groupNode(entry.getKey())));
}
}
for (ChatMetaType chatMetaType : ChatMetaType.values()) {
String keyName = chatMetaType.toString() + "es";
if (data.getNode(keyName).hasListChildren()) {
List<? extends ConfigurationNode> children = data.getNode(keyName).getChildrenList();
for (ConfigurationNode appended : children) {
Map.Entry<String, ConfigurationNode> entry = parseEntry(appended);
if (entry == null) {
continue;
}
nodes.add(readAttributes(entry.getValue(), c -> NodeFactory.chatMetaNode(chatMetaType, c.getNode("priority").getInt(0), entry.getKey())));
}
}
}
if (data.getNode("meta").hasListChildren()) {
List<? extends ConfigurationNode> children = data.getNode("meta").getChildrenList();
for (ConfigurationNode appended : children) {
Map.Entry<String, ConfigurationNode> entry = parseEntry(appended);
if (entry == null) {
continue;
}
nodes.add(readAttributes(entry.getValue(), c -> NodeFactory.metaNode(entry.getKey(), entry.getValue().getNode("value").getString("null"))));
}
}
return nodes;
}
Aggregations