Search in sources :

Example 1 with NodePath

use of org.spongepowered.configurate.NodePath in project SpongeCommon by SpongePowered.

the class FileMovingConfigurationTransformation method apply.

@Override
public void apply(@NonNull final ConfigurationNode oldConfig) throws ConfigurateException {
    final ConfigurationNode newConfig = this.destinationLoader.load();
    boolean acted = false;
    for (final NodePath path : this.paths) {
        final ConfigurationNode source = oldConfig.node(path);
        if (!source.virtual()) {
            acted = true;
            if (this.override) {
                newConfig.node(path).from(source);
            } else {
                newConfig.node(path).mergeFrom(source);
            }
            source.raw(null);
        }
    }
    if (acted) {
        this.destinationLoader.save(newConfig);
    }
}
Also used : ConfigurationNode(org.spongepowered.configurate.ConfigurationNode) NodePath(org.spongepowered.configurate.NodePath)

Aggregations

ConfigurationNode (org.spongepowered.configurate.ConfigurationNode)1 NodePath (org.spongepowered.configurate.NodePath)1