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


Java HoconConfigurationLoader类代码示例

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


HoconConfigurationLoader类属于ninja.leaping.configurate.hocon包,在下文中一共展示了HoconConfigurationLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Config

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //导入依赖的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

示例3: addPlayer

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //导入依赖的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

示例4: getPlayerMaxPower

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //导入依赖的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

示例5: setPower

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //导入依赖的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

示例6: setMaxPower

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //导入依赖的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

示例7: setPlayerChunkPosition

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //导入依赖的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

示例8: load

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //导入依赖的package包/类
/**
 * Loads the given configuration file.
 */
public static void load(Path path) {
    System.out.println("Loading config from " + path.toString());
    try {
        Files.createDirectories(path.getParent());
        if (Files.notExists(path)) {
            Files.createFile(path);
        }

        loader = HoconConfigurationLoader.builder().setPath(path).build();
        configMapper = ObjectMapper.forClass(ObfConfig.class).bindToNew();
        node = loader.load(ConfigurationOptions.defaults().setHeader(HEADER));
        config = configMapper.populate(node);
        configMapper.serialize(node);
        loader.save(node);
    } catch (Exception e) {
        System.err.println("Error loading configuration:");
        e.printStackTrace();
    }
}
 
开发者ID:Despector,项目名称:ObfuscationMapper,代码行数:23,代码来源:ObfConfigManager.java

示例9: load

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //导入依赖的package包/类
/**
 * Loads the given configuration file.
 */
public static void load(Path path) {
    System.out.println("Loading config from " + path.toString());
    try {
        Files.createDirectories(path.getParent());
        if (Files.notExists(path)) {
            Files.createFile(path);
        }

        loader = HoconConfigurationLoader.builder().setPath(path).build();
        configMapper = ObjectMapper.forClass(ConfigBase.class).bindToNew();
        node = loader.load(ConfigurationOptions.defaults().setHeader(HEADER));
        config = configMapper.populate(node);
        configMapper.serialize(node);
        loader.save(node);
    } catch (Exception e) {
        System.err.println("Error loading configuration:");
        e.printStackTrace();
    }
}
 
开发者ID:Despector,项目名称:Despector,代码行数:23,代码来源:ConfigManager.java

示例10: loadConfig

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //导入依赖的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

示例11: loadMessages

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //导入依赖的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

示例12: NamedConfiguration

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //导入依赖的package包/类
public NamedConfiguration(String name) {
    try {
        File conf = new File(Bedrock.getParentDirectory().getAbsolutePath() + "/" + name + ".conf");
        boolean fileCreated = false;

        if (!conf.exists()) {
            conf.createNewFile();
            fileCreated = true;
        }

        configLoader = HoconConfigurationLoader.builder().setFile(conf).build();
        if (fileCreated) {
            rootNode = configLoader.createEmptyNode(ConfigurationOptions.defaults());
        } else {
            rootNode = configLoader.load();
        }

        // Save
        save();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:prism,项目名称:Bedrock,代码行数:24,代码来源:NamedConfiguration.java

示例13: init

import ninja.leaping.configurate.hocon.HoconConfigurationLoader; //导入依赖的package包/类
public static void init(File rootDir)
{
	languageFile = new File(rootDir, "language.conf");
	languageManager = HoconConfigurationLoader.builder().setPath(languageFile.toPath()).build();
	
	try
	{
		if (!languageFile.exists())
		{
			languageFile.getParentFile().mkdirs();
			languageFile.createNewFile();
			language = languageManager.load();
			languageManager.save(language);
		}
		language = languageManager.load();
	}
	catch (IOException e)
	{
		NationsPlugin.getLogger().error("Could not load or create language file !");
		e.printStackTrace();
	}
	
}
 
开发者ID:Arckenver,项目名称:Nations,代码行数:24,代码来源:LanguageHandler.java

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

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


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