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