crwdns141005:0crwdne141005:0

Warning

crwdns141007:0crwdne141007:0

crwdns141009:0:javadoc:crwdne141009:0

Tip

crwdns141011:0crwdne141011:0

crwdns141013:0crwdne141013:0

Note

crwdns141015:0:javadoc:crwdnd141015:0:doc:crwdne141015:0

crwdns141017:0:javadoc:crwdne141017:0

import java.nio.file.Path;
import org.spongepowered.configurate.commented.CommentedConfigurationNode;
import org.spongepowered.configurate.hocon.HoconConfigurationLoader;
import org.spongepowered.configurate.loader.ConfigurationLoader;

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

crwdns141019:0:doc:crwdne141019:0

crwdns141021:0:javadoc:crwdnd141021:0:javadoc:crwdne141021:0

crwdns141023:0:javadoc:crwdnd141023:0:javadoc:crwdnd141023:0:javadoc:crwdne141023:0

crwdns141025:0crwdne141025:0

Note

crwdns141027:0:javadoc:crwdnd141027:0:javadoc:crwdne141027:0

crwdns141029:0crwdne141029:0

crwdns141031:0:javadoc:crwdnd141031:0:javadoc:crwdne141031:0

import org.spongerpowered.configurate.ConfigurationNode;
import org.spongerpowered.configurate.ConfigurationOptions;

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

crwdns141033:0:javadoc:crwdnd141033:0:javadoc:crwdne141033:0

crwdns141035:0:javadoc:crwdnd141035:0:javadoc:crwdne141035: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
}

crwdns141037:0crwdne141037:0

crwdns141039:0crwdne141039:0

crwdns141041:0crwdne141041:0

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

crwdns141043:0crwdne141043:0

Tip

crwdns141045:0:doc:crwdne141045:0

crwdns141047:0crwdne141047:0

crwdns141049:0crwdne141049: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();

crwdns141051:0:javadoc:crwdnd141051:0:javadoc:crwdne141051:0

Note

crwdns141053:0:doc:crwdne141053:0

crwdns141055:0:doc:crwdne141055:0

crwdns141057:0crwdne141057:0

crwdns141059:0crwdne141059:0

PluginContainer plugin = ...;

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

Note

crwdns141061:0crwdne141061:0