summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierce <spammermuch@gmail.com>2021-12-22 08:37:41 -0500
committerGitHub <noreply@github.com>2021-12-22 21:37:41 +0800
commitf0a1b27529e3512cc0a4aaf01f0fb94c5ff2fcbc (patch)
tree72de37c3856c39ecb745632c002d6cd4e125bce0
parentad3e7501cab36caccfc1bb1ab0987d9c3c6cdb4f (diff)
downloadProject-Tick-f0a1b27529e3512cc0a4aaf01f0fb94c5ff2fcbc.tar.gz
Project-Tick-f0a1b27529e3512cc0a4aaf01f0fb94c5ff2fcbc.zip
Choose correct installer version regardless of spec (#9)
-rw-r--r--src/main/java/io/github/zekerzhayard/forgewrapper/installer/Installer.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/main/java/io/github/zekerzhayard/forgewrapper/installer/Installer.java b/src/main/java/io/github/zekerzhayard/forgewrapper/installer/Installer.java
index eecfe90f00..72181dde2c 100644
--- a/src/main/java/io/github/zekerzhayard/forgewrapper/installer/Installer.java
+++ b/src/main/java/io/github/zekerzhayard/forgewrapper/installer/Installer.java
@@ -1,12 +1,14 @@
package io.github.zekerzhayard.forgewrapper.installer;
import java.io.File;
+import java.lang.reflect.Method;
import io.github.zekerzhayard.forgewrapper.installer.util.AbstractInstaller;
import io.github.zekerzhayard.forgewrapper.installer.util.InstallerV0;
import io.github.zekerzhayard.forgewrapper.installer.util.InstallerV1;
import net.minecraftforge.installer.actions.ProgressCallback;
import net.minecraftforge.installer.json.Install;
+import net.minecraftforge.installer.json.Util;
public class Installer {
public static boolean install(File libraryDir, File minecraftJar, File installerJar, int installerSpec) {
@@ -26,7 +28,18 @@ public class Installer {
private static AbstractInstaller getInstaller(int installerSpec) {
switch (installerSpec) {
- case 0: return new InstallerV0();
+ case 0: {
+ Boolean isV1 = false;
+ Method[] methods = Util.class.getDeclaredMethods();
+ for (Method method: methods) {
+ String methodName = method.toString();
+ if (methodName.contains("InstallV1") && methodName.contains("loadInstallProfile")) {
+ isV1 = true;
+ break;
+ }
+ }
+ return isV1 ? new InstallerV1() : new InstallerV0();
+ }
case 1: return new InstallerV1();
default: throw new IllegalArgumentException("Invalid installer profile spec: " + installerSpec);
}