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


Java HoconConfigurationLoader.save方法代碼示例

本文整理匯總了Java中ninja.leaping.configurate.hocon.HoconConfigurationLoader.save方法的典型用法代碼示例。如果您正苦於以下問題:Java HoconConfigurationLoader.save方法的具體用法?Java HoconConfigurationLoader.save怎麽用?Java HoconConfigurationLoader.save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ninja.leaping.configurate.hocon.HoconConfigurationLoader的用法示例。


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

示例1: load

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //導入方法依賴的package包/類
public static void load(BetterKits instance) {
	//load defaults
	try {
		URL defaultsInJarURL = CommonUtils.class.getResource("messages.yml");
		YAMLConfigurationLoader defaultsLoader = YAMLConfigurationLoader.builder().setURL(defaultsInJarURL).build();
		ConfigurationNode defaults = defaultsLoader.load();
		
		HoconConfigurationLoader loader = HoconConfigurationLoader.builder().setPath(instance.getConfigDir().resolve("messages.conf")).build();
		ConfigurationNode root = loader.load();
		root.mergeValuesFrom(defaults);
		loader.save(root);
		
		for (Entry<Object, ? extends ConfigurationNode> entry : root.getChildrenMap().entrySet()) {
			messages.put(entry.getKey().toString(), entry.getValue().getString());
		}
	} catch (IOException e) {
		throw new RuntimeException(e);
	}
}
 
開發者ID:KaiKikuchi,項目名稱:BetterKits,代碼行數:20,代碼來源:Messages.java

示例2: loadConfig

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //導入方法依賴的package包/類
/**
 * Loads the bStats configuration.
 *
 * @throws IOException If something did not work :(
 */
private void loadConfig() throws IOException {
    Path configPath = configDir.resolve("bStats");
    configPath.toFile().mkdirs();
    File configFile = new File(configPath.toFile(), "config.conf");
    HoconConfigurationLoader configurationLoader = HoconConfigurationLoader.builder().setFile(configFile).build();
    CommentedConfigurationNode node;
    if (!configFile.exists()) {
        configFile.createNewFile();
        node = configurationLoader.load();

        // Add default values
        node.getNode("enabled").setValue(true);
        // Every server gets it's unique random id.
        node.getNode("serverUuid").setValue(UUID.randomUUID().toString());
        // Should failed request be logged?
        node.getNode("logFailedRequests").setValue(false);

        // Add information about bStats
        node.getNode("enabled").setComment(
                "bStats collects some data for plugin authors like how many servers are using their plugins.\n" +
                        "To honor their work, you should not disable it.\n" +
                        "This has nearly no effect on the server performance!\n" +
                        "Check out https://bStats.org/ to learn more :)"
        );

        configurationLoader.save(node);
    } else {
        node = configurationLoader.load();
    }

    // Load configuration
    enabled = node.getNode("enabled").getBoolean(true);
    serverUUID = node.getNode("serverUuid").getString();
    logFailedRequests = node.getNode("logFailedRequests").getBoolean(false);
}
 
開發者ID:codeHusky,項目名稱:HuskyUI-Plugin,代碼行數:41,代碼來源:Metrics.java

示例3: serializeToJson

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //導入方法依賴的package包/類
public static String serializeToJson(DataContainer container) throws IOException {
    try (StringWriter writer = new StringWriter()) {
        HoconConfigurationLoader loader = HoconConfigurationLoader.builder().setSink(() -> new BufferedWriter(writer)).build();
        loader.save(DataTranslators.CONFIGURATION_NODE.translate(container));
        return Base64.getEncoder().encodeToString(writer.toString().getBytes(Charsets.UTF_8));
    } catch (Exception ex) {
        ex.printStackTrace();
        return null;
    }
}
 
開發者ID:poqdavid,項目名稱:VirtualTool,代碼行數:11,代碼來源:Tools.java

示例4: loadConfig

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //導入方法依賴的package包/類
/**
 * Loads the bStats configuration.
 *
 * @throws IOException
 *             If something did not work :(
 */
private void loadConfig() throws IOException {
	Path configPath = configDir.resolve("bStats");
	configPath.toFile().mkdirs();
	File configFile = new File(configPath.toFile(), "config.conf");
	HoconConfigurationLoader configurationLoader = HoconConfigurationLoader.builder().setFile(configFile).build();
	CommentedConfigurationNode node;
	if (!configFile.exists()) {
		configFile.createNewFile();
		node = configurationLoader.load();

		// Add default values
		node.getNode("enabled").setValue(true);
		// Every server gets it's unique random id.
		node.getNode("serverUuid").setValue(UUID.randomUUID().toString());
		// Should failed request be logged?
		node.getNode("logFailedRequests").setValue(false);

		// Add information about bStats
		node.getNode("enabled").setComment(
				"bStats collects some data for plugin authors like how many servers are using their plugins.\n"
						+ "To honor their work, you should not disable it.\n"
						+ "This has nearly no effect on the server performance!\n"
						+ "Check out https://bStats.org/ to learn more :)");

		configurationLoader.save(node);
	} else {
		node = configurationLoader.load();
	}

	// Load configuration
	enabled = node.getNode("enabled").getBoolean(true);
	serverUUID = node.getNode("serverUuid").getString();
	logFailedRequests = node.getNode("logFailedRequests").getBoolean(false);
}
 
開發者ID:rojo8399,項目名稱:PlaceholderAPI,代碼行數:41,代碼來源:Metrics.java

示例5: saveData

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //導入方法依賴的package包/類
synchronized public void saveData() throws IOException, ObjectMappingException {
	HoconConfigurationLoader loader = getDataLoader();
	ConfigurationNode rootNode = loader.load();

	rootNode.getNode("Kits").setValue(KitSerializer.token, new ArrayList<Kit>(this.kits.values()));
	rootNode.getNode("PlayersData").setValue(PlayerDataSerializer.token, new ArrayList<PlayerData>(this.playersData.values()));

	loader.save(rootNode);
}
 
開發者ID:KaiKikuchi,項目名稱:BetterKits,代碼行數:10,代碼來源:BetterKits.java

示例6: writeTo

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //導入方法依賴的package包/類
private static void writeTo(Callable<BufferedWriter> sink, DataView data) throws IOException {
    final HoconConfigurationLoader loader = HoconConfigurationLoader.builder()
            .setHeaderMode(HeaderMode.NONE)
            .setSink(sink)
            .build();
    final ConfigurationNode node = ConfigurateTranslator.instance().translate(data);
    loader.save(node);
}
 
開發者ID:LanternPowered,項目名稱:LanternServer,代碼行數:9,代碼來源:HoconDataFormat.java

示例7: loadConfig

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //導入方法依賴的package包/類
/**
 * Loads the bStats configuration.
 *
 * @throws IOException If something did not work :(
 */
private void loadConfig() throws IOException {
    Path configPath = configDir.resolve("bStats");
    configPath.toFile().mkdirs();
    File configFile = new File(configPath.toFile(), "config.conf");
    HoconConfigurationLoader configurationLoader = HoconConfigurationLoader.builder().setFile(configFile).build();
    CommentedConfigurationNode node;
    if (!configFile.exists()) {
        configFile.createNewFile();
        node = configurationLoader.load();

        // Add default values
        node.getNode("enabled").setValue(true);
        // Every server gets it's unique random id.
        node.getNode("serverUuid").setValue(UUID.randomUUID().toString());
        // Should failed request be logged?
        node.getNode("logFailedRequests").setValue(false);

        // Add information about bStats
        node.getNode("enabled").setComment(
                "bStats collects some data for plugin authors like how many servers are using their plugins.\n" +
                        "To honor their work, you should not disable it.\n" +
                        "This has nearly no effect on the server performance!\n" +
                        "Check out https://bStats.org/ to learn more :)"
                );

        configurationLoader.save(node);
    } else {
        node = configurationLoader.load();
    }

    // Load configuration
    enabled = node.getNode("enabled").getBoolean(true);
    serverUUID = node.getNode("serverUuid").getString();
    logFailedRequests = node.getNode("logFailedRequests").getBoolean(false);
}
 
開發者ID:Flibio,項目名稱:JobsLite,代碼行數:41,代碼來源:Metrics.java

示例8: loadWorldContext

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //導入方法依賴的package包/類
private WorldFallbackContext loadWorldContext(World world) throws IOException
{
    Path worldPath = configDir.resolve("world");
    Path configPath = worldPath.resolve(world.getName().replaceAll("[^a-zA-Z0-9-]", "_") + ".conf");
    if(!Files.isDirectory(worldPath))
        Files.createDirectory(worldPath);

    HoconConfigurationLoader loader = HoconConfigurationLoader.builder().setPath(configPath).build();
    CommentedConfigurationNode main = loader.load(
            ConfigurationOptions.defaults()
                    .setShouldCopyDefaults(true)
                    .setHeader("Default wild permissions on the world " + world.getName() + " with dimension " +
                            world.getDimension().getName() + " and unique id: " + world.getUniqueId())
    );

    CommentedConfigurationNode wildPerms = main.getNode("wild-permissions");
    wildPerms.setComment(
            "The permissions that affects unclaimed chunks on this world. Null values are inherited from the default-world-permissions declared on the default-permissions.conf file"
    );

    CommentedConfigurationNode defaultPerms = main.getNode("fallback-permissions");
    defaultPerms.setComment(
            "The fallback permissions that will be used when a claimed chunk or a zone does not define the permission, this will take priority over the default defined on the defailt-permission.conf file"
    );

    WorldFallbackContext worldContext = new WorldFallbackContext(world.getUniqueId());
    loadWorldConfig(worldContext, defaultPerms, false);
    loadWorldConfig(worldContext.getWilderness(), wildPerms, true);

    try
    {
        loader.save(main);
    }
    catch(Exception e)
    {
        logger.error("Failed to save the world config file for " + world.getName() + " DIM:" +
                world.getDimension().getName(), e);
    }

    return worldContext;
}
 
開發者ID:GameModsBR,項目名稱:MyChunks,代碼行數:42,代碼來源:MyChunks.java

示例9: load

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //導入方法依賴的package包/類
public ItemCategoryManager load() {
    categoryToItemIds.clear();

    CustomItemLibrary plugin = CustomItemLibrary.getInstance();
    Path path = plugin.getConfigPath();
    ConfigurationOptions options = plugin.getDefaultConfigurationOptions();
    HoconConfigurationLoader loader = HoconConfigurationLoader.builder()
            .setDefaultOptions(options).setPath(path).build();

    try {
        CommentedConfigurationNode root = loader.load();
        CommentedConfigurationNode nodeCategories = root.getNode(NODE_ITEM_CATEGORIES);

        nodeCategories.setComment("Categories are used to determine the mining speed of blocks. Here you can add items from mods.");

        if(nodeCategories.isVirtual()) {
            defaultCategory(nodeCategories, "shovel", ItemTypes.WOODEN_SHOVEL, ItemTypes.STONE_SHOVEL,
                    ItemTypes.IRON_SHOVEL, ItemTypes.GOLDEN_SHOVEL, ItemTypes.DIAMOND_SHOVEL);
            defaultCategory(nodeCategories, "hoe", ItemTypes.WOODEN_HOE, ItemTypes.STONE_HOE,
                    ItemTypes.IRON_HOE, ItemTypes.GOLDEN_HOE, ItemTypes.DIAMOND_HOE);
            defaultCategory(nodeCategories, "pickaxe", ItemTypes.WOODEN_PICKAXE, ItemTypes.STONE_PICKAXE,
                    ItemTypes.IRON_PICKAXE, ItemTypes.GOLDEN_PICKAXE, ItemTypes.DIAMOND_PICKAXE);
            defaultCategory(nodeCategories, "axe", ItemTypes.WOODEN_AXE, ItemTypes.STONE_AXE,
                    ItemTypes.IRON_AXE, ItemTypes.GOLDEN_AXE, ItemTypes.DIAMOND_AXE);
            defaultCategory(nodeCategories, "shears", ItemTypes.SHEARS);
        }

        nodeCategories.getChildrenMap().forEach((rawCategory, rawItemIds) -> {
            String category = Objects.toString(rawCategory);
            List<String> itemIds = rawItemIds.getList(Objects::toString);
            Set<Identifier> identifiers = itemIds.stream().map(itemId -> {
                if(Identifier.isParseable(itemId))
                    return Identifier.parse(itemId);
                else
                    return new Identifier("minecraft", itemId);
            }).collect(Collectors.toSet());

            categoryToItemIds.putAll(category, identifiers);
        });

        loader.save(root);
    } catch (IOException e) {
        e.printStackTrace();
    }

    return this;
}
 
開發者ID:Limeth,項目名稱:CustomItemLibrary,代碼行數:48,代碼來源:ItemCategoryManager.java


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