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


Java ConfigurationLoader.save方法代码示例

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


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

示例1: addPlayer

import ninja.leaping.configurate.loader.ConfigurationLoader; //导入方法依赖的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

示例2: setPower

import ninja.leaping.configurate.loader.ConfigurationLoader; //导入方法依赖的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

示例3: setMaxPower

import ninja.leaping.configurate.loader.ConfigurationLoader; //导入方法依赖的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

示例4: setPlayerChunkPosition

import ninja.leaping.configurate.loader.ConfigurationLoader; //导入方法依赖的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

示例5: loadConfig

import ninja.leaping.configurate.loader.ConfigurationLoader; //导入方法依赖的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

示例6: loadMessages

import ninja.leaping.configurate.loader.ConfigurationLoader; //导入方法依赖的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

示例7: testSimpleLoading

import ninja.leaping.configurate.loader.ConfigurationLoader; //导入方法依赖的package包/类
@Test
public void testSimpleLoading() throws IOException {
    URL url = getClass().getResource("/example.json");
    final Path tempFile = folder.newFile().toPath();
    ConfigurationLoader loader = JSONConfigurationLoader.builder()
            .setSource(() -> new BufferedReader(new InputStreamReader(url.openStream(), UTF_8)))
                    .setSink(AtomicFiles.createAtomicWriterFactory(tempFile, UTF_8)).build();
    ConfigurationNode node = loader.load(ConfigurationOptions.defaults().setMapFactory(MapFactories.sortedNatural()));
    assertEquals("unicorn", node.getNode("test", "op-level").getValue());
    assertEquals("dragon", node.getNode("other", "op-level").getValue());
    assertEquals("dog park", node.getNode("other", "location").getValue());
    /*CommentedConfigurationNode commentNode = SimpleCommentedConfigurationNode.root();
    commentNode.getNode("childOne").setValue("a").setComment("Test comment");
    commentNode.getNode("childTwo", "something").setValue("b").setComment("Test comment 2");
    commentNode.getNode("childTwo", "another").setValue("b").setComment("Test comment 3");
    */
    loader.save(node);
    assertEquals(Resources.readLines(url, UTF_8), Files
            .readAllLines(tempFile, UTF_8));

}
 
开发者ID:SpongePowered,项目名称:configurate,代码行数:22,代码来源:JSONConfigurationLoaderTest.java

示例8: testSimpleLoading

import ninja.leaping.configurate.loader.ConfigurationLoader; //导入方法依赖的package包/类
@Test
public void testSimpleLoading() throws IOException {
    URL url = getClass().getResource("/example.json");
    final Path tempFile = folder.newFile().toPath();
    ConfigurationLoader<ConfigurationNode> loader = GsonConfigurationLoader.builder()
            .setSource(() -> new BufferedReader(new InputStreamReader(url.openStream())))
            .setSink(AtomicFiles.createAtomicWriterFactory(tempFile, UTF_8)).setLenient(true).build();
    ConfigurationNode node = loader.load(loader.getDefaultOptions().setMapFactory(MapFactories.sortedNatural()));
    assertEquals("unicorn", node.getNode("test", "op-level").getValue());
    assertEquals("dragon", node.getNode("other", "op-level").getValue());
    assertEquals("dog park", node.getNode("other", "location").getValue());
    assertTrue(node.getNode("int-val").getValue() instanceof Integer);
    assertTrue(node.getNode("double-val").getValue() instanceof Double);
    loader.save(node);
    assertEquals(Resources.readLines(url, UTF_8), Files.readAllLines(tempFile, UTF_8));
}
 
开发者ID:SpongePowered,项目名称:configurate,代码行数:17,代码来源:GsonConfigurationLoaderTest.java

示例9: loadAndSaveConfiguration

import ninja.leaping.configurate.loader.ConfigurationLoader; //导入方法依赖的package包/类
private void loadAndSaveConfiguration() throws ClassNotFoundException, IllegalAccessException, IOException {
    for(Field field : module.getClass().getFields()) {
        if(field.isAnnotationPresent(ModuleConfiguration.class)) {
            File legacyConfig = new File(((SpongeModuleController<T>) this.getOwner()).getConfigurationDirectory(), getName() + ".conf");
            File config = new File(((SpongeModuleController<T>) this.getOwner()).getConfigurationDirectory(), getId() + ".conf");
            if(!getAnnotation().name().equals(getAnnotation().id()) && legacyConfig.exists()) {
                legacyConfig.renameTo(config);
            }
            if(!config.exists())
                config.createNewFile();
            ConfigurationLoader<CommentedConfigurationNode> configLoader = HoconConfigurationLoader.builder().setFile(config).build();
            if(((SpongeModuleController<T>) this.getOwner()).isOverrideConfigurationNode()) {
                field.set(module, configLoader.load(((SpongeModuleController<T>) this.getOwner()).getConfigurationOptions()));
            }
            configLoader.save((ConfigurationNode) field.get(module));
        }
    }
}
 
开发者ID:me4502,项目名称:ModularFramework,代码行数:19,代码来源:SpongeModuleWrapper.java

示例10: saveGraveyards

import ninja.leaping.configurate.loader.ConfigurationLoader; //导入方法依赖的package包/类
public static void saveGraveyards(Graveyards plugin) {

        File graveyardsFile = new File(plugin.getDefaultConfigDir().toFile(), "graveyardsData.conf");
        ConfigurationLoader<CommentedConfigurationNode> loader = HoconConfigurationLoader.builder().setFile(graveyardsFile).build();

        try {
            CommentedConfigurationNode graveyardsData = loader.load();

            graveyardsData.setValue(new TypeToken<Map<String, GraveyardGroup>>() {
                                    },
                    plugin.getGraveyardGroupManager().getGraveyardGroupMap());

            loader.save(graveyardsData);
        } catch (IOException | ObjectMappingException e) {
            plugin.getLogger().error("Error saving graveyard data! Error:" + e.getMessage());
        }
    }
 
开发者ID:Zerthick,项目名称:Graveyards,代码行数:18,代码来源:ConfigManager.java

示例11: loadConfigValues

import ninja.leaping.configurate.loader.ConfigurationLoader; //导入方法依赖的package包/类
public static void loadConfigValues(Graveyards plugin) {

        ConfigurationLoader<CommentedConfigurationNode> loader = plugin.getConfigLoader();

        try {
            CommentedConfigurationNode graveyardsConfig = loader.load();

            if (!plugin.getDefaultConfig().toFile().exists()) {
                graveyardsConfig.getNode("defaultMessage")
                        .setComment("Default message that will be set to the player upon spawning at a graveyard")
                        .setValue(TypeToken.of(String.class), "&2Welcome to the &a{GRAVEYARD_NAME} &2graveyard.");
                loader.save(graveyardsConfig);
            }

            ConfigValues.getInstance().setDefaultGraveyardMessage(graveyardsConfig.getNode("defaultMessage").getString());

        } catch (IOException | ObjectMappingException e) {
            plugin.getLogger().error("Error loading graveyard config! Error:" + e.getMessage());
        }
    }
 
开发者ID:Zerthick,项目名称:Graveyards,代码行数:21,代码来源:ConfigManager.java

示例12: saveRespawnPackets

import ninja.leaping.configurate.loader.ConfigurationLoader; //导入方法依赖的package包/类
public static void saveRespawnPackets(Graveyards plugin) {

        File respawnDataFile = new File(plugin.getDefaultConfigDir().toFile(), "respawnData.conf");
        ConfigurationLoader<CommentedConfigurationNode> loader = HoconConfigurationLoader.builder().setFile(respawnDataFile).build();

        try {
            CommentedConfigurationNode respawnData = loader.load();

            respawnData.setValue(new TypeToken<Map<UUID, RespawnDataPacket>>() {
                                 },
                    plugin.getRespawnDataPacketMap());

            loader.save(respawnData);
        } catch (IOException | ObjectMappingException e) {
            plugin.getLogger().error("Error saving respawn data! Error:" + e.getMessage());
        }
    }
 
开发者ID:Zerthick,项目名称:Graveyards,代码行数:18,代码来源:ConfigManager.java

示例13: loadMapper

import ninja.leaping.configurate.loader.ConfigurationLoader; //导入方法依赖的package包/类
private <T> void loadMapper(ObjectMapper<T>.BoundInstance mapper
        , ConfigurationLoader<CommentedConfigurationNode> loader) {
    CommentedConfigurationNode rootNode;
    if (mapper != null) {
        try {
            rootNode = loader.load(ConfigurationOptions.defaults().setShouldCopyDefaults(true));

            //load the config into the object
            mapper.populate(rootNode);

            //add missing default values
            loader.save(rootNode);
        } catch (ObjectMappingException objMappingExc) {
            logger.error("Error loading the configuration", objMappingExc);
        } catch (IOException ioExc) {
            logger.error("Error saving the default configuration", ioExc);
        }
    }
}
 
开发者ID:games647,项目名称:FlexibleLogin,代码行数:20,代码来源:Settings.java

示例14: addPower

import ninja.leaping.configurate.loader.ConfigurationLoader; //导入方法依赖的package包/类
public static void addPower(UUID playerUUID, boolean isKillAward)
{
    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 playerPower = new BigDecimal(playerNode.getNode("power").getString());

        if(isKillAward)
        {
            BigDecimal killAward = MainLogic.getKillAward();
            playerNode.getNode("power").setValue(playerPower.add(killAward));
        }
        else
        {
            playerNode.getNode("power").setValue(playerPower.add(MainLogic.getPowerIncrement()));
        }
        configLoader.save(playerNode);
    }
    catch (Exception exception)
    {
        exception.printStackTrace();
    }

}
 
开发者ID:Aquerr,项目名称:EagleFactions,代码行数:30,代码来源:PowerService.java

示例15: decreasePower

import ninja.leaping.configurate.loader.ConfigurationLoader; //导入方法依赖的package包/类
public static void decreasePower(UUID playerUUID)
{
    if(PowerService.getPlayerPower(playerUUID).subtract(MainLogic.getPowerDecrement()).doubleValue() > BigDecimal.ZERO.doubleValue())
    {
        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 playerPower = new BigDecimal(playerNode.getNode("power").getString());

            playerNode.getNode("power").setValue(playerPower.subtract(MainLogic.getPowerDecrement()));
            configLoader.save(playerNode);
        }
        catch (Exception exception)
        {
            exception.printStackTrace();
        }
    }
    else
    {
        PowerService.setPower(playerUUID, BigDecimal.ZERO);
    }
}
 
开发者ID:Aquerr,项目名称:EagleFactions,代码行数:28,代码来源:PowerService.java


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