From 99e6b37a643632b90c96af919ddfc55884872c81 Mon Sep 17 00:00:00 2001 From: M Peters Date: Sat, 10 Jun 2017 17:49:27 +0200 Subject: [PATCH 1/3] Avoid deprecated loadConfiguration(InputStream) Fixes https://github.com/graywolf336/Jail/issues/152 --- src/main/java/com/graywolf336/jail/JailIO.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/graywolf336/jail/JailIO.java b/src/main/java/com/graywolf336/jail/JailIO.java index 6309f81..ddd2951 100644 --- a/src/main/java/com/graywolf336/jail/JailIO.java +++ b/src/main/java/com/graywolf336/jail/JailIO.java @@ -46,7 +46,6 @@ public class JailIO { } /** Loads the language file from disk, if there is none then we save the default one. */ - @SuppressWarnings("deprecation") protected void loadLanguage() { String language = pl.getConfig().getString(Settings.LANGUAGE.getPath()); boolean save = false; @@ -60,18 +59,18 @@ public class JailIO { }else { 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."); - Lang.setFile(YamlConfiguration.loadConfiguration(pl.getResource("locales/en.yml"))); + Lang.setFile(YamlConfiguration.loadConfiguration(new File(pl.getDataFolder(),"locales/en.yml"))); save = true; } }else { 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."); - Lang.setFile(YamlConfiguration.loadConfiguration(pl.getResource("locales/en.yml"))); + Lang.setFile(YamlConfiguration.loadConfiguration(new File(pl.getDataFolder(),"locales/en.yml"))); save = true; } //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(save) { From 56c54c08f095cb4cfc9fced64a7b0c0274ab2088 Mon Sep 17 00:00:00 2001 From: M Peters Date: Mon, 12 Jun 2017 18:13:25 +0200 Subject: [PATCH 2/3] Switch from File to InputStream Fixes the failing tests --- src/main/java/com/graywolf336/jail/JailIO.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/graywolf336/jail/JailIO.java b/src/main/java/com/graywolf336/jail/JailIO.java index ddd2951..492c501 100644 --- a/src/main/java/com/graywolf336/jail/JailIO.java +++ b/src/main/java/com/graywolf336/jail/JailIO.java @@ -59,18 +59,18 @@ public class JailIO { }else { 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."); - Lang.setFile(YamlConfiguration.loadConfiguration(new File(pl.getDataFolder(),"locales/en.yml"))); + Lang.setFile(YamlConfiguration.loadConfiguration(new InputStreamReader(pl.getResource("locales/en.yml")))); save = true; } }else { 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."); - Lang.setFile(YamlConfiguration.loadConfiguration(new File(pl.getDataFolder(),"locales/en.yml"))); + Lang.setFile(YamlConfiguration.loadConfiguration(new InputStreamReader(pl.getResource("locales/en.yml")))); save = true; } //Make sure we have all the new language settings loaded - if(!save) save = Lang.writeNewLanguage(YamlConfiguration.loadConfiguration(new File(pl.getDataFolder(),"locales/en.yml"))); + if(!save) save = Lang.writeNewLanguage(YamlConfiguration.loadConfiguration(new InputStreamReader(pl.getResource("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(save) { From 7e2094830b7875d1962bc1a5d26c4e727dc424b1 Mon Sep 17 00:00:00 2001 From: M Peters Date: Mon, 12 Jun 2017 18:27:27 +0200 Subject: [PATCH 3/3] Forgot import... --- src/main/java/com/graywolf336/jail/JailIO.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/graywolf336/jail/JailIO.java b/src/main/java/com/graywolf336/jail/JailIO.java index 492c501..2bb8efe 100644 --- a/src/main/java/com/graywolf336/jail/JailIO.java +++ b/src/main/java/com/graywolf336/jail/JailIO.java @@ -1,6 +1,7 @@ package com.graywolf336.jail; import java.io.File; +import java.io.InputStreamReader; import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager;