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