crwdns121551:0crwdne121551:0

crwdns121553:0:javadoc:crwdne121553:0

Tip

crwdns121555:0crwdne121555:0

crwdns121557:0crwdne121557:0

Note

crwdns121559:0:javadoc:crwdnd121559:0:doc:crwdne121559:0

crwdns121561:0:javadoc:crwdne121561:0

import java.nio.file.Path;
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
import ninja.leaping.configurate.hocon.HoconConfigurationLoader;
import ninja.leaping.configurate.loader.ConfigurationLoader;

Path potentialFile = getConfigPath();
ConfigurationLoader<CommentedConfigurationNode> loader =
        HoconConfigurationLoader.builder().setPath(potentialFile).build();

crwdns121563:0:doc:crwdne121563:0

crwdns121565:0:javadoc:crwdnd121565:0:javadoc:crwdne121565:0

crwdns121567:0:javadoc:crwdnd121567:0:javadoc:crwdnd121567:0:javadoc:crwdne121567:0

crwdns121569:0crwdne121569:0

Note

crwdns121571:0:javadoc:crwdnd121571:0:javadoc:crwdne121571:0

crwdns121573:0crwdne121573:0

crwdns121575:0:javadoc:crwdnd121575:0:javadoc:crwdne121575:0

import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.ConfigurationOptions;

Path potentialFile = getConfigPath();
ConfigurationLoader<CommentedConfigurationNode> loader =
        HoconConfigurationLoader.builder().setPath(potentialFile).build();
ConfigurationNode rootNode = loader.createEmptyNode(ConfigurationOptions.defaults());

crwdns121577:0:javadoc:crwdnd121577:0:javadoc:crwdne121577:0

crwdns121579:0:javadoc:crwdnd121579:0:javadoc:crwdne121579:0

import java.io.IOException;

Path potentialFile = getConfigPath();
ConfigurationLoader<CommentedConfigurationNode> loader =
        HoconConfigurationLoader.builder().setPath(potentialFile).build();
ConfigurationNode rootNode;
try {
    rootNode = loader.load();
} catch(IOException e) {
    // handle error
}

crwdns121581:0crwdne121581:0

crwdns121583:0crwdne121583:0

crwdns121585:0crwdne121585:0

try {
    loader.save(rootNode);
} catch(IOException e) {
    // handle error
}

crwdns121587:0crwdne121587:0

Tip

crwdns121589:0:doc:crwdne121589:0

crwdns121591:0crwdne121591:0

crwdns121593:0:doc:crwdne121593:0

PluginContainer plugin = ...;
Path path = ...;

Sponge.getAssetManager().getAsset(plugin, "default.conf").get().copyToFile(path, false, true);
loader = HoconConfigurationLoader.builder().setPath(path).build();
rootNode = loader.load();

crwdns121595:0:javadoc:crwdnd121595:0:javadoc:crwdne121595:0

Note

crwdns121597:0:doc:crwdne121597:0

crwdns121599:0:doc:crwdne121599:0

crwdns121601:0crwdne121601:0

crwdns121603:0crwdne121603:0

PluginContainer plugin = ...;

node.mergeValuesFrom(HoconConfigurationLoader.builder()
                    .setURL(plugin.getAsset("default.conf").get().getUrl())
                    .build()
                    .load(ConfigurationOptions.defaults()));

Note

crwdns121605:0crwdne121605:0