A Minecraft server-side mod that adds various teleportation related commands
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[1.2.1] backported to 1.21-1.21.1

MrSnowy bef1510a f7b7f715

+11 -5
+4
CHANGELOG.md
··· 5 5 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), 6 6 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 7 8 + ### [v1.2.2] 9 + - Handled a case where the client (geyser) will return the language as uppercase instead of lowercase. 10 + - Fixed null-pointer exceptions being logged when a language file couldn't be found. 11 + 8 12 ### [v1.2.1] 9 13 - Added support for 1.21.4 10 14 - Added Traditional Chinese translations (Thanks to [hugoalh](https://github.com/hugoalh)!)
+4 -4
common/src/main/java/dev/mrsnowy/teleport_commands/utils/tools.java
··· 133 133 134 134 // 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) 135 135 public static MutableComponent getTranslatedText(String key, ServerPlayer player, MutableComponent... args) { 136 - String language = player.clientInformation().language(); 136 + String language = player.clientInformation().language().toLowerCase(); 137 137 String regex = "%(\\d+)%"; 138 138 Pattern pattern = Pattern.compile(regex); 139 139 ··· 142 142 String filePath = String.format("/assets/%s/lang/%s.json", MOD_ID, language); 143 143 InputStream stream = TeleportCommands.class.getResourceAsStream(filePath); 144 144 145 - Reader reader = new InputStreamReader(Objects.requireNonNull(stream), StandardCharsets.UTF_8); 145 + Reader reader = new InputStreamReader(Objects.requireNonNull(stream, String.format("Couldn't find the required language file for \"%s\"", language)), StandardCharsets.UTF_8); 146 146 JsonElement json = JsonParser.parseReader(reader); 147 147 String translation = json.getAsJsonObject().get(key).getAsString(); 148 148 ··· 166 166 return component; 167 167 168 168 } catch (Exception e) { 169 - TeleportCommands.LOGGER.error(e.toString()); 169 + 170 170 try { 171 171 if (!Objects.equals(language, "en_us")) { 172 172 // TeleportCommands.LOGGER.warn("Key \"{}\" not found in the language: {}, falling back to default (en_us)", key, language); ··· 174 174 String filePath = String.format("/assets/%s/lang/en_us.json", MOD_ID); 175 175 InputStream stream = TeleportCommands.class.getResourceAsStream(filePath); 176 176 177 - Reader reader = new InputStreamReader(Objects.requireNonNull(stream, "translation file stream cannot be null"), StandardCharsets.UTF_8); 177 + Reader reader = new InputStreamReader(Objects.requireNonNull(stream, String.format("Couldn't find the required language file for \"%s\"", language)), StandardCharsets.UTF_8); 178 178 JsonElement json = JsonParser.parseReader(reader); 179 179 String translation = json.getAsJsonObject().get(key).getAsString(); 180 180
+1 -1
fabric/src/main/resources/fabric.mod.json
··· 17 17 "environment": "*", 18 18 "entrypoints": { 19 19 "main": [ 20 - "dev.mrsnowy.teleport_commands.fabricInit" 20 + "${group}.fabricInit" 21 21 ] 22 22 }, 23 23 "mixins": [
+2
settings.gradle
··· 1 1 pluginManagement { 2 2 repositories { 3 3 gradlePluginPortal() 4 + mavenCentral() 5 + 4 6 maven { 5 7 name = 'Fabric' 6 8 url = uri("https://maven.fabricmc.net")