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


Java HoconConfigurationLoader.load方法代码示例

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


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

示例1: load

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //导入方法依赖的package包/类
public static HoconConfigFile load(@Nonnull final Path path,
                                   @Nonnull final String resource,
                                   final boolean overwrite) throws IOException {
    if (overwrite) {
        Files.deleteIfExists(path);
    }

    if (!Files.exists(path)) {
        Files.createDirectories(path.getParent());

        if (!resource.isEmpty()) {
            Files.copy(HoconConfigFile.class.getResourceAsStream(resource), path);
        }
    }

    final HoconConfigurationLoader fileLoader = HoconConfigurationLoader.builder().setPath(path).build();

    return new HoconConfigFile(path, fileLoader, fileLoader.load());
}
 
开发者ID:FerusTech,项目名称:Amicus,代码行数:20,代码来源:HoconConfigFile.java

示例2: loadData

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

	List<Kit> kitsList = rootNode.getNode("Kits").getList(TypeToken.of(Kit.class));
	this.kits = new HashMap<String, Kit>();
	for (Kit kit : kitsList) {
		this.kits.put(kit.getName().toLowerCase(), kit);
	}

	List<PlayerData> playersDataList = rootNode.getNode("PlayersData").getList(TypeToken.of(PlayerData.class));
	this.playersData = new HashMap<UUID, PlayerData>();
	for (PlayerData pd : playersDataList) {
		this.playersData.put(pd.getPlayerUUID(), pd);
	}
}
 
开发者ID:KaiKikuchi,项目名称:BetterKits,代码行数:17,代码来源:BetterKits.java

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

示例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:codeHusky,项目名称:HuskyUI-Plugin,代码行数:41,代码来源:Metrics.java

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

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

示例7: readFrom

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //导入方法依赖的package包/类
@Override
public DataContainer readFrom(InputStream input) throws InvalidDataFormatException, IOException {
    final HoconConfigurationLoader loader = HoconConfigurationLoader.builder()
            .setSource(() -> new BufferedReader(new InputStreamReader(input)))
            .build();
    final ConfigurationNode node = loader.load();
    return ConfigurateTranslator.instance().translate(node);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:9,代码来源:HoconDataFormat.java

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

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

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

示例11: loadDefaultConfiguration

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //导入方法依赖的package包/类
ConfigurationNode loadDefaultConfiguration() throws IOException {
    URL defaultConfig = PlotMe_Sponge.class.getResource("default.conf");
    HoconConfigurationLoader loader = HoconConfigurationLoader.builder().setURL(defaultConfig).build();
    return loader.load();

}
 
开发者ID:WorldCretornica,项目名称:PlotMe-Core,代码行数:7,代码来源:PlotMe_Sponge.java


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