Search in sources :

Example 1 with Types

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;
}
Also used : LogEntry(me.lucko.luckperms.api.LogEntry) FilenameFilter(java.io.FilenameFilter) Iterables(com.google.common.collect.Iterables) AbstractDao(me.lucko.luckperms.common.storage.dao.AbstractDao) Arrays(java.util.Arrays) UserIdentifier(me.lucko.luckperms.common.references.UserIdentifier) BulkUpdate(me.lucko.luckperms.common.bulkupdate.BulkUpdate) Function(java.util.function.Function) ConfigurationLoader(ninja.leaping.configurate.loader.ConfigurationLoader) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) PlayerSaveResult(me.lucko.luckperms.common.storage.PlayerSaveResult) NodeModel(me.lucko.luckperms.common.node.NodeModel) Map(java.util.Map) ConfigurationNode(ninja.leaping.configurate.ConfigurationNode) LuckPermsPlugin(me.lucko.luckperms.common.plugin.LuckPermsPlugin) SimpleConfigurationNode(ninja.leaping.configurate.SimpleConfigurationNode) Types(ninja.leaping.configurate.Types) HeldPermission(me.lucko.luckperms.api.HeldPermission) Path(java.nio.file.Path) LinkedHashSet(java.util.LinkedHashSet) GroupManager(me.lucko.luckperms.common.managers.group.GroupManager) Collection(java.util.Collection) NodeHeldPermission(me.lucko.luckperms.common.node.NodeHeldPermission) Set(java.util.Set) IOException(java.io.IOException) ImmutableContextSet(me.lucko.luckperms.api.context.ImmutableContextSet) Log(me.lucko.luckperms.common.actionlog.Log) NodeFactory(me.lucko.luckperms.common.node.NodeFactory) UUID(java.util.UUID) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) File(java.io.File) MetaType(me.lucko.luckperms.common.node.MetaType) Objects(java.util.Objects) ContextSetConfigurateSerializer(me.lucko.luckperms.common.contexts.ContextSetConfigurateSerializer) Track(me.lucko.luckperms.common.model.Track) ImmutableCollectors(me.lucko.luckperms.common.utils.ImmutableCollectors) List(java.util.List) TrackManager(me.lucko.luckperms.common.managers.track.TrackManager) ChatMetaType(me.lucko.luckperms.api.ChatMetaType) Group(me.lucko.luckperms.common.model.Group) Optional(java.util.Optional) Node(me.lucko.luckperms.api.Node) Collections(java.util.Collections) User(me.lucko.luckperms.common.model.User) Uuids(me.lucko.luckperms.common.utils.Uuids) Types(ninja.leaping.configurate.Types) NodeModel(me.lucko.luckperms.common.node.NodeModel) ConfigurationNode(ninja.leaping.configurate.ConfigurationNode) SimpleConfigurationNode(ninja.leaping.configurate.SimpleConfigurationNode) ChatMetaType(me.lucko.luckperms.api.ChatMetaType) Map(java.util.Map) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

Iterables (com.google.common.collect.Iterables)1 Maps (com.google.common.collect.Maps)1 File (java.io.File)1 FilenameFilter (java.io.FilenameFilter)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Set (java.util.Set)1 UUID (java.util.UUID)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1