當前位置: 首頁>>代碼示例>>Java>>正文


Java CommentedConfigurationNode類代碼示例

本文整理匯總了Java中ninja.leaping.configurate.commented.CommentedConfigurationNode的典型用法代碼示例。如果您正苦於以下問題:Java CommentedConfigurationNode類的具體用法?Java CommentedConfigurationNode怎麽用?Java CommentedConfigurationNode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CommentedConfigurationNode類屬於ninja.leaping.configurate.commented包,在下文中一共展示了CommentedConfigurationNode類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: Config

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //導入依賴的package包/類
public Config(String name, boolean auto_save) {
    this.name = name;
    try {
        file = new File(GWMCrates.getInstance().getConfigDirectory(), name);
        loader = HoconConfigurationLoader.builder().setFile(file).build();
        node = loader.load();
        if (!file.exists()) {
            file.createNewFile();
            URL defaultsURL = GWMCrates.class.getResource("/" + name);
            ConfigurationLoader<CommentedConfigurationNode> defaultsLoader =
                    HoconConfigurationLoader.builder().setURL(defaultsURL).build();
            ConfigurationNode defaultsNode = defaultsLoader.load();
            node.mergeValuesFrom(defaultsNode);
            Sponge.getScheduler().createTaskBuilder().delayTicks(1).execute(this::save).
                    submit(GWMCrates.getInstance());
        }
        if (auto_save) {
            Sponge.getScheduler().createTaskBuilder().async().execute(this::save).
                    interval(AUTO_SAVE_INTERVAL, TimeUnit.SECONDS).submit(GWMCrates.getInstance());
        }
    } catch (Exception e) {
        GWMCrates.getInstance().getLogger().warn("Failed initialize config \"" + getName() + "\"!", e);
    }
}
 
開發者ID:GreWeMa,項目名稱:gwm_Crates,代碼行數:25,代碼來源:Config.java

示例2: addPlayer

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //導入依賴的package包/類
public static void addPlayer(UUID playerUUID)
{
    Path playerFile = Paths.get(EagleFactions.getEagleFactions ().getConfigDir().resolve("players") +  "/" + playerUUID.toString() + ".conf");

    try
    {
        Files.createFile(playerFile);

        ConfigurationLoader<CommentedConfigurationNode> configLoader = HoconConfigurationLoader.builder().setPath(playerFile).build();

        CommentedConfigurationNode playerNode = configLoader.load();

        playerNode.getNode("power").setValue(MainLogic.getStartingPower());
        playerNode.getNode("maxpower").setValue(MainLogic.getGlobalMaxPower());
        configLoader.save(playerNode);
    }
    catch (Exception exception)
    {
        exception.printStackTrace();
    }
}
 
開發者ID:Aquerr,項目名稱:EagleFactions,代碼行數:22,代碼來源:PowerService.java

示例3: getPlayerMaxPower

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //導入依賴的package包/類
public static BigDecimal getPlayerMaxPower(UUID playerUUID)
{
    Path playerFile = Paths.get(EagleFactions.getEagleFactions ().getConfigDir().resolve("players") +  "/" + playerUUID.toString() + ".conf");

    try
    {
        ConfigurationLoader<CommentedConfigurationNode> configLoader = HoconConfigurationLoader.builder().setPath(playerFile).build();

        CommentedConfigurationNode playerNode = configLoader.load();

        BigDecimal playerMaxPower =  new BigDecimal(playerNode.getNode("maxpower").getString());

        return playerMaxPower;
    }
    catch (Exception exception)
    {
        exception.printStackTrace();
    }

    return BigDecimal.ZERO;
}
 
開發者ID:Aquerr,項目名稱:EagleFactions,代碼行數:22,代碼來源:PowerService.java

示例4: setPower

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //導入依賴的package包/類
public static void setPower(UUID playerUUID, BigDecimal power)
{
    Path playerFile = Paths.get(EagleFactions.getEagleFactions ().getConfigDir().resolve("players") +  "/" + playerUUID.toString() + ".conf");

    try
    {
        ConfigurationLoader<CommentedConfigurationNode> configLoader = HoconConfigurationLoader.builder().setPath(playerFile).build();

        CommentedConfigurationNode playerNode = configLoader.load();

        playerNode.getNode("power").setValue(power);
        configLoader.save(playerNode);
    }
    catch (Exception exception)
    {
        exception.printStackTrace();
    }
}
 
開發者ID:Aquerr,項目名稱:EagleFactions,代碼行數:19,代碼來源:PowerService.java

示例5: setMaxPower

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //導入依賴的package包/類
public static void setMaxPower(UUID playerUUID, BigDecimal power)
{
    Path playerFile = Paths.get(EagleFactions.getEagleFactions ().getConfigDir().resolve("players") +  "/" + playerUUID.toString() + ".conf");

    try
    {
        ConfigurationLoader<CommentedConfigurationNode> configLoader = HoconConfigurationLoader.builder().setPath(playerFile).build();

        CommentedConfigurationNode playerNode = configLoader.load();

        playerNode.getNode("maxpower").setValue(power);
        configLoader.save(playerNode);
    }
    catch (Exception exception)
    {
        exception.printStackTrace();
    }
}
 
開發者ID:Aquerr,項目名稱:EagleFactions,代碼行數:19,代碼來源:PowerService.java

示例6: setPlayerChunkPosition

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //導入依賴的package包/類
public static void setPlayerChunkPosition(UUID playerUUID, Vector3i chunk)
{
    Path playerFile = Paths.get(EagleFactions.getEagleFactions ().getConfigDir().resolve("players") +  "/" + playerUUID.toString() + ".conf");

    try
    {
        ConfigurationLoader<CommentedConfigurationNode> configLoader = HoconConfigurationLoader.builder().setPath(playerFile).build();

        CommentedConfigurationNode playerNode = configLoader.load();

        if(chunk != null)
        {
            playerNode.getNode("chunkPosition").setValue(chunk.toString());
        }
        else
        {
            playerNode.getNode("chunkPosition").setValue(null);
        }

        configLoader.save(playerNode);
    }
    catch (Exception exception)
    {
        exception.printStackTrace();
    }
}
 
開發者ID:Aquerr,項目名稱:EagleFactions,代碼行數:27,代碼來源:PlayerService.java

示例7: init

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //導入依賴的package包/類
public static ConfigManager init(String configName) {
    ConfigManager configManager = new ConfigManager(configName);
    CommentedConfigurationNode config = configManager.getConfig();

    if (configName.equalsIgnoreCase("config")) {
        // config.conf 配置文件設置
        setDefaultValue(config, "null", "sid");
        setDefaultValue(config, "null", "key");
        setDefaultValue(config, true, "logApi"); //key盡量不要包括下劃線! 否則在配置文件會被加上引號,顯示為 "key"=xxx
        setDefaultValue(config, true, "renewOnJoin");
        setDefaultValue(config, new ArrayList<String>(), "opModifyWhiteList");
        setDefaultValue(config, "點券", "point");
        setDefaultValue(config, "b", "command");
        setDefaultValue(config, "&a[&e點券中心&a] &2", "prefix");
    }
    configManager.save();
    configManagers.put(configName, configManager);
    return configManager;
}
 
開發者ID:txgs888,項目名稱:McrmbCore_Sponge,代碼行數:20,代碼來源:ConfigManager.java

示例8: save

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //導入依賴的package包/類
/** {@inheritDoc} */
@Override
public void save(@NotNull Object object) throws DataHandlingException {
    try {
        String header = getComments(object.getClass(), true);

        CommentedConfigurationNode node = SimpleCommentedConfigurationNode.root(ConfigurationOptions.defaults().setHeader(header));
        Object serialized = SerializableConfig.serialize(object, serializerSet);
        node = node.setValue(serialized);

        if (commentsEnabled) {
            node = addComments(FieldMapper.getFieldMap(object.getClass()), node);
        }

        getLoader().save(node);
    } catch (IOException e) {
        throw new DataHandlingException(e);
    }
}
 
開發者ID:dumptruckman,項目名稱:dtmlibs,代碼行數:20,代碼來源:AbstractDataSource.java

示例9: setInternalValue

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //導入依賴的package包/類
private <T> void setInternalValue(T storageHandler) {
    if (storageHandler instanceof ConfigurationNode) {
        ConfigurationNode node = ((ConfigurationNode) storageHandler).getNode(this.key.get());
        if (this.comment != null && node instanceof CommentedConfigurationNode) {
            ((CommentedConfigurationNode) node).setComment(this.comment);
        }

        if (this.modified) {
            if (this.valueTypeToken != null) {
                try {
                    node.setValue(this.valueTypeToken, this.value);
                } catch (ObjectMappingException e) {
                    e.printStackTrace();
                }
            } else {
                node.setValue(this.value);
            }
            this.modified = false;
        }
    }
}
 
開發者ID:ichorpowered,項目名稱:elderguardian,代碼行數:22,代碼來源:StorageValue.java

示例10: getInternalValue

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //導入依賴的package包/類
private <T> E getInternalValue(T storageHandler) {
    if (storageHandler instanceof ConfigurationNode) {
        ConfigurationNode node = ((ConfigurationNode) storageHandler).getNode(this.key.get());

        if (node.isVirtual()) {
            this.modified = true;
        }

        if (this.comment != null && node instanceof CommentedConfigurationNode) {
            ((CommentedConfigurationNode) node).setComment(this.comment);
        }

        try {
            if (this.valueTypeToken != null) {
                return node.getValue(this.valueTypeToken, this.defaultValue);
            } else {
                return node.getValue(new TypeToken<E>(this.defaultValue.getClass()) {}, this.defaultValue);
            }
        } catch (Exception e) {
            return this.defaultValue;
        }
    }
    return null;
}
 
開發者ID:ichorpowered,項目名稱:elderguardian,代碼行數:25,代碼來源:StorageValue.java

示例11: 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

示例12: 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

示例13: execute

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //導入依賴的package包/類
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    String id = args.<String>getOne("id").get();
    CommentedConfigurationNode ticket = plugin.getTickets().get(id);

    if (ticket.isVirtual()) {
        src.sendMessage(Text.of(RED, "That ticket does not exist!"));
        return CommandResult.success();
    }

    if(!ticket.getNode("completed").getBoolean())
        Sponge.getServer().getPlayer(UUID.fromString(ticket.getNode("player").getString()))
                .ifPresent(player -> player.sendMessage(Text.of(GREEN, "Your ticket has been completed by ",
                        WHITE, src.getName()))
                );

    boolean completed = ticket.getNode("completed").getBoolean();
    ticket.setValue(null);
    src.sendMessage(Text.of(GREEN, completed ? "Ticket deleted." : "Ticket completed & deleted."));

    return CommandResult.success();
}
 
開發者ID:xDotDash,項目名稱:HelpTicketsOld,代碼行數:23,代碼來源:CommandTicketDelete.java

示例14: execute

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //導入依賴的package包/類
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    String id = args.<String>getOne("id").get();
    CommentedConfigurationNode ticket = plugin.getTickets().get(id);

    if (ticket.isVirtual()) {
        src.sendMessage(Text.of(TextColors.RED, "That ticket does not exist!"));
        return CommandResult.success();
    }

    if(ticket.getNode("completed").getBoolean()) {
        src.sendMessage(Text.of(TextColors.RED, "That ticket is already completed."));
        return CommandResult.success();
    } else {
        Sponge.getServer().getPlayer(UUID.fromString(ticket.getNode("player").getString()))
                .ifPresent(player -> player.sendMessage(Text.of(TextColors.GREEN, "Your ticket has been completed by ",
                        TextColors.WHITE, src.getName()))
                );
    }

    ticket.getNode("completed").setValue(true);
    plugin.getTickets().save();

    src.sendMessage(Text.of(TextColors.GREEN, "Ticket completed."));
    return CommandResult.success();
}
 
開發者ID:xDotDash,項目名稱:HelpTicketsOld,代碼行數:27,代碼來源:CommandTicketComplete.java

示例15: init

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //導入依賴的package包/類
public static ConfigManager init(String configName) {
	ConfigManager configManager = new ConfigManager(configName);
	CommentedConfigurationNode config = configManager.getConfig();
	
	if(configName.equalsIgnoreCase("config")) {
		if (config.getNode("mode").isVirtual()) {
			config.getNode("mode").setValue("default").setComment("default or advanced");
		}
	}
	
	configManager.save();
	
	configManagers.put(configName, configManager);
	
	return configManager;
}
 
開發者ID:trentech,項目名稱:SimpleTagsNations,代碼行數:17,代碼來源:ConfigManager.java


注:本文中的ninja.leaping.configurate.commented.CommentedConfigurationNode類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。