From c51da28e3120c782e557722e5573c259ad31f65d Mon Sep 17 00:00:00 2001 From: yushijinhun Date: Sat, 6 Oct 2018 12:06:31 +0800 Subject: [PATCH] Add error message for authlib-injector download failure --- .../hmcl/ui/account/AddAccountPane.java | 3 ++ .../resources/assets/lang/I18N.properties | 1 + .../resources/assets/lang/I18N_zh.properties | 1 + .../assets/lang/I18N_zh_CN.properties | 1 + .../AuthlibInjectorAccount.java | 2 +- .../AuthlibInjectorDownloadException.java | 41 +++++++++++++++++++ 6 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorDownloadException.java diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AddAccountPane.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AddAccountPane.java index c4aeb0b3a..6277b9129 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AddAccountPane.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AddAccountPane.java @@ -31,6 +31,7 @@ import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.scene.layout.StackPane; import org.jackhuang.hmcl.auth.*; +import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorDownloadException; import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorServer; import org.jackhuang.hmcl.auth.yggdrasil.GameProfile; import org.jackhuang.hmcl.auth.yggdrasil.RemoteAuthenticationException; @@ -278,6 +279,8 @@ public class AddAccountPane extends StackPane { return i18n("account.failed.invalid_password"); } return exception.getMessage(); + } else if (exception instanceof AuthlibInjectorDownloadException) { + return i18n("account.failed.injector_download_failure"); } else { return exception.getClass().getName() + ": " + exception.getLocalizedMessage(); } diff --git a/HMCL/src/main/resources/assets/lang/I18N.properties b/HMCL/src/main/resources/assets/lang/I18N.properties index 6bb09f2d4..7a973939b 100644 --- a/HMCL/src/main/resources/assets/lang/I18N.properties +++ b/HMCL/src/main/resources/assets/lang/I18N.properties @@ -36,6 +36,7 @@ account.create=Create a new account account.email=Email account.failed.connect_authentication_server=Cannot connect to the authentication server. Check your network. account.failed.connect_injector_server=Cannot connect to the authentication server. Check your network and ensure the URL is correct. +account.failed.injector_download_failure=Failed to download authlib-injector. Check your network and try switching to another download source. account.failed.invalid_credentials=Incorrect password, or you are forbidden to login temporarily. account.failed.invalid_password=Invalid password account.failed.invalid_token=Please log out and re-input your password to login. diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh.properties b/HMCL/src/main/resources/assets/lang/I18N_zh.properties index 17506a248..9e046b8af 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh.properties @@ -36,6 +36,7 @@ account.create=建立帳戶 account.email=電子信箱 account.failed.connect_authentication_server=無法連接認證伺服器,可能是網路問題 account.failed.connect_injector_server=無法連接認證伺服器,可能是網路故障或 URL 輸入錯誤 +account.failed.injector_download_failure=無法下載 authlib-injector,請檢查網路或嘗試切換下載源 account.failed.invalid_credentials=您的使用者名稱或密碼錯誤,或者登入次數過多被暫時禁止登入,請稍後再試 account.failed.invalid_password=無效的密碼 account.failed.invalid_token=請嘗試登出並重新輸入密碼登入 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 62841461a..c711a6006 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties @@ -36,6 +36,7 @@ account.create=新建账户 account.email=邮箱 account.failed.connect_authentication_server=无法连接认证服务器,可能是网络问题 account.failed.connect_injector_server=无法连接认证服务器,可能是网络故障或 URL 输入错误 +account.failed.injector_download_failure=无法下载 authlib-injector,请检查网络或尝试切换下载源 account.failed.invalid_credentials=您的用户名或密码错误,或者登录次数过多被暂时禁止登录,请稍后再试 account.failed.invalid_password=无效的密码 account.failed.invalid_token=请尝试登出并重新输入密码登录 diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorAccount.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorAccount.java index f8d6b9761..4d95fb41d 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorAccount.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorAccount.java @@ -69,7 +69,7 @@ public class AuthlibInjectorAccount extends YggdrasilAccount { try { return authlibInjectorDownloader.get(); } catch (IOException e) { - throw new CompletionException(new AuthenticationException("Failed to download authlib-injector", e)); + throw new CompletionException(new AuthlibInjectorDownloadException(e)); } }); diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorDownloadException.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorDownloadException.java new file mode 100644 index 000000000..3b8dd3683 --- /dev/null +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorDownloadException.java @@ -0,0 +1,41 @@ +/* + * Hello Minecraft! Launcher. + * Copyright (C) 2018 huangyuhui + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see {http://www.gnu.org/licenses/}. + */ +package org.jackhuang.hmcl.auth.authlibinjector; + +import org.jackhuang.hmcl.auth.AuthenticationException; + +/** + * @author yushijinhun + */ +public class AuthlibInjectorDownloadException extends AuthenticationException { + + public AuthlibInjectorDownloadException() { + } + + public AuthlibInjectorDownloadException(String message, Throwable cause) { + super(message, cause); + } + + public AuthlibInjectorDownloadException(String message) { + super(message); + } + + public AuthlibInjectorDownloadException(Throwable cause) { + super(cause); + } +}