Friendly prompt that it cannot download some libraries successfully.
This commit is contained in:
@@ -25,6 +25,7 @@ import org.jackhuang.hmcl.auth.AuthenticationException;
|
|||||||
import org.jackhuang.hmcl.auth.CredentialExpiredException;
|
import org.jackhuang.hmcl.auth.CredentialExpiredException;
|
||||||
import org.jackhuang.hmcl.download.DefaultDependencyManager;
|
import org.jackhuang.hmcl.download.DefaultDependencyManager;
|
||||||
import org.jackhuang.hmcl.download.MaintainTask;
|
import org.jackhuang.hmcl.download.MaintainTask;
|
||||||
|
import org.jackhuang.hmcl.download.game.LibraryDownloadException;
|
||||||
import org.jackhuang.hmcl.launch.*;
|
import org.jackhuang.hmcl.launch.*;
|
||||||
import org.jackhuang.hmcl.mod.CurseCompletionException;
|
import org.jackhuang.hmcl.mod.CurseCompletionException;
|
||||||
import org.jackhuang.hmcl.mod.CurseCompletionTask;
|
import org.jackhuang.hmcl.mod.CurseCompletionTask;
|
||||||
@@ -190,6 +191,8 @@ public final class LauncherHelper {
|
|||||||
message = i18n("launch.failed.creating_process") + ex.getLocalizedMessage();
|
message = i18n("launch.failed.creating_process") + ex.getLocalizedMessage();
|
||||||
} else if (ex instanceof NotDecompressingNativesException) {
|
} else if (ex instanceof NotDecompressingNativesException) {
|
||||||
message = i18n("launch.failed.decompressing_natives") + ex.getLocalizedMessage();
|
message = i18n("launch.failed.decompressing_natives") + ex.getLocalizedMessage();
|
||||||
|
} else if (ex instanceof LibraryDownloadException) {
|
||||||
|
message = i18n("launch.failed.download_library", ((LibraryDownloadException) ex).getLibrary().getName()) + "\n" + StringUtils.getStackTrace(ex.getCause());
|
||||||
} else {
|
} else {
|
||||||
message = StringUtils.getStackTrace(ex);
|
message = StringUtils.getStackTrace(ex);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ launch.failed=Unable to launch
|
|||||||
launch.failed.cannot_create_jvm=Java virtual machine cannot be created. Java arguments may have problems. You can enable the no args mode in the settings.
|
launch.failed.cannot_create_jvm=Java virtual machine cannot be created. Java arguments may have problems. You can enable the no args mode in the settings.
|
||||||
launch.failed.creating_process=Failed to create process, maybe your java path is wrong, please modify your java path.
|
launch.failed.creating_process=Failed to create process, maybe your java path is wrong, please modify your java path.
|
||||||
launch.failed.decompressing_natives=Unable to decompress native libraries.
|
launch.failed.decompressing_natives=Unable to decompress native libraries.
|
||||||
|
launch.failed.download_library=Unable to download library %s.
|
||||||
launch.failed.executable_permission=Unable to add permission to the launch script
|
launch.failed.executable_permission=Unable to add permission to the launch script
|
||||||
launch.failed.exited_abnormally=Game exited abnormally, please visit the log, or ask someone for help.
|
launch.failed.exited_abnormally=Game exited abnormally, please visit the log, or ask someone for help.
|
||||||
launch.state.dependencies=Dependencies
|
launch.state.dependencies=Dependencies
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ launch.failed=啓動失敗
|
|||||||
launch.failed.cannot_create_jvm=截獲到無法創建 Java 虛擬機,可能是 Java 參數有問題,可以在設置中開啓無參數模式啓動。
|
launch.failed.cannot_create_jvm=截獲到無法創建 Java 虛擬機,可能是 Java 參數有問題,可以在設置中開啓無參數模式啓動。
|
||||||
launch.failed.creating_process=啓動失敗,在創建新進程時發生錯誤,可能是 Java 路徑錯誤。
|
launch.failed.creating_process=啓動失敗,在創建新進程時發生錯誤,可能是 Java 路徑錯誤。
|
||||||
launch.failed.decompressing_natives=未能解壓遊戲本地庫。
|
launch.failed.decompressing_natives=未能解壓遊戲本地庫。
|
||||||
|
launch.failed.download_library=未能下载游戏依赖 %s.
|
||||||
launch.failed.executable_permission=未能爲啓動文件添加執行權限。
|
launch.failed.executable_permission=未能爲啓動文件添加執行權限。
|
||||||
launch.failed.exited_abnormally=遊戲非正常退出,請查看日志文件,或聯繫他人尋求幫助。
|
launch.failed.exited_abnormally=遊戲非正常退出,請查看日志文件,或聯繫他人尋求幫助。
|
||||||
launch.state.dependencies=正在處理遊戲依賴
|
launch.state.dependencies=正在處理遊戲依賴
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ launch.failed=启动失败
|
|||||||
launch.failed.cannot_create_jvm=截获到无法创建 Java 虚拟机,可能是 Java 参数有问题,可以在设置中开启无参数模式启动。
|
launch.failed.cannot_create_jvm=截获到无法创建 Java 虚拟机,可能是 Java 参数有问题,可以在设置中开启无参数模式启动。
|
||||||
launch.failed.creating_process=启动失败,在创建新进程时发生错误,可能是 Java 路径错误。
|
launch.failed.creating_process=启动失败,在创建新进程时发生错误,可能是 Java 路径错误。
|
||||||
launch.failed.decompressing_natives=未能解压游戏本地库。
|
launch.failed.decompressing_natives=未能解压游戏本地库。
|
||||||
|
launch.failed.download_library=未能下载游戏依赖 %s.
|
||||||
launch.failed.executable_permission=未能为启动文件添加执行权限。
|
launch.failed.executable_permission=未能为启动文件添加执行权限。
|
||||||
launch.failed.exited_abnormally=游戏非正常退出,请查看日志文件,或联系他人寻求帮助。
|
launch.failed.exited_abnormally=游戏非正常退出,请查看日志文件,或联系他人寻求帮助。
|
||||||
launch.state.dependencies=正在处理游戏依赖
|
launch.state.dependencies=正在处理游戏依赖
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Hello Minecraft! Launcher.
|
||||||
|
* Copyright (C) 2017 huangyuhui <huanghongxun2008@126.com>
|
||||||
|
*
|
||||||
|
* 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.download.game;
|
||||||
|
|
||||||
|
import org.jackhuang.hmcl.game.Library;
|
||||||
|
|
||||||
|
public class LibraryDownloadException extends Exception {
|
||||||
|
private final Library library;
|
||||||
|
|
||||||
|
public LibraryDownloadException(Library library, Throwable cause) {
|
||||||
|
super("Unable to download library " + library, cause);
|
||||||
|
|
||||||
|
this.library = library;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Library getLibrary() {
|
||||||
|
return library;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,7 +55,7 @@ public final class LibraryDownloadTask extends Task {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<? extends Task> getDependents() {
|
public Collection<? extends Task> getDependents() {
|
||||||
return library.getChecksums() != null ? Collections.singleton(xzTask) : Collections.emptySet();
|
return library.getChecksums() != null ? Collections.singleton(xzTask) : Collections.singleton(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -65,20 +65,23 @@ public final class LibraryDownloadTask extends Task {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws Exception {
|
public void execute() throws Exception {
|
||||||
if (isDependentsSucceeded() && library.getChecksums() != null) {
|
if (!isDependentsSucceeded()) {
|
||||||
|
// Since FileDownloadTask wraps the actual exception with another IOException.
|
||||||
|
// We should extract it letting the error message clearer.
|
||||||
|
Throwable t = library.getChecksums() != null ? xzTask.getLastException() : task.getLastException();
|
||||||
|
if (t.getCause() != null && t.getCause() != t)
|
||||||
|
throw new LibraryDownloadException(library, t.getCause());
|
||||||
|
else
|
||||||
|
throw new LibraryDownloadException(library, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (library.getChecksums() != null) {
|
||||||
unpackLibrary(jar, FileUtils.readBytes(xzFile));
|
unpackLibrary(jar, FileUtils.readBytes(xzFile));
|
||||||
if (!checksumValid(jar, library.getChecksums()))
|
if (!checksumValid(jar, library.getChecksums()))
|
||||||
throw new IOException("Checksum failed for " + library);
|
throw new IOException("Checksum failed for " + library);
|
||||||
|
|
||||||
downloaded = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<? extends Task> getDependencies() {
|
|
||||||
return downloaded ? Collections.emptySet() : Collections.singleton(task);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean checksumValid(File libPath, List<String> checksums) {
|
private static boolean checksumValid(File libPath, List<String> checksums) {
|
||||||
try {
|
try {
|
||||||
if ((checksums == null) || (checksums.isEmpty())) {
|
if ((checksums == null) || (checksums.isEmpty())) {
|
||||||
|
|||||||
@@ -63,6 +63,16 @@ public abstract class Task {
|
|||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Throwable lastException = null;
|
||||||
|
|
||||||
|
public Throwable getLastException() {
|
||||||
|
return lastException;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setLastException(Throwable e) {
|
||||||
|
lastException = e;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The scheduler that decides how this task runs.
|
* The scheduler that decides how this task runs.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -190,6 +190,7 @@ public final class TaskExecutor {
|
|||||||
} catch (SilentException | RejectedExecutionException e) {
|
} catch (SilentException | RejectedExecutionException e) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
task.setLastException(e);
|
||||||
lastException = e;
|
lastException = e;
|
||||||
variables.set(LAST_EXCEPTION_ID, e);
|
variables.set(LAST_EXCEPTION_ID, e);
|
||||||
if (task.getSignificance().shouldLog()) {
|
if (task.getSignificance().shouldLog()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user