diff --git a/core/src/main/java/com/xujiayao/discord_mc_chat/commands/impl/ConsoleCommand.java b/core/src/main/java/com/xujiayao/discord_mc_chat/commands/impl/ConsoleCommand.java index df362e12..80a2ce90 100644 --- a/core/src/main/java/com/xujiayao/discord_mc_chat/commands/impl/ConsoleCommand.java +++ b/core/src/main/java/com/xujiayao/discord_mc_chat/commands/impl/ConsoleCommand.java @@ -247,7 +247,7 @@ public class ConsoleCommand implements Command { } else { String[] lines = response.response.split("\n"); for (String line : lines) { - sender.reply("[" + serverName + "] " + line); + sender.reply(I18nManager.getDmccTranslation("commands.remote_result_prefix", serverName, line)); } } } catch (Exception e) { diff --git a/core/src/main/java/com/xujiayao/discord_mc_chat/commands/impl/ExecuteCommand.java b/core/src/main/java/com/xujiayao/discord_mc_chat/commands/impl/ExecuteCommand.java index 07887858..ded3f4a5 100644 --- a/core/src/main/java/com/xujiayao/discord_mc_chat/commands/impl/ExecuteCommand.java +++ b/core/src/main/java/com/xujiayao/discord_mc_chat/commands/impl/ExecuteCommand.java @@ -172,11 +172,11 @@ public class ExecuteCommand implements Command { } else { // Terminal: send result directly if (response.fileData != null && response.fileName != null) { - sender.replyWithFile("[" + serverName + "] " + response.response, response.fileData, response.fileName); + sender.replyWithFile(I18nManager.getDmccTranslation("commands.remote_result_prefix", serverName, response.response), response.fileData, response.fileName); } else { String[] lines = response.response.split("\n"); for (String line : lines) { - sender.reply("[" + serverName + "] " + line); + sender.reply(I18nManager.getDmccTranslation("commands.remote_result_prefix", serverName, line)); } } } diff --git a/core/src/main/java/com/xujiayao/discord_mc_chat/server/ServerHandler.java b/core/src/main/java/com/xujiayao/discord_mc_chat/server/ServerHandler.java index 18bb8d80..7e4b41ff 100644 --- a/core/src/main/java/com/xujiayao/discord_mc_chat/server/ServerHandler.java +++ b/core/src/main/java/com/xujiayao/discord_mc_chat/server/ServerHandler.java @@ -106,7 +106,7 @@ public class ServerHandler extends SimpleChannelInboundHandler { DiscordManager.clientBroadcast(clientName, "player.die", "player.die", false, p.placeholders); case PLAYER_ADVANCEMENT -> DiscordManager.clientBroadcast(clientName, "player.advancement", "player.advancement." + p.placeholders.get("type"), false, p.placeholders); - // Unhandled events + // TODO Unhandled events default -> LOGGER.warn("Received MinecraftEventPacket from authenticated client {}: type={}, placeholders={}", clientName, p.type, p.placeholders); } diff --git a/core/src/main/java/com/xujiayao/discord_mc_chat/server/discord/DiscordManager.java b/core/src/main/java/com/xujiayao/discord_mc_chat/server/discord/DiscordManager.java index 666e1375..106b4893 100644 --- a/core/src/main/java/com/xujiayao/discord_mc_chat/server/discord/DiscordManager.java +++ b/core/src/main/java/com/xujiayao/discord_mc_chat/server/discord/DiscordManager.java @@ -221,7 +221,7 @@ public class DiscordManager { try { doUpdateBotPresence(enableStatus, enableActivity); } catch (Exception e) { - LOGGER.warn("Failed to update bot presence: " + e.getMessage()); + LOGGER.warn(I18nManager.getDmccTranslation("discord.manager.presence_update_failed", e.getMessage())); } }, 0, 30, TimeUnit.SECONDS); } diff --git a/core/src/main/java/com/xujiayao/discord_mc_chat/server/linking/OpSyncManager.java b/core/src/main/java/com/xujiayao/discord_mc_chat/server/linking/OpSyncManager.java index ecffa671..c0fcf2e1 100644 --- a/core/src/main/java/com/xujiayao/discord_mc_chat/server/linking/OpSyncManager.java +++ b/core/src/main/java/com/xujiayao/discord_mc_chat/server/linking/OpSyncManager.java @@ -9,6 +9,7 @@ import com.xujiayao.discord_mc_chat.utils.config.ConfigManager; import com.xujiayao.discord_mc_chat.utils.config.ModeManager; import com.xujiayao.discord_mc_chat.utils.events.CoreEvents; import com.xujiayao.discord_mc_chat.utils.events.EventManager; +import com.xujiayao.discord_mc_chat.utils.i18n.I18nManager; import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.User; @@ -117,7 +118,7 @@ public class OpSyncManager { return OpLevelResolver.resolve(member, user); } } catch (Exception e) { - LOGGER.warn("Failed to resolve OP level for Discord user {}: {}", discordId, e.getMessage()); + LOGGER.warn(I18nManager.getDmccTranslation("linking.op_sync.resolve_failed", discordId, e.getMessage())); return -1; } } diff --git a/core/src/main/resources/lang/en_us.yml b/core/src/main/resources/lang/en_us.yml index ba9d066f..3e32e12e 100644 --- a/core/src/main/resources/lang/en_us.yml +++ b/core/src/main/resources/lang/en_us.yml @@ -17,6 +17,7 @@ commands: execution_failed: "Command execution failed: {}" invalid_usage: "Invalid usage. Correct usage: \"{}\"" insufficient_permission: "You do not have enough permissions to execute this command." + remote_result_prefix: "[{}] {}" console: description: "Execute a Minecraft command" args_desc: @@ -172,6 +173,7 @@ discord: registering_commands: "Registering Discord DMCC commands. This may take a while... (should be within 1 minute)" commands_success: "Discord DMCC commands registered successfully!" commands_failed: "Failed to register Discord DMCC commands." + presence_update_failed: "Failed to update bot presence: {}" channel_not_found: "Discord text channel not found: \"{}\"" channel_cannot_talk: "Cannot send messages in Discord text channel: \"{}\"" insufficient_permission: "Discord bot has insufficient permissions in channel {}: \"{}\"" @@ -293,6 +295,8 @@ linking: generated: "Generated account linking verification code for Minecraft player {}." refreshed: "Refreshed account linking verification code validity for Minecraft player {}." consumed: "Minecraft player {} completed account linking." + op_sync: + resolve_failed: "Failed to resolve OP level for Discord user {}: {}" message: not_linked_1: "You are not linked to a Discord user. Use " not_linked_2: " command on Discord to complete linking. The code expires in 5 minutes. Run " diff --git a/core/src/main/resources/lang/zh_cn.yml b/core/src/main/resources/lang/zh_cn.yml index 464d5a82..79109621 100644 --- a/core/src/main/resources/lang/zh_cn.yml +++ b/core/src/main/resources/lang/zh_cn.yml @@ -17,6 +17,7 @@ commands: execution_failed: "命令执行失败:{}" invalid_usage: "用法错误。正确用法:\"{}\"" insufficient_permission: "你没有足够的权限执行此命令。" + remote_result_prefix: "[{}] {}" console: description: "执行 Minecraft 命令" args_desc: @@ -172,6 +173,7 @@ discord: registering_commands: "正在注册 Discord DMCC 命令。这可能需要一段时间...(理应在 1 分钟以内)" commands_success: "Discord DMCC 命令注册成功!" commands_failed: "注册 Discord DMCC 命令失败。" + presence_update_failed: "更新机器人状态失败:{}" channel_not_found: "未找到 Discord 文字频道:\"{}\"" channel_cannot_talk: "无法在 Discord 文字频道中发送消息:\"{}\"" insufficient_permission: "Discord 机器人在频道 {} 中权限不足:\"{}\"" @@ -293,6 +295,8 @@ linking: generated: "已为 Minecraft 玩家 {} 生成账户绑定验证码。" refreshed: "已刷新 Minecraft 玩家 {} 的账户绑定验证码有效期。" consumed: "Minecraft 玩家 {} 完成了账户绑定。" + op_sync: + resolve_failed: "解析 Discord 用户 {} 的 OP 等级失败:{}" message: not_linked_1: "你尚未绑定 Discord 用户。在 Discord 上使用 " not_linked_2: " 命令完成绑定。验证码将在 5 分钟后过期,届时可在游戏内执行 "