diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/AuthlibInjectorServersPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/AuthlibInjectorServersPage.java index 157c5bda0..52420423f 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/AuthlibInjectorServersPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/AuthlibInjectorServersPage.java @@ -20,6 +20,8 @@ import org.jackhuang.hmcl.util.NetworkUtils; import static java.util.stream.Collectors.toList; +import java.io.IOException; + public class AuthlibInjectorServersPage extends StackPane implements DecoratorPage { private final StringProperty title = new SimpleStringProperty(this, "title", Launcher.i18n("account.injector.server")); @@ -108,7 +110,7 @@ public class AuthlibInjectorServersPage extends StackPane implements DecoratorPa transitionHandler.setContent(confirmServerPane, ContainerAnimations.SWIPE_LEFT.getAnimationProducer()); } else { - lblCreationWarning.setText(variables.get("lastException").getLocalizedMessage()); + lblCreationWarning.setText(resolveFetchExceptionMessage(variables.get("lastException"))); } }).start(); @@ -147,4 +149,12 @@ public class AuthlibInjectorServersPage extends StackPane implements DecoratorPa } return url; } + + private String resolveFetchExceptionMessage(Throwable exception) { + if (exception instanceof IOException) { + return Launcher.i18n("account.failed.connect_injector_server"); + } else { + return exception.getClass() + ": " + exception.getLocalizedMessage(); + } + } } diff --git a/HMCL/src/main/resources/assets/lang/I18N.properties b/HMCL/src/main/resources/assets/lang/I18N.properties index ce380d777..0874ae9ed 100644 --- a/HMCL/src/main/resources/assets/lang/I18N.properties +++ b/HMCL/src/main/resources/assets/lang/I18N.properties @@ -40,6 +40,7 @@ account.failed.invalid_password=Invalid password account.failed.invalid_token=Please log out and re-input your password to log in. account.failed.no_charactor=No character in this account. account.failed.no_selected_server=No authentication server is selected. +account.failed.connect_injector_server=Cannot connect to the authentication server. Check your network and ensure the URL is correct. account.injector.add=Add authentication server account.injector.manage=Manage authentication servers account.injector.http=Warning: This server is using HTTP, which will cause your password be transmitted in clear text. 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 2473ea9ac..4838cdb7b 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties @@ -40,6 +40,7 @@ account.failed.invalid_password=无效的密码 account.failed.invalid_token=请尝试登出并重新输入密码登录 account.failed.no_charactor=该帐号没有角色 account.failed.no_selected_server=未选择认证服务器 +account.failed.connect_injector_server=无法连接认证服务器,可能是网络故障或 URL 输入错误 account.injector.add=添加认证服务器 account.injector.manage=管理认证服务器 account.injector.http=警告:此服务器使用不安全的http协议,您的密码在登录时会被明文传输。