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


Java CommentedConfigurationNode.setValue方法代码示例

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


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

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

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

示例3: registerWorld

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public void registerWorld(String world) {
	boolean save = false;
	
	for (String collection : this.getCollections()) {
		if (!this.getWorld(collection, world).isPresent()) {
			CommentedConfigurationNode config = this.get("collections." + collection).getNode(EPConfig.DEFAULT);
			
			try {
				List<String> worlds = new ArrayList<String>();
				worlds.addAll(config.getList(TypeToken.of(String.class)));
				worlds.add(world);
				config.setValue(worlds);
				
				save = true;
			} catch (ObjectMappingException e) {}
		}
	}
	
	if (save) this.save(true);
}
 
开发者ID:EverCraft,项目名称:EverPermissions,代码行数:21,代码来源:EPConfig.java

示例4: mergeConfigs

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
/**
 * Merge default values into a existing config, adding only the values that don't exist yet.
 * @param node The node that receives any missing default values
 * @param def The default configuration
 * @param restoreDefaults True if missing values in the config marked with _DEFAULT_ in the comment of the default config should be added.
 */
public static void mergeConfigs(CommentedConfigurationNode node, CommentedConfigurationNode def, boolean restoreDefaults) {
    if (def.getComment().isPresent() && def.getComment().get().contains("_EXAMPLE_") && !restoreDefaults) {
        return;
    }

    if (node.isVirtual()) {
        node.setValue(def);
        return;
    }

    if (!def.hasMapChildren()) {
        return;
    }

    Map<Object, ? extends CommentedConfigurationNode> map = def.getChildrenMap();
    for (Map.Entry<Object, ? extends CommentedConfigurationNode> entry : map.entrySet()) {
        CommentedConfigurationNode subNode = node.getNode(entry.getKey());
        mergeConfigs(subNode, entry.getValue(), restoreDefaults);
    }
}
 
开发者ID:Valandur,项目名称:Web-API,代码行数:27,代码来源:Util.java

示例5: loadConfig

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public static void loadConfig() {
    try {
        config = confLoader.load();
    } catch (IOException e) {
        logger.error("Error while loading config", e);
        config = confLoader.createEmptyNode();
    }
    CommentedConfigurationNode playerSettings = config.getNode("player-settings");
    if (playerSettings.isVirtual()) {
        playerSettings.setValue(Collections.emptyMap());
    }
}
 
开发者ID:simon816,项目名称:ChatUI,代码行数:13,代码来源:Config.java

示例6: ensureString

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

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

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


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