Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,16 @@
* @author huangyuhui
*/
@Immutable
public final class ForgeInstallProfile implements Validation {
public record ForgeInstallProfile(@SerializedName("install") ForgeInstall install,
@SerializedName("versionInfo") GameInstanceManifest versionInfo) implements Validation {

@SerializedName("install")
private final ForgeInstall install;

@SerializedName("versionInfo")
private final GameInstanceManifest versionInfo;

public ForgeInstallProfile(ForgeInstall install, GameInstanceManifest versionInfo) {
this.install = install;
this.versionInfo = versionInfo;
}

public ForgeInstall getInstall() {
@Override
public ForgeInstall install() {
return install;
}

public GameInstanceManifest getVersionInfo() {
@Override
public GameInstanceManifest versionInfo() {
return versionInfo;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ public static boolean detectForgeInstallerType(DependencyManager dependencyManag
return true;
} else if (installProfile.containsKey("install") && installProfile.containsKey("versionInfo")) {
ForgeInstallProfile profile = JsonUtils.fromNonNullJson(installProfileText, ForgeInstallProfile.class);
if (!gameVersion.get().equals(profile.getInstall().getMinecraft()))
throw new VersionMismatchException(profile.getInstall().getMinecraft(), gameVersion.get());
if (!gameVersion.get().equals(profile.install().getMinecraft()))
throw new VersionMismatchException(profile.install().getMinecraft(), gameVersion.get());
return false;
} else {
throw new IOException();
Expand Down Expand Up @@ -168,9 +168,9 @@ public static Task<GameInstancePatch> install(DefaultDependencyManager dependenc
return new ForgeNewInstallTask(dependencyManager, manifest, modifyVersion(gameVersion.get(), profile.getVersion()), installer);
} else if (installProfile.containsKey("install") && installProfile.containsKey("versionInfo")) {
ForgeInstallProfile profile = JsonUtils.fromNonNullJson(installProfileText, ForgeInstallProfile.class);
if (!gameVersion.get().equals(profile.getInstall().getMinecraft()))
throw new VersionMismatchException(profile.getInstall().getMinecraft(), gameVersion.get());
return new ForgeOldInstallTask(dependencyManager, manifest, modifyVersion(gameVersion.get(), profile.getInstall().getPath().getVersion().replaceAll("(?i)forge", "")), installer);
if (!gameVersion.get().equals(profile.install().getMinecraft()))
throw new VersionMismatchException(profile.install().getMinecraft(), gameVersion.get());
return new ForgeOldInstallTask(dependencyManager, manifest, modifyVersion(gameVersion.get(), profile.install().getPath().getVersion().replaceAll("(?i)forge", "")), installer);
} else {
throw new IOException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.util.gson.JsonUtils;

import java.io.*;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
Expand Down Expand Up @@ -72,22 +73,22 @@ public void execute() throws Exception {
ForgeInstallProfile installProfile = JsonUtils.fromNonNullJsonFully(stream, ForgeInstallProfile.class);

// unpack the universal jar in the installer file.
Library forgeLibrary = new Library(installProfile.getInstall().getPath());
Library forgeLibrary = new Library(installProfile.install().getPath());
Path forgeFile = dependencyManager.getGameRepository().getLibraryFile(manifest, forgeLibrary);
Files.createDirectories(forgeFile.getParent());

ZipEntry forgeEntry = zipFile.getEntry(installProfile.getInstall().getFilePath());
ZipEntry forgeEntry = zipFile.getEntry(installProfile.install().getFilePath());
try (InputStream is = zipFile.getInputStream(forgeEntry);
OutputStream os = Files.newOutputStream(forgeFile, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) {
is.transferTo(os);
}

setResult(GameInstancePatch.fromManifest(
installProfile.getVersionInfo(),
installProfile.versionInfo(),
LibraryAnalyzer.LibraryType.FORGE.getPatchId(),
selfVersion,
GameInstancePatch.PRIORITY_LOADER));
dependencies.add(dependencyManager.checkLibraryCompletionAsync(installProfile.getVersionInfo(), true));
dependencies.add(dependencyManager.checkLibraryCompletionAsync(installProfile.versionInfo(), true));
} catch (ZipException ex) {
throw new ArtifactMalformedException("Malformed forge installer file", ex);
}
Expand Down