From 845122a061e07a090f3954b4b67b8adba7565c56 Mon Sep 17 00:00:00 2001 From: Simba98 Date: Thu, 3 Aug 2023 13:42:21 +0800 Subject: [PATCH 1/2] If the translation is not provided, return as-is --- .../main/java/cn/evole/mods/mcbot/util/locale/I18n.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/forge/src/main/java/cn/evole/mods/mcbot/util/locale/I18n.java b/forge/src/main/java/cn/evole/mods/mcbot/util/locale/I18n.java index 44add026..e9f4b138 100644 --- a/forge/src/main/java/cn/evole/mods/mcbot/util/locale/I18n.java +++ b/forge/src/main/java/cn/evole/mods/mcbot/util/locale/I18n.java @@ -83,6 +83,11 @@ public static String get(String key, Object... args) { } public static String get(String key) { - return translations.get(key); + String translation = translations.get(key); + if (translation != null) { + return translation; + } else { + return key; + } } } From 42f60e9fdedd6f2bbe8260dd0299f8b4a2348899 Mon Sep 17 00:00:00 2001 From: Simba98 Date: Thu, 3 Aug 2023 20:29:10 +0800 Subject: [PATCH 2/2] Trim for multiple part command --- .../src/main/java/cn/evole/mods/mcbot/util/onebot/BotUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forge/src/main/java/cn/evole/mods/mcbot/util/onebot/BotUtils.java b/forge/src/main/java/cn/evole/mods/mcbot/util/onebot/BotUtils.java index 1d9e47dc..8bc5bd3c 100644 --- a/forge/src/main/java/cn/evole/mods/mcbot/util/onebot/BotUtils.java +++ b/forge/src/main/java/cn/evole/mods/mcbot/util/onebot/BotUtils.java @@ -48,7 +48,7 @@ private static boolean isVar(String msg) { public static String varParse(CustomCmd customCmd, String cmd) { String returnCmd = ""; if (isVar(cmd)) {//存在变量 - val replaceContent = customCmd.getCmdContent().split("%")[0].replaceAll(" ", ""); + val replaceContent = customCmd.getCmdContent().split("%")[0].trim(); returnCmd = cmd.replace(customCmd.getCmdAlies(), replaceContent);//返回q群指令 } else returnCmd = customCmd.getCmdContent();//返回普通自定义命令指令 return returnCmd;