当前位置: 首页>>代码示例>>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;未经允许,请勿转载。