use of com.electronwill.nightconfig.core.file.CommentedFileConfig in project UnlitCampfire by cech12.
the class ServerConfig 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);
}
use of com.electronwill.nightconfig.core.file.CommentedFileConfig in project Tetra-Pak by Noobulus.
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);
}
use of com.electronwill.nightconfig.core.file.CommentedFileConfig in project MinecraftForge by MinecraftForge.
the class ForgeConfigSpecTest method executeSpeedTest.
private <T> void executeSpeedTest(final String configKey, final T defaultKeyValue, final String testName) throws IOException {
final ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
final ForgeConfigSpec.ConfigValue<T> simpleValue = builder.define(configKey, defaultKeyValue);
final ForgeConfigSpec spec = builder.build();
final String configPath = String.format(Locale.ROOT, TEST_CONFIG_PATH_TEMPLATE, testName);
final File configFile = new File(configPath);
configFile.getParentFile().mkdirs();
configFile.createNewFile();
final CommentedFileConfig configData = CommentedFileConfig.builder(configPath).sync().preserveInsertionOrder().onFileNotFound((newfile, configFormat) -> {
Files.createFile(newfile);
return true;
}).writingMode(WritingMode.REPLACE).build();
spec.setConfig(configData);
final List<TestResult> results = runTestHarness(defaultKeyValue, testName, simpleValue, spec, 3, 20);
final double averageEnabled = results.stream().mapToLong(value -> value.enabledWatch.elapsed(TimeUnit.NANOSECONDS)).average().getAsDouble();
final double averageDisabled = results.stream().mapToLong(value -> value.disabledWatch.elapsed(TimeUnit.NANOSECONDS)).average().getAsDouble();
final double maxEnabledDeviation = results.stream().mapToLong(value -> value.enabledWatch.elapsed(TimeUnit.NANOSECONDS)).mapToDouble(e -> e - averageEnabled).map(Math::abs).max().getAsDouble();
final double maxDisabledDeviation = results.stream().mapToLong(value -> value.disabledWatch.elapsed(TimeUnit.NANOSECONDS)).mapToDouble(e -> e - averageDisabled).map(Math::abs).max().getAsDouble();
System.out.printf("Computed test results for: %s:%n", testName);
System.out.printf(" > Enabled: ~%10.2f ns. +- %10.2f ns.%n", averageEnabled, maxEnabledDeviation);
System.out.printf(" > Disabled: ~%10.2f ns. +- %10.2f ns.%n", averageDisabled, maxDisabledDeviation);
configFile.delete();
}
use of com.electronwill.nightconfig.core.file.CommentedFileConfig in project pollen by MoonflowerTeam.
the class ConfigTracker method openConfig.
private void openConfig(PollinatedModConfigImpl config, Path configBasePath) {
CommentedFileConfig configData = config.getHandler().reader(configBasePath).apply(config);
config.setConfigData(configData);
ConfigEvent.LOADING.invoker().configChanged(config);
config.save();
}
use of com.electronwill.nightconfig.core.file.CommentedFileConfig in project RFToolsBuilder 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);
}
Aggregations