Search in sources :

Example 31 with CommentedFileConfig

use of com.electronwill.nightconfig.core.file.CommentedFileConfig in project JustEnoughResources by way2muchnoise.

the class Config method loadConfig.

public void loadConfig(ForgeConfigSpec spec, Path path) {
    JEResources.LOGGER.debug("Loading config file {}", path);
    final CommentedFileConfig configData = CommentedFileConfig.builder(path).sync().autosave().writingMode(WritingMode.REPLACE).build();
    JEResources.LOGGER.debug("Built TOML config for {}", path.toString());
    configData.load();
    JEResources.LOGGER.debug("Loaded TOML config file {}", path.toString());
    spec.setConfig(configData);
    ConfigValues.pushChanges();
}
Also used : CommentedFileConfig(com.electronwill.nightconfig.core.file.CommentedFileConfig)

Example 32 with CommentedFileConfig

use of com.electronwill.nightconfig.core.file.CommentedFileConfig in project MinecraftForge by MinecraftForge.

the class ConfigTracker method openConfig.

private void openConfig(final ModConfig config, final Path configBasePath) {
    LOGGER.trace(CONFIG, "Loading config file type {} at {} for {}", config.getType(), config.getFileName(), config.getModId());
    final CommentedFileConfig configData = config.getHandler().reader(configBasePath).apply(config);
    config.setConfigData(configData);
    config.fireEvent(IConfigEvent.loading(config));
    config.save();
}
Also used : CommentedFileConfig(com.electronwill.nightconfig.core.file.CommentedFileConfig)

Example 33 with CommentedFileConfig

use of com.electronwill.nightconfig.core.file.CommentedFileConfig in project Fragile-Glass by fredtargaryen.

the class Config method loadConfig.

public static void loadConfig(Path path) {
    final CommentedFileConfig configData = CommentedFileConfig.builder(path).sync().autosave().writingMode(WritingMode.REPLACE).build();
    configData.load();
    COMMON_CONFIG_SPEC.setConfig(configData);
}
Also used : CommentedFileConfig(com.electronwill.nightconfig.core.file.CommentedFileConfig)

Example 34 with CommentedFileConfig

use of com.electronwill.nightconfig.core.file.CommentedFileConfig in project xercamods by ercanserteli.

the class Config method loadConfig.

public static void loadConfig(ForgeConfigSpec spec, Path path) {
    final CommentedFileConfig configData = CommentedFileConfig.builder(path).sync().autosave().writingMode(WritingMode.REPLACE).build();
    configData.load();
    spec.setConfig(configData);
    bakeConfig();
}
Also used : CommentedFileConfig(com.electronwill.nightconfig.core.file.CommentedFileConfig)

Example 35 with CommentedFileConfig

use of com.electronwill.nightconfig.core.file.CommentedFileConfig in project RFToolsUtility by McJtyMods.

the class Config method loadConfig.

public static void loadConfig(ForgeConfigSpec spec, Path path) {
    final CommentedFileConfig configData = CommentedFileConfig.builder(path).sync().autosave().writingMode(WritingMode.REPLACE).build();
    configData.load();
    spec.setConfig(configData);
}
Also used : CommentedFileConfig(com.electronwill.nightconfig.core.file.CommentedFileConfig)

Aggregations

CommentedFileConfig (com.electronwill.nightconfig.core.file.CommentedFileConfig)45 File (java.io.File)12 Path (java.nio.file.Path)2 CommentedConfig (com.electronwill.nightconfig.core.CommentedConfig)1 ObjectConverter (com.electronwill.nightconfig.core.conversion.ObjectConverter)1 WritingMode (com.electronwill.nightconfig.core.io.WritingMode)1 Stopwatch (com.google.common.base.Stopwatch)1 Lists (com.google.common.collect.Lists)1 IOException (java.io.IOException)1 Field (java.lang.reflect.Field)1 Files (java.nio.file.Files)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Locale (java.util.Locale)1 TimeUnit (java.util.concurrent.TimeUnit)1 ForgeConfigSpec (net.minecraftforge.common.ForgeConfigSpec)1 Assert (org.junit.Assert)1 Test (org.junit.Test)1