Compare commits

...
12 changed files with 44 additions and 14 deletions

No files matched your search

+1 -1
View File
@@ -112,7 +112,7 @@ def createExecutable(String suffix, String header) {
processResources {
ext.convertToBSS = { String resource ->
exclude resource
// exclude resource
doFirst {
def cssFile = new File(this.projectDir, "src/main/resources/" + resource)
def bssFile = new File(this.projectDir, "build/compiled-resources/" + resource[0..-4] + "bss")
@@ -22,6 +22,7 @@ import org.jackhuang.hmcl.download.DownloadProvider;
import org.jackhuang.hmcl.download.LibraryAnalyzer;
import org.jackhuang.hmcl.download.RemoteVersion;
import org.jackhuang.hmcl.download.game.LibraryDownloadException;
import org.jackhuang.hmcl.download.optifine.OptiFineInstallTask;
import org.jackhuang.hmcl.game.Library;
import org.jackhuang.hmcl.game.Version;
import org.jackhuang.hmcl.setting.Profile;
@@ -125,6 +126,8 @@ public final class InstallerWizardProvider implements WizardProvider {
Controllers.dialog(i18n("launch.failed.download_library", ((LibraryDownloadException) exception).getLibrary().getName()) + "\n" + StringUtils.getStackTrace(exception.getCause()), i18n("install.failed.downloading"), MessageType.ERROR, next);
} else if (exception instanceof DownloadException) {
Controllers.dialog(i18n("install.failed.downloading.detail", ((DownloadException) exception).getUrl()) + "\n" + StringUtils.getStackTrace(exception.getCause()), i18n("install.failed.downloading"), MessageType.ERROR, next);
} else if (exception instanceof OptiFineInstallTask.UnsupportedOptiFineInstallationException) {
Controllers.dialog(i18n("install.failed.optifine_conflict"), i18n("install.failed"), MessageType.ERROR, next);
} else {
Controllers.dialog(StringUtils.getStackTrace(exception), i18n("install.failed"), MessageType.ERROR, next);
}
@@ -95,7 +95,7 @@ download.failed=Failed to download
download.failed.empty=No candidates. Click here to return.
download.failed.refresh=Unable to load version list. Click here to retry.
download.provider.bmclapi=BMCLAPI (bangbang93, https://bmclapi2.bangbang93.com/)
download.provider.mojang=Mojang
download.provider.mojang=Mojang (Forge and OptiFine installation being downloaded from BMCLAPI)
extension.bat=Windows Bat file
extension.mod=Mod file
@@ -127,6 +127,7 @@ install=Install New Game
install.failed=Failed to install
install.failed.downloading=Failed to install due to some files not downloaded successfully
install.failed.downloading.detail=Failed to download file: %s
install.failed.optifine_conflict=OptiFine and Forge are both installed simultaneously on Minecraft 1.13
install.installer.choose=Choose a %s version
install.installer.forge=Forge
install.installer.game=Game
@@ -94,7 +94,7 @@ download.failed=下載失敗
download.failed.empty=沒有可供安裝的版本,點擊此處返回。
download.failed.refresh=載入版本列表失敗,點擊此處重試。
download.provider.bmclapi=BMCLAPI(bangbang93,https://bmclapi2.bangbang93.com/)
download.provider.mojang=官方伺服器(Mojang)
download.provider.mojang=官方伺服器(Forge 和 OptiFine 自動安裝的下載來源是 BMCLAPI)
extension.bat=Windows 腳本
extension.mod=模組檔案
@@ -126,6 +126,7 @@ install=新增遊戲
install.failed=安裝失敗
install.failed.downloading=安裝失敗,部分文件未能完成下載
install.failed.downloading.detail=未能下載檔案:%s
install.failed.optifine_conflict=暫不支持 OptiFine 與 Forge 同時安裝於 Minecraft 1.13
install.installer.choose=選擇 %s 版本
install.installer.forge=Forge
install.installer.game=遊戲
@@ -94,7 +94,7 @@ download.failed=下载失败
download.failed.empty=没有可供安装的版本,点击此处返回。
download.failed.refresh=加载版本列表失败,点击此处重试。
download.provider.bmclapi=BMCLAPI(bangbang93,https://bmclapi2.bangbang93.com/)
download.provider.mojang=官方(Mojang)
download.provider.mojang=官方(Forge 和 OptiFine 自动安装使用 BMCLAPI 下载源)
extension.bat=Windows 脚本
extension.mod=模组文件
@@ -126,6 +126,7 @@ install=添加游戏
install.failed=安装失败
install.failed.downloading=安装失败,部分文件未能完成下载
install.failed.downloading.detail=未能下载文件:%s
install.failed.optifine_conflict=暂不支持 OptiFine 与 Forge 同时安装于 Minecraft 1.13
install.installer.choose=选择 %s 版本
install.installer.forge=Forge
install.installer.game=游戏
@@ -58,7 +58,8 @@ public final class ForgeInstallTask extends TaskResult<Version> {
public void preExecute() throws Exception {
installer = Files.createTempFile("forge-installer", ".jar");
dependent = new FileDownloadTask(NetworkUtils.toURL(remote.getUrl()), installer.toFile());
dependent = new FileDownloadTask(NetworkUtils.toURL(remote.getUrl()), installer.toFile())
.setCaching(true);
}
@Override
@@ -82,11 +83,6 @@ public final class ForgeInstallTask extends TaskResult<Version> {
return Collections.singleton(dependency);
}
@Override
public boolean isRelyingOnDependencies() {
return false;
}
@Override
public void execute() {
if (VersionNumber.VERSION_COMPARATOR.compare("1.13", remote.getGameVersion()) <= 0)
@@ -34,14 +34,16 @@ public class ForgeNewInstallProfile {
private final int spec;
private final String minecraft;
private final String json;
private final Artifact path;
private final List<Library> libraries;
private final List<Processor> processors;
private final Map<String, Datum> data;
public ForgeNewInstallProfile(int spec, String minecraft, String json, List<Library> libraries, List<Processor> processors, Map<String, Datum> data) {
public ForgeNewInstallProfile(int spec, String minecraft, String json, Artifact path, List<Library> libraries, List<Processor> processors, Map<String, Datum> data) {
this.spec = spec;
this.minecraft = minecraft;
this.json = json;
this.path = path;
this.libraries = libraries;
this.processors = processors;
this.data = data;
@@ -69,6 +71,14 @@ public class ForgeNewInstallProfile {
return json;
}
/**
* Maven artifact path for the main jar to install.
* @return artifact path of the main jar.
*/
public Artifact getPath() {
return path;
}
/**
* Libraries that processors depend on.
* @return the required dependencies.
@@ -19,6 +19,7 @@ package org.jackhuang.hmcl.download.forge;
import org.jackhuang.hmcl.download.DefaultDependencyManager;
import org.jackhuang.hmcl.download.game.GameLibrariesTask;
import org.jackhuang.hmcl.download.optifine.OptiFineInstallTask;
import org.jackhuang.hmcl.game.*;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.task.TaskResult;
@@ -107,6 +108,14 @@ public class ForgeNewInstallTask extends TaskResult<Version> {
FileUtils.copyFile(file, dest);
}
}
{
Path mainJar = profile.getPath().getPath(fs.getPath("maven"));
if (Files.exists(mainJar)) {
Path dest = gameRepository.getArtifactFile(version, profile.getPath());
FileUtils.copyFile(mainJar, dest);
}
}
}
dependents.add(new GameLibrariesTask(dependencyManager, version, profile.getLibraries()));
@@ -114,6 +123,9 @@ public class ForgeNewInstallTask extends TaskResult<Version> {
@Override
public void execute() throws Exception {
if ("net.minecraft.launchwrapper.Launch".equals(version.getMainClass()))
throw new OptiFineInstallTask.UnsupportedOptiFineInstallationException();
Path temp = Files.createTempDirectory("forge_installer");
int finished = 0;
try (FileSystem fs = CompressingUtils.createReadOnlyZipFileSystem(installer)) {
@@ -89,6 +89,7 @@ public final class GameAssetDownloadTask extends Task {
String url = dependencyManager.getDownloadProvider().getAssetBaseURL() + assetObject.getLocation();
FileDownloadTask task = new FileDownloadTask(NetworkUtils.toURL(url), file, new FileDownloadTask.IntegrityCheck("SHA-1", assetObject.getHash()));
task.setName(assetObject.getHash());
task.setCaching(true);
dependencies.add(task
.setCacheRepository(dependencyManager.getCacheRepository())
.setCaching(true)
@@ -128,12 +128,12 @@ public class LibraryDownloadTask extends Task {
try {
URL packXz = NetworkUtils.toURL(url + ".pack.xz");
if (NetworkUtils.urlExists(packXz)) {
task = new FileDownloadTask(packXz, xzFile, null);
task = new FileDownloadTask(packXz, xzFile, null).setCaching(true);
xz = true;
} else {
task = new FileDownloadTask(NetworkUtils.toURL(url),
jar,
library.getDownload().getSha1() != null ? new IntegrityCheck("SHA-1", library.getDownload().getSha1()) : null);
library.getDownload().getSha1() != null ? new IntegrityCheck("SHA-1", library.getDownload().getSha1()) : null).setCaching(true);
xz = false;
}
} catch (IOException e) {
@@ -66,6 +66,9 @@ public final class OptiFineInstallTask extends TaskResult<Version> {
@Override
public void execute() {
if ("cpw.mods.modlauncher.Launcher".equals(version.getMainClass()))
throw new UnsupportedOptiFineInstallationException();
String remoteVersion = remote.getGameVersion() + "_" + remote.getSelfVersion();
Library library = new Library(
@@ -90,4 +93,6 @@ public final class OptiFineInstallTask extends TaskResult<Version> {
dependencies.add(dependencyManager.checkLibraryCompletionAsync(version.setLibraries(libraries)));
}
public static class UnsupportedOptiFineInstallationException extends UnsupportedOperationException {
}
}
@@ -140,7 +140,7 @@ public final class CurseCompletionTask extends Task {
for (CurseManifestFile file : newManifest.getFiles())
if (StringUtils.isNotBlank(file.getFileName())) {
if (!modManager.hasSimpleMod(file.getFileName())) {
dependencies.add(new FileDownloadTask(file.getUrl(), modManager.getSimpleModPath(file.getFileName()).toFile()));
dependencies.add(new FileDownloadTask(file.getUrl(), modManager.getSimpleModPath(file.getFileName()).toFile()).setCaching(true));
}
}