Avoid deprecated loadConfiguration(InputStream)

Fixes https://github.com/graywolf336/Jail/issues/152
This commit is contained in:
M Peters 2017-06-10 17:49:27 +02:00 committed by GitHub
parent f0057a2079
commit 99e6b37a64

View File

@ -46,7 +46,6 @@ public class JailIO {
} }
/** Loads the language file from disk, if there is none then we save the default one. */ /** Loads the language file from disk, if there is none then we save the default one. */
@SuppressWarnings("deprecation")
protected void loadLanguage() { protected void loadLanguage() {
String language = pl.getConfig().getString(Settings.LANGUAGE.getPath()); String language = pl.getConfig().getString(Settings.LANGUAGE.getPath());
boolean save = false; boolean save = false;
@ -60,18 +59,18 @@ public class JailIO {
}else { }else {
pl.getLogger().severe("The language file can not be a folder."); pl.getLogger().severe("The language file can not be a folder.");
pl.getLogger().severe("As a result, we are reverting back to English as the language."); pl.getLogger().severe("As a result, we are reverting back to English as the language.");
Lang.setFile(YamlConfiguration.loadConfiguration(pl.getResource("locales/en.yml"))); Lang.setFile(YamlConfiguration.loadConfiguration(new File(pl.getDataFolder(),"locales/en.yml")));
save = true; save = true;
} }
}else { }else {
pl.getLogger().warning("Loading the default language of: en"); pl.getLogger().warning("Loading the default language of: en");
pl.getLogger().warning("If you wish to change this, please rename 'en.yml' to whatever you wish and set the config value to the name of the file."); pl.getLogger().warning("If you wish to change this, please rename 'en.yml' to whatever you wish and set the config value to the name of the file.");
Lang.setFile(YamlConfiguration.loadConfiguration(pl.getResource("locales/en.yml"))); Lang.setFile(YamlConfiguration.loadConfiguration(new File(pl.getDataFolder(),"locales/en.yml")));
save = true; save = true;
} }
//Make sure we have all the new language settings loaded //Make sure we have all the new language settings loaded
if(!save) save = Lang.writeNewLanguage(YamlConfiguration.loadConfiguration(pl.getResource("locales/en.yml"))); if(!save) save = Lang.writeNewLanguage(YamlConfiguration.loadConfiguration(new File(pl.getDataFolder(),"locales/en.yml")));
//If we have flagged to save the language file, let's save it as en.yml as this flag usually means they didn't have it loaded. //If we have flagged to save the language file, let's save it as en.yml as this flag usually means they didn't have it loaded.
if(save) { if(save) {