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


Java CommentedConfigurationNode.getValue方法代码示例

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


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

示例1: loadConfig

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public boolean loadConfig() {
    try {
        File file = new File(plugin.getConfigDir(), "catclearlag.conf");
        if (!file.exists()) {
            file.createNewFile();
        }
        ConfigurationLoader<CommentedConfigurationNode> loader = HoconConfigurationLoader.builder().setFile(file).build();
        CommentedConfigurationNode config = loader.load(ConfigurationOptions.defaults().setObjectMapperFactory(plugin.getFactory()).setShouldCopyDefaults(true));
        cclConfig = config.getValue(TypeToken.of(CCLConfig.class), new CCLConfig());
        loader.save(config);
        return true;
    } catch (Exception e) {
        plugin.getLogger().error("Could not load config.", e);
        return false;
    }
}
 
开发者ID:Time6628,项目名称:CatClearLag,代码行数:17,代码来源:ConfigLoader.java

示例2: loadMessages

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public boolean loadMessages() {
    try {
        File file = new File(plugin.getConfigDir(), "messages.conf");
        if (!file.exists()) {
            file.createNewFile();
        }
        ConfigurationLoader<CommentedConfigurationNode> loader = HoconConfigurationLoader.builder().setFile(file).build();
        CommentedConfigurationNode config = loader.load(ConfigurationOptions.defaults().setObjectMapperFactory(plugin.getFactory()).setShouldCopyDefaults(true));
        messagesConfig = config.getValue(TypeToken.of(MessagesConfig.class), new MessagesConfig());
        loader.save(config);
        return true;
    } catch (Exception e) {
        plugin.getLogger().error("Could not load config.", e);
        return false;
    }
}
 
开发者ID:Time6628,项目名称:CatClearLag,代码行数:17,代码来源:ConfigLoader.java

示例3: scanDir

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
private Map<String, VirtualChestInventory> scanDir(File file)
{
    Map<String, VirtualChestInventory> newInventories = new LinkedHashMap<>();
    if (file.isDirectory() || file.mkdirs())
    {
        for (File f : Optional.ofNullable(file.listFiles()).orElse(new File[0]))
        {
            String fileName = f.getName();
            if (fileName.endsWith(".conf"))
            {
                String chestName = fileName.substring(0, fileName.lastIndexOf(".conf"));
                try
                {
                    HoconConfigurationLoader loader = HoconConfigurationLoader.builder().setFile(f).build();
                    CommentedConfigurationNode menuRoot = loader.load().getNode(VirtualChestPlugin.PLUGIN_ID);
                    VirtualChestInventory inventory = menuRoot.getValue(TypeToken.of(VirtualChestInventory.class));
                    newInventories.put(chestName, Objects.requireNonNull(inventory));
                }
                catch (Exception e)
                {
                    this.logger.warn("Find error when reading a file (" + f.getAbsolutePath() +
                            "). Don't worry, we will skip this one and continue to read others", e);
                }
            }
        }
    }
    return newInventories;
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:29,代码来源:VirtualChestInventoryDispatcher.java

示例4: saveConfig

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public void saveConfig(CCLConfig newConfig) {
    try {
        File file = new File(plugin.getConfigDir(), "catclearlag.conf");
        if (!file.exists()) {
            file.createNewFile();
        }
        ConfigurationLoader<CommentedConfigurationNode> loader = HoconConfigurationLoader.builder().setFile(file).build();
        CommentedConfigurationNode config = loader.load(ConfigurationOptions.defaults().setObjectMapperFactory(plugin.getFactory()).setShouldCopyDefaults(true));
        config.getValue(TypeToken.of(CCLConfig.class), newConfig);
        loader.save(config);
    } catch (Exception e) {
        plugin.getLogger().error("Could not load config.", e);
    }
}
 
开发者ID:Time6628,项目名称:CatClearLag,代码行数:15,代码来源:ConfigLoader.java

示例5: ensurePositiveNumber

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public static void ensurePositiveNumber(CommentedConfigurationNode node, Number def)
{
	if (!(node.getValue() instanceof Number) || node.getDouble(-1) < 0)
	{
		node.setValue(def);
	}
}
 
开发者ID:Arckenver,项目名称:Nations,代码行数:8,代码来源:ConfigHandler.java

示例6: ensureBoolean

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public static void ensureBoolean(CommentedConfigurationNode node, boolean def)
{
	if (!(node.getValue() instanceof Boolean))
	{
		node.setValue(def);
	}
}
 
开发者ID:Arckenver,项目名称:Nations,代码行数:8,代码来源:ConfigHandler.java

示例7: addDefault

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public void addDefault(final String paths, final Object value, final String comment){
	CommentedConfigurationNode node = get(paths);    	
	if (node.getValue() == null){
		node.setComment(comment).setValue(value);
		this.setModified(true);
	}
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:8,代码来源:EConfig.java

示例8: addComment

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public void addComment(final String paths, final String... comments){
	CommentedConfigurationNode node = get(paths);
	if (node.getValue() == null){
		node.setComment(String.join("\n", comments));
		this.setModified(true);
	}
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:8,代码来源:EConfig.java

示例9: loadWorldConfig

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
private void loadWorldConfig(@Nullable PublicContext context, CommentedConfigurationNode parentNode, boolean wild)
{
    for(Permission permission : values())
    {
        CommentedConfigurationNode node = parentNode.getNode(permission.toString().toLowerCase());
        boolean def = wild? permission.isAllowedByDefaultOnTheWild() : permission.isAllowedByDefault();
        node.setComment(permission.getDescription() + " [Default:" + def + "]");

        if(context != null)
        {
            if(!node.isVirtual())
            {
                Object value = node.getValue();
                if(value instanceof Boolean)
                {
                    context.setPublicPermission(permission, Tristate.fromBoolean((boolean) value));
                    context.setModified(false);
                }
            }
        }
        else
        {
            boolean val = node.getBoolean(def);
            if (val != def)
            {
                if (wild)
                    permission.setAllowedByDefaultOnTheWild(val);
                else
                    permission.setAllowedByDefault(val);
                permission.setModified(false);
            }
        }
    }
}
 
开发者ID:GameModsBR,项目名称:MyChunks,代码行数:35,代码来源:MyChunks.java

示例10: loadConfig

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
private void loadConfig(){

        try {
            CommentedConfigurationNode node = loader.load(ConfigurationOptions.defaults().setObjectMapperFactory(factory).setShouldCopyDefaults(true));
            config = node.getValue(TypeToken.of(NoXrayConfig.class), new NoXrayConfig());
            loader.save(node);
        } catch (IOException | ObjectMappingException e) {
            e.printStackTrace();
        }
    }
 
开发者ID:thomas15v,项目名称:NoXray,代码行数:11,代码来源:NoXrayPlugin.java

示例11: NucleusMixinConfig

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
private NucleusMixinConfig() {
    Config config;
    try {
        Path path = Paths.get("config", "nucleus", "mixins.conf");
        ConfigurationLoader<CommentedConfigurationNode> ccn = HoconConfigurationLoader.builder().setPath(path).build();
        CommentedConfigurationNode node = ccn.load();
        node.mergeValuesFrom(SimpleCommentedConfigurationNode.root().setValue(TypeToken.of(Config.class), new Config()));
        ccn.save(node);
        config = node.getValue(TypeToken.of(Config.class));
    } catch (Exception e) {
        config = new Config();
    }

    this.config = config;
}
 
开发者ID:NucleusPowered,项目名称:NucleusMixins,代码行数:16,代码来源:NucleusMixinConfig.java


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