Skip to content

Commit

Permalink
2023.09.30-2
Browse files Browse the repository at this point in the history
1.增加自定义jvm参数
2.修复bug:无法用邮箱登录
3.增加异常处理
  • Loading branch information
half-nothing committed Sep 30, 2023
1 parent 17f478b commit 926429a
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package cn.pigeon.update.exception;

import java.io.IOException;

public class AccountTypeErrorException extends IOException {

public AccountTypeErrorException() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -30,9 +31,9 @@ public class CheckUpdateTask extends Task<SyncMode[]> {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -24,10 +25,12 @@ public class GetTokenTask extends Task<Token> {
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
Expand All @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions HMCL/src/main/java/cn/pigeon/update/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -139,8 +140,8 @@ public static void listFiles(File file, ArrayList<File> 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();
Expand Down
16 changes: 11 additions & 5 deletions HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<File, String> requireModFile = verifyFiles.verifyFile();
Map<URL, File> urls = Utils.prepareForDownload(builder, requireModFile);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions HMCL/src/main/resources/assets/lang/I18N.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions HMCL/src/main/resources/assets/lang/I18N_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions HMCL/src/main/resources/assets/lang/I18N_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=著作権
Expand Down
1 change: 1 addition & 0 deletions HMCL/src/main/resources/assets/lang/I18N_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=Авторские права
Expand Down
1 change: 1 addition & 0 deletions HMCL/src/main/resources/assets/lang/I18N_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=著作權
Expand Down
1 change: 1 addition & 0 deletions HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=版权
Expand Down

0 comments on commit 926429a

Please sign in to comment.