当前位置: 首页>>代码示例>>Java>>正文


Java SimpleConfigurationNode.root方法代码示例

本文整理汇总了Java中ninja.leaping.configurate.SimpleConfigurationNode.root方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleConfigurationNode.root方法的具体用法?Java SimpleConfigurationNode.root怎么用?Java SimpleConfigurationNode.root使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ninja.leaping.configurate.SimpleConfigurationNode的用法示例。


在下文中一共展示了SimpleConfigurationNode.root方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: save

import ninja.leaping.configurate.SimpleConfigurationNode; //导入方法依赖的package包/类
public ConfigurationNode save() {
    try {
        ConfigurationNode node = SimpleConfigurationNode.root();
        ConfigurationNode world_node = node.getNode("WORLD");
        ConfigurationNode x_node = node.getNode("X");
        ConfigurationNode y_node = node.getNode("Y");
        ConfigurationNode z_node = node.getNode("Z");
        world_node.setValue(world_field.hasText() ? world_field.getText() : null);
        x_node.setValue(x_field.hasText() ? x_field.getText() : null);
        y_node.setValue(y_field.hasText() ? y_field.getText() : null);
        z_node.setValue(z_field.hasText() ? z_field.getText() : null);
        return node;
    } catch (Exception e) {
        throw new RuntimeException("Exception saving Location Panel!", e);
    }
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:17,代码来源:LocationPanel.java

示例2: FlatSuperObjectPanel

import ninja.leaping.configurate.SimpleConfigurationNode; //导入方法依赖的package包/类
public FlatSuperObjectPanel(boolean full, SuperObjectType super_object_type, String[] strings) {
    this.super_object_type = super_object_type;
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
    delete_button = new DeleteButton();
    add(delete_button);
    combo_box = new AdvancedComboBox(strings);
    combo_box.setEditable(true);
    Dimension combo_box_dimension = full ? new Dimension(210, 20) : new Dimension(100, 20);
    combo_box.setPreferredSize(combo_box_dimension);
    combo_box.setMaximumSize(combo_box_dimension);
    combo_box.addActionListener(e -> {
        combo_box.setEnabled(false);
        node.getNode("TYPE").setValue(getType());
    });
    add(combo_box);
    configure_button = new AdvancedConfigurationButton(super_object_type, this::getType, this::getNode);
    add(configure_button);
    node = SimpleConfigurationNode.root();
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:20,代码来源:FlatSuperObjectPanel.java

示例3: save

import ninja.leaping.configurate.SimpleConfigurationNode; //导入方法依赖的package包/类
@Override
public void save() {
    super.save();
    try {
        ConfigurationNode node = getNode();
        ConfigurationNode commands_node = node.getNode("COMMANDS");
        if (commands.isEmpty()) {
            commands_node.setValue(null);
        } else {
            List<ConfigurationNode> command_nodes = new ArrayList<ConfigurationNode>();
            for (CommandPanel command_panel : commands) {
                if (command_panel.getCommandField().hasText()) {
                    ConfigurationNode command_node = SimpleConfigurationNode.root();
                    command_node.getNode("CMD").setValue(command_panel.getCommandField().getText());
                    command_node.getNode("CONSOLE").setValue(command_panel.getConsoleCheckBox().isSelected());
                    command_nodes.add(command_node);
                }
            }
            commands_node.setValue(command_nodes);
        }
    } catch (Exception e) {
        throw new RuntimeException("Exception saving Commands Drop Configuration Dialog!", e);
    }
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:25,代码来源:CommandsDropConfigurationDialog.java

示例4: deserializeItemEnchantment

import ninja.leaping.configurate.SimpleConfigurationNode; //导入方法依赖的package包/类
private Optional<Object> deserializeItemEnchantment(String s)
{
    try
    {
        int colonFirst = s.indexOf(':'), colonIndex = s.lastIndexOf(':');
        String enchantmentId = colonFirst == colonIndex ? s : s.substring(0, colonIndex);
        int enchantmentLevel = colonFirst == colonIndex ? 1 : Coerce.toInteger(s.substring(colonIndex + 1));

        ConfigurationNode node = SimpleConfigurationNode.root(/* default deserializer */);
        node.getNode(Queries.ENCHANTMENT_ID.toString()).setValue(enchantmentId);
        node.getNode(Queries.LEVEL.toString()).setValue(enchantmentLevel);
        return Optional.ofNullable(node.getValue(ITEM_ENCHANTMENT));
    }
    catch (Exception e)
    {
        return Optional.empty();
    }
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:19,代码来源:VirtualChestItemStackSerializer.java

示例5: resolvePath

import ninja.leaping.configurate.SimpleConfigurationNode; //导入方法依赖的package包/类
private ConfigurationNode resolvePath(String path) {
    Iterable<String> paths = Splitter.on('.').split(path);
    ConfigurationNode node = this.root;

    if (node == null) {
        throw new RuntimeException("Config is not loaded.");
    }

    for (String s : paths) {
        node = node.getNode(s);

        if (node == null) {
            return SimpleConfigurationNode.root();
        }
    }

    return node;
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:19,代码来源:SpongeConfigAdapter.java

示例6: saveUser

import ninja.leaping.configurate.SimpleConfigurationNode; //导入方法依赖的package包/类
@Override
public void saveUser(User user) throws Exception {
    user.getIoLock().lock();
    try {
        if (!this.plugin.getUserManager().shouldSave(user)) {
            saveFile(StorageLocation.USER, user.getUuid().toString(), null);
        } else {
            ConfigurationNode data = SimpleConfigurationNode.root();
            data.getNode("uuid").setValue(user.getUuid().toString());
            data.getNode("name").setValue(user.getName().orElse("null"));
            data.getNode(this instanceof JsonDao ? "primaryGroup" : "primary-group").setValue(user.getPrimaryGroup().getStoredValue().orElse(NodeFactory.DEFAULT_GROUP_NAME));

            Set<NodeModel> nodes = user.getEnduringNodes().values().stream().map(NodeModel::fromNode).collect(Collectors.toCollection(LinkedHashSet::new));
            writeNodes(data, nodes);

            saveFile(StorageLocation.USER, user.getUuid().toString(), data);
        }
    } catch (Exception e) {
        throw reportException(user.getUuid().toString(), e);
    } finally {
        user.getIoLock().unlock();
    }
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:24,代码来源:ConfigurateDao.java

示例7: saveGroup

import ninja.leaping.configurate.SimpleConfigurationNode; //导入方法依赖的package包/类
@Override
public void saveGroup(Group group) throws Exception {
    group.getIoLock().lock();
    try {
        ConfigurationNode data = SimpleConfigurationNode.root();
        data.getNode("name").setValue(group.getName());

        Set<NodeModel> nodes = group.getEnduringNodes().values().stream().map(NodeModel::fromNode).collect(Collectors.toCollection(LinkedHashSet::new));
        writeNodes(data, nodes);

        saveFile(StorageLocation.GROUP, group.getName(), data);
    } catch (Exception e) {
        throw reportException(group.getName(), e);
    } finally {
        group.getIoLock().unlock();
    }
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:18,代码来源:ConfigurateDao.java

示例8: writeAttributes

import ninja.leaping.configurate.SimpleConfigurationNode; //导入方法依赖的package包/类
private static ConfigurationNode writeAttributes(NodeModel node) {
    ConfigurationNode attributes = SimpleConfigurationNode.root();
    attributes.getNode("value").setValue(node.getValue());

    if (!node.getServer().equals("global")) {
        attributes.getNode("server").setValue(node.getServer());
    }

    if (!node.getWorld().equals("global")) {
        attributes.getNode("world").setValue(node.getWorld());
    }

    if (node.getExpiry() != 0L) {
        attributes.getNode("expiry").setValue(node.getExpiry());
    }

    if (!node.getContexts().isEmpty()) {
        attributes.getNode("context").setValue(ContextSetConfigurateSerializer.serializeContextSet(node.getContexts()));
    }

    return attributes;
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:23,代码来源:ConfigurateDao.java

示例9: serializeContextSet

import ninja.leaping.configurate.SimpleConfigurationNode; //导入方法依赖的package包/类
public static ConfigurationNode serializeContextSet(ContextSet contextSet) {
    ConfigurationNode data = SimpleConfigurationNode.root();
    Map<String, Collection<String>> map = contextSet.toMultimap().asMap();

    map.forEach((k, v) -> {
        List<String> values = new ArrayList<>(v);
        int size = values.size();

        if (size == 1) {
            data.getNode(k).setValue(values.get(0));
        } else if (size > 1) {
            data.getNode(k).setValue(values);
        }
    });

    return data;
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:18,代码来源:ContextSetConfigurateSerializer.java

示例10: testMoveNode

import ninja.leaping.configurate.SimpleConfigurationNode; //导入方法依赖的package包/类
@Test
public void testMoveNode() {
    final ConfigurationTransformation transform = ConfigurationTransformation.builder()
            .addAction(p("old", "path"), new TransformAction() {
                @Override
                public Object[] visitPath(SingleConfigurationTransformation.NodePath inputPath, ConfigurationNode valueAtPath) {
                    return p("new", "path");
                }
            }).build();

    ConfigurationNode node = SimpleConfigurationNode.root();
    final Object nodeValue = new Object();
    node.getNode("old", "path").setValue(nodeValue);
    transform.apply(node);
    assertTrue(node.getNode("old", "path").isVirtual());
    assertEquals(nodeValue, node.getNode("new", "path").getValue());
}
 
开发者ID:SpongePowered,项目名称:configurate,代码行数:18,代码来源:ConfigurationTransformationTest.java

示例11: serialize

import ninja.leaping.configurate.SimpleConfigurationNode; //导入方法依赖的package包/类
@Override
public void serialize(TypeToken<?> type, Multimap obj, ConfigurationNode node) throws ObjectMappingException {
    TypeToken<?> key = type.resolveType(Multimap.class.getTypeParameters()[0]);
    TypeToken<?> value = type.resolveType(Multimap.class.getTypeParameters()[1]);
    TypeSerializer keySerial = node.getOptions().getSerializers().get(key);
    TypeSerializer valueSerial = node.getOptions().getSerializers().get(value);

    if (keySerial == null) {
        throw new ObjectMappingException("No type serializer available for type " + key);
    }

    if (valueSerial == null) {
        throw new ObjectMappingException("No type serializer available for type " + value);
    }

    node.setValue(ImmutableMap.of());
    for (Object k : obj.keySet()) {
        for (Object v : obj.get(k)) {
            SimpleConfigurationNode keyNode = SimpleConfigurationNode.root();
            keySerial.serialize(key, k, keyNode);
            valueSerial.serialize(value, v, node.getNode(keyNode.getValue()));
        }
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:25,代码来源:MultimapTypeSerializer.java

示例12: testListSerializer

import ninja.leaping.configurate.SimpleConfigurationNode; //导入方法依赖的package包/类
@Test
public void testListSerializer() throws ObjectMappingException {
    final TypeToken<List<String>> stringListType = new TypeToken<List<String>>() {};
    final TypeSerializer<List<String>> stringListSerializer = SERIALIZERS.get(stringListType);
    final ConfigurationNode value = SimpleConfigurationNode.root();
    value.getAppendedNode().setValue("hi");
    value.getAppendedNode().setValue("there");
    value.getAppendedNode().setValue("beautiful");
    value.getAppendedNode().setValue("people");

    assertEquals(Arrays.asList("hi", "there", "beautiful", "people"), stringListSerializer.deserialize(stringListType, value));
    value.setValue(null);

    stringListSerializer.serialize(stringListType, Arrays.asList("hi", "there", "lame", "people"), value);
    assertEquals("hi", value.getNode(0).getString());
    assertEquals("there", value.getNode(1).getString());
    assertEquals("lame", value.getNode(2).getString());
    assertEquals("people", value.getNode(3).getString());
}
 
开发者ID:SpongePowered,项目名称:configurate,代码行数:20,代码来源:TypeSerializersTest.java

示例13: testMapSerializer

import ninja.leaping.configurate.SimpleConfigurationNode; //导入方法依赖的package包/类
@Test
public void testMapSerializer() throws ObjectMappingException {
    final TypeToken<Map<String, Integer>> mapStringIntType = new TypeToken<Map<String, Integer>>() {};
    final TypeSerializer<Map<String, Integer>> mapStringIntSerializer =
            SERIALIZERS.get(mapStringIntType);

    final ConfigurationNode value = SimpleConfigurationNode.root();
    value.getNode("fish").setValue(5);
    value.getNode("bugs").setValue("124880");
    value.getNode("time").setValue("-1");

    final Map<String, Integer> expectedValues = ImmutableMap.of("fish", 5, "bugs", 124880, "time", -1);

    assertEquals(expectedValues, mapStringIntSerializer.deserialize(mapStringIntType, value));

    value.setValue(null);

    mapStringIntSerializer.serialize(mapStringIntType, expectedValues, value);
    assertEquals(5, value.getNode("fish").getInt());
    assertEquals(124880, value.getNode("bugs").getInt());
    assertEquals(-1, value.getNode("time").getInt());
}
 
开发者ID:SpongePowered,项目名称:configurate,代码行数:23,代码来源:TypeSerializersTest.java

示例14: testMoveToBase

import ninja.leaping.configurate.SimpleConfigurationNode; //导入方法依赖的package包/类
@Test
public void testMoveToBase() {
    final ConfigurationTransformation transform = ConfigurationTransformation.builder()
            .addAction(p("sub"), new TransformAction() {
                @Override
                public Object[] visitPath(SingleConfigurationTransformation.NodePath inputPath, ConfigurationNode valueAtPath) {
                    return new Object[0];
                }
            }).build();

    ConfigurationNode node = SimpleConfigurationNode.root();
    node.getNode("sub", "key").setValue("value");
    node.getNode("at-parent").setValue("until-change");
    transform.apply(node);
    assertEquals("value", node.getNode("key").getValue());
    assertEquals(null, node.getNode("at-parent").getValue());
}
 
开发者ID:SpongePowered,项目名称:configurate,代码行数:18,代码来源:ConfigurationTransformationTest.java

示例15: testMapSerializerRemovesDeletedKeys

import ninja.leaping.configurate.SimpleConfigurationNode; //导入方法依赖的package包/类
@Test
public void testMapSerializerRemovesDeletedKeys() throws ObjectMappingException {
    final TypeToken<Map<String, Integer>> mapStringIntType = new TypeToken<Map<String, Integer>>() {};
    final TypeSerializer<Map<String, Integer>> mapStringIntSerializer = SERIALIZERS.get(mapStringIntType);

    final ConfigurationNode value = SimpleConfigurationNode.root();
    value.getNode("fish").setValue(5);
    value.getNode("bugs").setValue("124880");
    value.getNode("time").setValue("-1");

    @SuppressWarnings("unchecked")
    final Map<String, Integer> deserialized = mapStringIntSerializer.deserialize(mapStringIntType, value);
    deserialized.remove("fish");

    mapStringIntSerializer.serialize(mapStringIntType, deserialized, value);
    assertTrue(value.getNode("fish").isVirtual());
    assertFalse(value.getNode("bugs").isVirtual());
}
 
开发者ID:SpongePowered,项目名称:configurate,代码行数:19,代码来源:TypeSerializersTest.java


注:本文中的ninja.leaping.configurate.SimpleConfigurationNode.root方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。