From fdab4445b6ea9cf22f0254e70754ea49d0ac259a Mon Sep 17 00:00:00 2001 From: Xujiayao Date: Fri, 30 Jan 2026 09:47:46 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4Minecraft=E7=BF=BB=E8=AF=91?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/i18n/I18nManager.java | 86 +------------------ 1 file changed, 1 insertion(+), 85 deletions(-) diff --git a/core/src/main/java/com/xujiayao/discord_mc_chat/utils/i18n/I18nManager.java b/core/src/main/java/com/xujiayao/discord_mc_chat/utils/i18n/I18nManager.java index 58d28f32..b1cc28ad 100644 --- a/core/src/main/java/com/xujiayao/discord_mc_chat/utils/i18n/I18nManager.java +++ b/core/src/main/java/com/xujiayao/discord_mc_chat/utils/i18n/I18nManager.java @@ -21,7 +21,7 @@ import static com.xujiayao.discord_mc_chat.Constants.YAML_MAPPER; /** * Manages internationalization (i18n) for DMCC. - * Handles loading language files for custom messages, DMCC translations, and Minecraft translations. + * Handles loading language files for DMCC Translations and Custom Messages. * * @author Xujiayao */ @@ -29,8 +29,6 @@ public class I18nManager { private static final Map DMCC_TRANSLATIONS = new HashMap<>(); private static final Path CUSTOM_MESSAGES_DIR = Paths.get("./config/discord_mc_chat/custom_messages"); - private static final Path CACHE_DIR = Paths.get("./config/discord_mc_chat/cache/lang"); - private static final Map minecraftTranslations = new HashMap<>(); private static String language = detectLanguage(); private static JsonNode customMessages; @@ -102,11 +100,6 @@ public class I18nManager { if (!loadCustomMessages()) { return false; } - - // Load official Minecraft translations, from cache or by downloading -// if (!loadMinecraftTranslations()) { -// return false; -// } } LOGGER.info(I18nManager.getDmccTranslation("utils.i18n.fully_loaded")); @@ -206,64 +199,6 @@ public class I18nManager { return false; } -// /** -// * Loads the official Minecraft translation file for the current language. -// * It attempts to use a cached version before downloading a new one. -// * -// * @return true if the translations were loaded successfully. -// */ -// private static boolean loadMinecraftTranslations() { -// minecraftTranslations.clear(); -// -// try { -// String mcVersion = "EnvironmentUtils.getMinecraftVersion()"; -// String fileName = StringUtils.format("{}-{}.json", language, mcVersion); -// -// Files.createDirectories(CACHE_DIR); -// Path langCachePath = CACHE_DIR.resolve(fileName); -// -// // If a valid cached file exists, use it. -// if (Files.exists(langCachePath)) { -// try { -// JsonNode root = JSON_MAPPER.readTree(Files.newBufferedReader(langCachePath, StandardCharsets.UTF_8)); -// minecraftTranslations.putAll(JSON_MAPPER.convertValue(root, new TypeReference>() { -// })); -// -// LOGGER.info("Loaded Minecraft translations from cache for version {}", mcVersion); -// return true; -// } catch (Exception e) { -// LOGGER.error("Failed to read cached Minecraft translations, will attempt to re-download", e); -// } -// } -// -// // Otherwise, download the file. -// LOGGER.info("Downloading Minecraft translations for version {}...", mcVersion); -// String url = "https://cdn.jsdelivr.net/gh/InventivetalentDev/minecraft-assets@" + mcVersion + "/assets/minecraft/lang/" + language + ".json"; -// Request request = new Request.Builder().url(url).build(); -// -// try (Response response = OK_HTTP_CLIENT.newCall(request).execute()) { -// if (!response.isSuccessful()) { -// LOGGER.error("Failed to download Minecraft translations. HTTP Status: {}", response.code()); -// return false; -// } -// -// String jsonContent = response.body().string(); -// Files.writeString(langCachePath, jsonContent); -// -// JsonNode root = JSON_MAPPER.readTree(jsonContent); -// minecraftTranslations.putAll(JSON_MAPPER.convertValue(root, new TypeReference>() { -// })); -// -// LOGGER.info("Downloaded and cached Minecraft translations, file size: {} bytes", jsonContent.length()); -// return true; -// } -// } catch (IOException e) { -// LOGGER.error("Failed to load or download Minecraft translations", e); -// } -// -// return false; -// } - /** * Gets a translation from DMCC's internal translation files (lang/*.yml). * Placeholders are formatted using {}. @@ -286,25 +221,6 @@ public class I18nManager { return customMessages; } -// /** -// * Gets a translation from the official Minecraft translation files. -// * Placeholders are formatted using %s or %1$s. -// * -// * @param key The translation key (e.g., "death.attack.drown"). -// * @param args The arguments to format into the string. -// * @return The formatted translation string, or the key if not found. -// */ -// public static String getMinecraftTranslation(String key, Object... args) { -// String translation = minecraftTranslations.getOrDefault(key, key); -// try { -// // MessageFormat handles both %s and %1$s style placeholders -// return MessageFormat.format(translation.replace("'", "''"), args); -// } catch (IllegalArgumentException e) { -// LOGGER.warn("Failed to format Minecraft translation for key \"{}\": {}", key, e.getMessage()); -// return translation; // Return unformatted string on error -// } -// } - /** * Recursively flattens a JsonNode object into a Map with dot-separated keys. *