diff --git a/README.md b/README.md index f0c7f1a..5cf8966 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Releases can be found on the [releases tab](https://github.com/APDevTeam/Movecra Development builds can be found on the [GitHub Actions tab](https://github.com/APDevTeam/Movecraft-Warfare/actions) of this repository. -Previous builds can be found on[our SpigotMC page](https://www.spigotmc.org/resources/movecraft-warfare.87359/). +Previous builds can be found on [our SpigotMC page](https://www.spigotmc.org/resources/movecraft-warfare.87359/). ## Building Run the following to build Movecraft-Warfare: diff --git a/src/main/java/net/countercraft/movecraft/warfare/localisation/I18nSupport.java b/src/main/java/net/countercraft/movecraft/warfare/localisation/I18nSupport.java index fffb843..10746f7 100644 --- a/src/main/java/net/countercraft/movecraft/warfare/localisation/I18nSupport.java +++ b/src/main/java/net/countercraft/movecraft/warfare/localisation/I18nSupport.java @@ -2,16 +2,20 @@ import net.countercraft.movecraft.warfare.MovecraftWarfare; import net.countercraft.movecraft.warfare.config.Config; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.TextComponent; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; import java.io.*; import java.util.Properties; import java.util.logging.Level; public class I18nSupport { - private static Properties langFile; + private static Properties languageFile; public static void init() { - langFile = new Properties(); + languageFile = new Properties(); File langDirectory = new File(MovecraftWarfare.getInstance().getDataFolder().getAbsolutePath() + "/localisation"); if (!langDirectory.exists()) { @@ -19,7 +23,6 @@ public static void init() { } InputStream stream = null; - try { stream = new FileInputStream(langDirectory.getAbsolutePath()+"/mcwlang_" + Config.Locale + ".properties"); } catch (FileNotFoundException e) { @@ -32,18 +35,28 @@ public static void init() { } try { - langFile.load(stream); + languageFile.load(stream); } catch (IOException e) { e.printStackTrace(); } } - public static String getInternationalisedString(String key) { - String ret = langFile.getProperty(key); + private static String get(String key) { + String ret = languageFile.getProperty(key); if (ret != null) { return ret; } else { return key; } } + + @Deprecated(forRemoval = true) + public static String getInternationalisedString(String key) { + return get(key); + } + + @Contract("_ -> new") + public static @NotNull TextComponent getInternationalisedComponent(String key){ + return Component.text(get(key)); + } }