diff --git a/HMCL/src/main/java/cn/pigeon/update/exception/AccountTypeErrorException.java b/HMCL/src/main/java/cn/pigeon/update/exception/AccountTypeErrorException.java new file mode 100644 index 0000000000..e8b753873a --- /dev/null +++ b/HMCL/src/main/java/cn/pigeon/update/exception/AccountTypeErrorException.java @@ -0,0 +1,9 @@ +package cn.pigeon.update.exception; + +import java.io.IOException; + +public class AccountTypeErrorException extends IOException { + + public AccountTypeErrorException() { + } +} diff --git a/HMCL/src/main/java/cn/pigeon/update/tasks/api/CheckUpdateTask.java b/HMCL/src/main/java/cn/pigeon/update/tasks/api/CheckUpdateTask.java index 5c074a3b76..7b5a1c8e1a 100644 --- a/HMCL/src/main/java/cn/pigeon/update/tasks/api/CheckUpdateTask.java +++ b/HMCL/src/main/java/cn/pigeon/update/tasks/api/CheckUpdateTask.java @@ -11,6 +11,7 @@ import okhttp3.Response; import okhttp3.ResponseBody; import org.jackhuang.hmcl.auth.Account; +import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilAccount; import org.jackhuang.hmcl.task.Task; import org.jackhuang.hmcl.util.gson.JsonUtils; @@ -30,9 +31,9 @@ public class CheckUpdateTask extends Task { private final File configFile; private final Token token; - public CheckUpdateTask(Account account, String packName, Token token, File configFile) { + public CheckUpdateTask(YggdrasilAccount account, String packName, Token token, File configFile) { this.uuid = account.getUUID().toString().replace("-", ""); - this.username = account.getUsername(); + this.username = account.getCharacter(); this.packName = packName; this.configFile = configFile; this.token = token; diff --git a/HMCL/src/main/java/cn/pigeon/update/tasks/api/GetTokenTask.java b/HMCL/src/main/java/cn/pigeon/update/tasks/api/GetTokenTask.java index 705321513d..5ff5907398 100644 --- a/HMCL/src/main/java/cn/pigeon/update/tasks/api/GetTokenTask.java +++ b/HMCL/src/main/java/cn/pigeon/update/tasks/api/GetTokenTask.java @@ -10,6 +10,7 @@ import okhttp3.Response; import okhttp3.ResponseBody; import org.jackhuang.hmcl.auth.Account; +import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilAccount; import org.jackhuang.hmcl.task.Task; import org.jackhuang.hmcl.util.gson.JsonUtils; @@ -24,10 +25,12 @@ public class GetTokenTask extends Task { private static Token token = null; private final String username; private final String uuid; + private final String packName; - public GetTokenTask(Account account) { - this.username = account.getUsername(); + public GetTokenTask(YggdrasilAccount account, String packName) { + this.username = account.getCharacter(); this.uuid = account.getUUID().toString().replace("-", ""); + this.packName = packName; } @Override @@ -50,6 +53,7 @@ public void getAccessToken() throws IOException { builder.addQueryParameter("macAddress", Utils.getMacAddress()); builder.addQueryParameter("username", username); builder.addQueryParameter("uuid", uuid); + builder.addQueryParameter("packName", packName); updateProgress(2, 5); String url = builder.build().toString(); Request request = new Request.Builder() diff --git a/HMCL/src/main/java/cn/pigeon/update/utils/Utils.java b/HMCL/src/main/java/cn/pigeon/update/utils/Utils.java index 0fb177764e..f47a94ecdc 100644 --- a/HMCL/src/main/java/cn/pigeon/update/utils/Utils.java +++ b/HMCL/src/main/java/cn/pigeon/update/utils/Utils.java @@ -4,6 +4,7 @@ import cn.pigeon.update.data.Token; import okhttp3.HttpUrl; import org.jackhuang.hmcl.auth.Account; +import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilAccount; import javax.xml.bind.DatatypeConverter; import java.io.*; @@ -139,8 +140,8 @@ public static void listFiles(File file, ArrayList fileArrayList) { } } - public static HttpUrl.Builder getBaseUrl(Account account, Token token, String packName) { - final String username = account.getUsername(); + public static HttpUrl.Builder getBaseUrl(YggdrasilAccount account, Token token, String packName) { + final String username = account.getCharacter(); final String uuid = account.getUUID().toString().replace("-", ""); final String accessToken = token.key; HttpUrl.Builder builder = Objects.requireNonNull(HttpUrl.parse(config().getBaseUrl())).newBuilder(); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java b/HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java index d8024bdb43..ed6ddb8e44 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java @@ -17,7 +17,7 @@ */ package org.jackhuang.hmcl.game; -import cn.pigeon.update.Static; +import cn.pigeon.update.exception.AccountTypeErrorException; import cn.pigeon.update.exception.HttpRequestException; import cn.pigeon.update.tasks.DownloadRequireFileTask; import cn.pigeon.update.tasks.VerifyFiles; @@ -31,6 +31,7 @@ import org.jackhuang.hmcl.Launcher; import org.jackhuang.hmcl.auth.*; import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorDownloadException; +import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilAccount; import org.jackhuang.hmcl.download.DefaultDependencyManager; import org.jackhuang.hmcl.download.DownloadProvider; import org.jackhuang.hmcl.download.LibraryAnalyzer; @@ -71,7 +72,6 @@ import java.util.stream.Collectors; import static org.jackhuang.hmcl.setting.ConfigHolder.config; -import static org.jackhuang.hmcl.task.FetchTask.DEFAULT_CONCURRENCY; import static org.jackhuang.hmcl.ui.FXUtils.runInFX; import static org.jackhuang.hmcl.util.Lang.resolveException; import static org.jackhuang.hmcl.util.Logging.LOG; @@ -511,13 +511,16 @@ private void launch0() { pigeon.mkdir(); } File configFile = new File(pigeon, "config.json"); - return new GetTokenTask(account) + if (!(account instanceof YggdrasilAccount)) { + throw new AccountTypeErrorException(); + } + return new GetTokenTask((YggdrasilAccount) account, version.get().getId()) .setName("Get Access Key") - .thenComposeAsync(token -> new CheckUpdateTask(account, + .thenComposeAsync(token -> new CheckUpdateTask((YggdrasilAccount) account, version.get().getId(), token, configFile) .setName("Check Update") .thenComposeAsync(() -> { - HttpUrl.Builder builder = Utils.getBaseUrl(account, token, version.get().getId()); + HttpUrl.Builder builder = Utils.getBaseUrl((YggdrasilAccount) account, token, version.get().getId()); VerifyFiles verifyFiles = new VerifyFiles(configFile, rootPath.toPath()); Map requireModFile = verifyFiles.verifyFile(); Map urls = Utils.prepareForDownload(builder, requireModFile); @@ -572,6 +575,7 @@ private void launch0() { .thenComposeAsync(() -> gameVersion.map(s -> new GameVerificationFixTask(dependencyManager, s, version.get())).orElse(null)) .thenComposeAsync(() -> logIn(account).withStage("launch.state.logging_in")) .thenComposeAsync(authInfo -> Task.supplyAsync(() -> { + setting.setJavaArgs("-Dhmcl.version=hmcl-3.5liteUI -Dstart.time=" + System.currentTimeMillis()); LaunchOptions launchOptions = repository.getLaunchOptions(selectedVersion, javaVersionRef.get(), profile.getGameDir(), javaAgents, scriptFile != null); return new HMCLGameLauncher( repository, @@ -640,6 +644,8 @@ public void onStop(boolean success, TaskExecutor executor) { message = i18n("modpack.type.curse.error"); } else if (ex instanceof HttpRequestException) { message = String.format("Http code: %d\n%s", ((HttpRequestException) ex).httpCode, ex.getMessage()); + } else if (ex instanceof AccountTypeErrorException) { + message = i18n("lunch.failed.account.type.error"); } else if (ex instanceof PermissionException) { message = i18n("launch.failed.executable_permission"); } else if (ex instanceof ProcessCreationException) { diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java b/HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java index d88f91bc10..c7e92cc1f3 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java @@ -177,7 +177,7 @@ public static Config fromJson(String json) throws JsonParseException { @SerializedName("_version") private IntegerProperty configVersion = new SimpleIntegerProperty(0); @SerializedName("baseUrl") - private StringProperty baseUrl = new SimpleStringProperty(""); + private StringProperty baseUrl = new SimpleStringProperty("https://sbi.pigeon-server.cn"); /** * The version of UI that the user have last used. diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorSkin.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorSkin.java index c67e908672..db54f85dcc 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorSkin.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorSkin.java @@ -200,7 +200,7 @@ public DecoratorSkin(Decorator control) { JFXButton btnHelp = new JFXButton(); btnHelp.setGraphic(SVG.HELP_CIRCLE_OUTLINE.createIcon(Theme.foregroundFillBinding(), -1, -1)); btnHelp.getStyleClass().add("jfx-decorator-button"); - btnHelp.setOnAction(e -> FXUtils.openLink("https://docs.hmcl.net/help.html")); + btnHelp.setOnAction(e -> FXUtils.openLink("https://docs.pigeon-server.cn/")); JFXButton btnMin = new JFXButton(); StackPane pane = new StackPane(minus); diff --git a/HMCL/src/main/resources/assets/lang/I18N.properties b/HMCL/src/main/resources/assets/lang/I18N.properties index 546620ffb5..a51e927ae4 100644 --- a/HMCL/src/main/resources/assets/lang/I18N.properties +++ b/HMCL/src/main/resources/assets/lang/I18N.properties @@ -25,6 +25,7 @@ settings.launcher.pigeon.download.hint=This setting affects only the maximum num update.download.config=Update configuration file launch.state.mods=Check modules and configuration files agreement.privacy=Privacy agreement +lunch.failed.account.type.error=This initiator supports only external login about=About about.copyright=Copyright diff --git a/HMCL/src/main/resources/assets/lang/I18N_es.properties b/HMCL/src/main/resources/assets/lang/I18N_es.properties index 4864699102..16b3160b54 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_es.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_es.properties @@ -25,6 +25,7 @@ settings.launcher.pigeon.download.hint=Este ajuste solo afecta al máximo de hil update.download.config=Actualizar tu perfil launch.state.mods=Revisión de mods y perfiles agreement.privacy=Acuerdo de privacidad +lunch.failed.account.type.error=Este lanzador solo admite login externo about=Acerca de diff --git a/HMCL/src/main/resources/assets/lang/I18N_ja.properties b/HMCL/src/main/resources/assets/lang/I18N_ja.properties index b7c63f2df4..f9d02d0cbd 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_ja.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_ja.properties @@ -24,6 +24,7 @@ settings.launcher.pigeon.download.hint=この設定はランチャー最大の update.download.config=プロファイルを更新します launch.state.mods=モジュールとプロファイルをチェックします agreement.privacy=プライバシー協定です +lunch.failed.account.type.error=本ランチャーは外付けログインのみ対応しています。 about=About about.copyright=著作権 diff --git a/HMCL/src/main/resources/assets/lang/I18N_ru.properties b/HMCL/src/main/resources/assets/lang/I18N_ru.properties index 50b96de3a9..bad60338d2 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_ru.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_ru.properties @@ -24,6 +24,7 @@ settings.launcher.pigeon.download.hint=Эта настройка влияет т update.download.config=Обновить профиль launch.state.mods=Проверьте модули и профили agreement.privacy=Соглашение о конфиденциальности +lunch.failed.account.type.error=Стартер бена поддерживает только внешний вход about=О лаунчере about.copyright=Авторские права diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh.properties b/HMCL/src/main/resources/assets/lang/I18N_zh.properties index 03a2c1e330..e7f55635f3 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh.properties @@ -24,6 +24,7 @@ settings.launcher.pigeon.download.hint=此設置只影響啟動器最大的下 update.download.config=更新配置文件 launch.state.mods=檢查模組和配置文件 agreement.privacy=隱私協議 +lunch.failed.account.type.error=本啟動器只支持外置登錄 about=關於 about.copyright=著作權 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 9b7460517a..68824d7e16 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties @@ -24,6 +24,7 @@ settings.launcher.pigeon.download.hint=此设置只影响启动器最大的下 update.download.config=更新配置文件 launch.state.mods=检查模组和配置文件 agreement.privacy=隐私协议 +lunch.failed.account.type.error=本启动器只支持外置登录 about=关于 about.copyright=版权