當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。