diff --git a/CHANGELOG.md b/CHANGELOG.md index c88158b..582f8d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +### [v1.2.2] +- Handled a case where the client (geyser) will return the language as uppercase instead of lowercase. +- Fixed null-pointer exceptions being logged when a language file couldn't be found. + ### [v1.2.1] - Added support for 1.21.4 - Added Traditional Chinese translations (Thanks to [hugoalh](https://github.com/hugoalh)!) diff --git a/common/src/main/java/dev/mrsnowy/teleport_commands/utils/tools.java b/common/src/main/java/dev/mrsnowy/teleport_commands/utils/tools.java index ca6c129..f1a6665 100644 --- a/common/src/main/java/dev/mrsnowy/teleport_commands/utils/tools.java +++ b/common/src/main/java/dev/mrsnowy/teleport_commands/utils/tools.java @@ -133,7 +133,7 @@ public class tools { // Gets the translated text for each player based on their language, this is fully server side and actually works (UNLIKE MOJANG'S TRANSLATED KEY'S WHICH ARE CLIENT SIDE) (I'm not mad, I swear) public static MutableComponent getTranslatedText(String key, ServerPlayer player, MutableComponent... args) { - String language = player.clientInformation().language(); + String language = player.clientInformation().language().toLowerCase(); String regex = "%(\\d+)%"; Pattern pattern = Pattern.compile(regex); @@ -142,7 +142,7 @@ public class tools { String filePath = String.format("/assets/%s/lang/%s.json", MOD_ID, language); InputStream stream = TeleportCommands.class.getResourceAsStream(filePath); - Reader reader = new InputStreamReader(Objects.requireNonNull(stream), StandardCharsets.UTF_8); + Reader reader = new InputStreamReader(Objects.requireNonNull(stream, String.format("Couldn't find the required language file for \"%s\"", language)), StandardCharsets.UTF_8); JsonElement json = JsonParser.parseReader(reader); String translation = json.getAsJsonObject().get(key).getAsString(); @@ -166,7 +166,7 @@ public class tools { return component; } catch (Exception e) { - TeleportCommands.LOGGER.error(e.toString()); + try { if (!Objects.equals(language, "en_us")) { // TeleportCommands.LOGGER.warn("Key \"{}\" not found in the language: {}, falling back to default (en_us)", key, language); @@ -174,7 +174,7 @@ public class tools { String filePath = String.format("/assets/%s/lang/en_us.json", MOD_ID); InputStream stream = TeleportCommands.class.getResourceAsStream(filePath); - Reader reader = new InputStreamReader(Objects.requireNonNull(stream, "translation file stream cannot be null"), StandardCharsets.UTF_8); + Reader reader = new InputStreamReader(Objects.requireNonNull(stream, String.format("Couldn't find the required language file for \"%s\"", language)), StandardCharsets.UTF_8); JsonElement json = JsonParser.parseReader(reader); String translation = json.getAsJsonObject().get(key).getAsString(); diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index dfbe55e..bb78ecc 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -17,7 +17,7 @@ "environment": "*", "entrypoints": { "main": [ - "dev.mrsnowy.teleport_commands.fabricInit" + "${group}.fabricInit" ] }, "mixins": [ diff --git a/settings.gradle b/settings.gradle index a98bb51..fdbb244 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,6 +1,8 @@ pluginManagement { repositories { gradlePluginPortal() + mavenCentral() + maven { name = 'Fabric' url = uri("https://maven.fabricmc.net")