use of org.spongepowered.configurate.CommentedConfigurationNode in project SpongeCommon by SpongePowered.
the class InheritableConfigHandle method load.
public void load() throws ConfigurateException {
final CommentedConfigurationNode node;
final CommentedConfigurationNode mergedNode;
if (this.isAttached()) {
// store "what's in the file" separately in memory
node = this.loader.load();
// and perform any necessary version updates
this.doVersionUpdate(node);
// make a copy of the file data
mergedNode = node.copy();
} else {
node = null;
mergedNode = CommentedConfigurationNode.root(SpongeConfigs.OPTIONS);
}
// merge with settings from parent
if (this.parent != null && this.parent.mergedNode != null) {
mergedNode.mergeFrom(this.parent.mergedNode);
}
// populate the config object
this.instance = mergedNode.get(this.instanceType);
this.node = node;
this.mergedNode = mergedNode;
this.doSave();
}
use of org.spongepowered.configurate.CommentedConfigurationNode in project SpongeCommon by SpongePowered.
the class Installer method loadConfig.
private LauncherConfig loadConfig() throws ConfigurateException {
final CommentedConfigurationNode node = this.loader.load();
final LauncherConfig ret = node.get(LauncherConfig.class);
// Write back to apply any additions to the file
this.loader.save(node);
return ret;
}
use of org.spongepowered.configurate.CommentedConfigurationNode in project SpongeCommon by SpongePowered.
the class ConfigHandle method load.
void load() throws ConfigurateException {
if (this.loader == null) {
// we are virtual
return;
}
final CommentedConfigurationNode node = this.loader.load();
this.doVersionUpdate(node);
this.node = node;
this.instance = node.get(this.instanceType);
this.doSave();
}
use of org.spongepowered.configurate.CommentedConfigurationNode in project SpongeCommon by SpongePowered.
the class ConfigHandle method updateSetting.
public CompletableFuture<CommentedConfigurationNode> updateSetting(final String key, final Object value) {
return ConfigHandle.asyncFailableFuture(() -> {
final CommentedConfigurationNode upd = this.getSetting(key);
upd.set(value);
this.instance = this.node.get(this.instanceType);
this.save();
return upd;
}, ForkJoinPool.commonPool());
}
use of org.spongepowered.configurate.CommentedConfigurationNode in project SpongeCommon by SpongePowered.
the class ConfigHandle method updateSetting.
public <V> CompletableFuture<CommentedConfigurationNode> updateSetting(final String key, final V value, final TypeToken<V> token) {
return ConfigHandle.asyncFailableFuture(() -> {
final CommentedConfigurationNode upd = this.getSetting(key);
upd.set(token, value);
this.instance = this.node.get(this.instanceType);
this.save();
return upd;
}, ForkJoinPool.commonPool());
}
Aggregations