use of org.spongepowered.configurate.ConfigurateException in project SpongeCommon by SpongePowered.
the class WorldMigrator method getOldWorldContainer.
/**
* Gets the old world container used when this server used to be running Bukkit.
*
* @return The world container
*/
public static Path getOldWorldContainer() {
Path worldContainer = Paths.get(".");
final Path bukkitYml = worldContainer.resolve("bukkit.yml");
if (Files.exists(bukkitYml)) {
try {
final ConfigurationNode node = YamlConfigurationLoader.builder().path(bukkitYml).build().load();
final String containerCandidate = node.node("settings", "world-container").getString("");
if (!containerCandidate.isEmpty()) {
try {
worldContainer = worldContainer.resolve(containerCandidate);
} catch (final InvalidPathException ipe) {
SpongeCommon.logger().warn("Cannot use path [{}] specified under [world-container] in bukkit" + ".yml. Will use [{}] instead.", containerCandidate, worldContainer, ipe);
}
}
} catch (final ConfigurateException ex) {
SpongeCommon.logger().warn("Cannot load bukkit.yml. Will use [{}] instead.", worldContainer, ex);
}
}
return worldContainer;
}
use of org.spongepowered.configurate.ConfigurateException in project SpongeCommon by SpongePowered.
the class HoconDataFormat method writeTo.
private static void writeTo(final Callable<BufferedWriter> sink, final DataView data) throws IOException {
final HoconConfigurationLoader loader = HoconConfigurationLoader.builder().sink(sink).build();
final ConfigurationNode node = loader.createNode();
ConfigurateTranslator.instance().translateDataToNode(node, data);
try {
loader.save(node);
} catch (final ConfigurateException ex) {
throw new IOException(ex);
}
}
use of org.spongepowered.configurate.ConfigurateException in project SpongeCommon by SpongePowered.
the class ConfigTest method onConstruction.
@Listener
public void onConstruction(final ConstructPluginEvent event) {
final URL testOne = this.getClass().getResource("/configtest/test.txt");
final URL testTwo = this.getClass().getResource("/configtest/test2.txt");
this.logger.info("Asset one: {}, asset two: {}", testOne, testTwo);
try {
this.config = this.reference.referenceTo(ExampleConfiguration.class);
this.reference.save();
} catch (final ConfigurateException ex) {
this.logger.error("Unable to load test configuration", ex);
}
}
Aggregations