diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/InstallersPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/InstallersPage.java index 2a4124abe..69f254d28 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/InstallersPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/InstallersPage.java @@ -27,7 +27,6 @@ import org.jackhuang.hmcl.ui.construct.MessageDialogPane; import org.jackhuang.hmcl.ui.construct.RequiredValidator; import org.jackhuang.hmcl.ui.construct.Validator; import org.jackhuang.hmcl.ui.wizard.WizardController; -import org.jackhuang.hmcl.util.StringUtils; import java.util.Map; @@ -77,11 +76,24 @@ public class InstallersPage extends AbstractInstallersPage { public void cleanup(Map settings) { } + private static boolean checkName(String name) { + for (int i = 0; i < name.length(); i++) { + char c = name.charAt(i); + if (!(c >= '0' && c <= '9') + && !(c >= 'a' && c <= 'z') + && !(c >= 'A' && c <= 'Z') + && c != '-' && c != '_' && c != '.' + ) + return false; + } + + return true; + } + protected void onInstall() { String name = txtName.getText(); - // Check for non-ASCII characters. - if (!StringUtils.isASCII(name)) { + if (!checkName(name)) { Controllers.dialog(new MessageDialogPane.Builder( i18n("install.name.invalid"), i18n("message.warning"), diff --git a/HMCL/src/main/resources/assets/lang/I18N.properties b/HMCL/src/main/resources/assets/lang/I18N.properties index a53ae90b1..7a075548f 100644 --- a/HMCL/src/main/resources/assets/lang/I18N.properties +++ b/HMCL/src/main/resources/assets/lang/I18N.properties @@ -714,7 +714,7 @@ install.installer.external_version=%s (Installed by external process, which cann install.installing=Installing install.modpack=Install Modpack install.modpack.installation=Modpack Installation -install.name.invalid=The name contains non-ASCII characters (such as emoji or CJK characters).\nIt is recommended to change the name to include only English letters, numbers, and underscores to avoid potential issues when launching the game.\nDo you want to proceed with the installation? +install.name.invalid=The name contains special characters (such as emoji or CJK characters).\nIt is recommended to change the name to include only English letters, numbers, and underscores to avoid potential issues when launching the game.\nDo you want to proceed with the installation? install.new_game=Install Instance install.new_game.already_exists=This instance name already exists. Please use another name. install.new_game.current_game_version=Current Instance Version diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh.properties b/HMCL/src/main/resources/assets/lang/I18N_zh.properties index 23cfd7370..33a9123c1 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh.properties @@ -530,7 +530,7 @@ install.installer.external_version=%s [由外部安裝的版本,無法解除 install.installing=安裝 install.modpack=安裝模組包 install.modpack.installation=安裝模組包 -install.name.invalid=名稱中包含非 ASCII 字元(如 Emoji 表情或中文字元)。\n建議修改名稱。名稱建議僅包含英文字母、數字和底線,以防啟動遊戲時出現問題。是否繼續安裝? +install.name.invalid=名稱中包含特殊字元(如 Emoji 表情或中文字元)。\n建議修改名稱。名稱建議僅包含英文字母、數字和底線,以防啟動遊戲時出現問題。是否繼續安裝? install.new_game=安裝新實例 install.new_game.already_exists=此實例已經存在,請重新命名 install.new_game.current_game_version=目前遊戲實例 diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties index b43556e2f..2ea6f142f 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties @@ -540,7 +540,7 @@ install.installer.external_version=%s (由外部安装的版本,无法卸载 install.installing=安装 install.modpack=安装整合包 install.modpack.installation=安装整合包 -install.name.invalid=名称中包含非 ASCII 字符(如 Emoji 表情或中文字符)。\n建议修改名称。名称建议仅包含英文字母、数字和下划线,以防启动游戏时出现问题。是否继续安装? +install.name.invalid=名称中包含特殊字符(如 Emoji 表情或中文字符)。\n建议修改名称。名称建议仅包含英文字母、数字和下划线,以防启动游戏时出现问题。是否继续安装? install.new_game=安装新游戏 install.new_game.already_exists=此版本已经存在,请换一个名字 install.new_game.current_game_version=当前游戏版本