From a7a4a511e790b51f3be92dcaae1c38c4ddb40898 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sat, 25 Jul 2015 00:08:29 +0200 Subject: [PATCH] Hotfix: it was shit, sorry --- .../fr/xephi/authme/settings/Messages.java | 11 ++++++++--- .../fr/xephi/authme/settings/Settings.java | 19 +++++++++++-------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/main/java/fr/xephi/authme/settings/Messages.java b/src/main/java/fr/xephi/authme/settings/Messages.java index bf88b15d0..2328d8206 100644 --- a/src/main/java/fr/xephi/authme/settings/Messages.java +++ b/src/main/java/fr/xephi/authme/settings/Messages.java @@ -1,9 +1,12 @@ package fr.xephi.authme.settings; import java.io.File; +import java.io.InputStream; + import org.bukkit.command.CommandSender; import org.bukkit.configuration.file.YamlConfiguration; +import fr.xephi.authme.AuthMe; import fr.xephi.authme.ConsoleLogger; public class Messages extends CustomConfiguration { @@ -24,11 +27,13 @@ public class Messages extends CustomConfiguration { * @param filename * The filename to open */ + @SuppressWarnings("deprecation") public final void loadDefaults(File file) { - if (!file.exists()) + InputStream stream = AuthMe.getInstance().getResource(file.getName()); + if (stream == null) return; - - setDefaults(YamlConfiguration.loadConfiguration(file)); + + setDefaults(YamlConfiguration.loadConfiguration(stream)); } /** diff --git a/src/main/java/fr/xephi/authme/settings/Settings.java b/src/main/java/fr/xephi/authme/settings/Settings.java index 0d3fb0caa..61b5a682f 100644 --- a/src/main/java/fr/xephi/authme/settings/Settings.java +++ b/src/main/java/fr/xephi/authme/settings/Settings.java @@ -7,6 +7,7 @@ import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -102,7 +103,7 @@ public final class Settings extends YamlConfiguration { if (exists()) { load(); } else { - loadDefaults(file); + loadDefaults(file.getName()); load(); } configFile = (YamlConfiguration) plugin.getConfig(); @@ -685,7 +686,7 @@ public final class Settings extends YamlConfiguration { public final void reload() { load(); - loadDefaults(file); + loadDefaults(file.getName()); } /** @@ -717,12 +718,14 @@ public final class Settings extends YamlConfiguration { * @param filename * The filename to open */ - public final void loadDefaults(File file) { - if (!file.exists()) - return; - - setDefaults(YamlConfiguration.loadConfiguration(file)); - } + @SuppressWarnings("deprecation") + public final void loadDefaults(String filename) { + InputStream stream = plugin.getResource(filename); + if (stream == null) + return; + + setDefaults(YamlConfiguration.loadConfiguration(stream)); + } /** * Saves current configuration (plus defaults) to disk.