From 7b1e77340b60a8b21215b8dec4cb5d23cc140b12 Mon Sep 17 00:00:00 2001 From: Eric Stokes Date: Sat, 12 Mar 2016 13:00:05 -0700 Subject: [PATCH] Removed deprecated use of loadConfiguration The new method properly uses the Reader class and resolves the reason for deprecation, the lack of encoding support. --- .../MultiverseCore/MultiverseCore.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index 86e0ddd1..8bf67449 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -106,8 +106,7 @@ import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import org.mcstats.Metrics; -import java.io.File; -import java.io.IOException; +import java.io.*; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -480,8 +479,19 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core { public void loadConfigs() { // Now grab the Configuration Files. this.multiverseConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml")); - Configuration coreDefaults = YamlConfiguration.loadConfiguration(this.getClass().getResourceAsStream("/defaults/config.yml")); - this.multiverseConfig.setDefaults(coreDefaults); + InputStream resourceURL = this.getClass().getResourceAsStream("/defaults/config.yml"); + + // Read in our default config with UTF-8 now + Configuration coreDefaults; + try { + coreDefaults = YamlConfiguration.loadConfiguration(new BufferedReader(new InputStreamReader(resourceURL, "UTF-8"))); + this.multiverseConfig.setDefaults(coreDefaults); + } catch (UnsupportedEncodingException e) { + Logging.severe("Couldn't load default config with UTF-8 encoding. Details follow:"); + e.printStackTrace(); + Logging.severe("Default configs NOT loaded."); + } + this.multiverseConfig.options().copyDefaults(false); this.multiverseConfig.options().copyHeader(true);