Skip to content

Commit f0a1b27

Browse files
authored
Choose correct installer version regardless of spec (ZekerZhayard#9)
1 parent ad3e750 commit f0a1b27

File tree

1 file changed

+14
-1
lines changed
  • src/main/java/io/github/zekerzhayard/forgewrapper/installer

1 file changed

+14
-1
lines changed

src/main/java/io/github/zekerzhayard/forgewrapper/installer/Installer.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package io.github.zekerzhayard.forgewrapper.installer;
22

33
import java.io.File;
4+
import java.lang.reflect.Method;
45

56
import io.github.zekerzhayard.forgewrapper.installer.util.AbstractInstaller;
67
import io.github.zekerzhayard.forgewrapper.installer.util.InstallerV0;
78
import io.github.zekerzhayard.forgewrapper.installer.util.InstallerV1;
89
import net.minecraftforge.installer.actions.ProgressCallback;
910
import net.minecraftforge.installer.json.Install;
11+
import net.minecraftforge.installer.json.Util;
1012

1113
public class Installer {
1214
public static boolean install(File libraryDir, File minecraftJar, File installerJar, int installerSpec) {
@@ -26,7 +28,18 @@ public static boolean install(File libraryDir, File minecraftJar, File installer
2628

2729
private static AbstractInstaller getInstaller(int installerSpec) {
2830
switch (installerSpec) {
29-
case 0: return new InstallerV0();
31+
case 0: {
32+
Boolean isV1 = false;
33+
Method[] methods = Util.class.getDeclaredMethods();
34+
for (Method method: methods) {
35+
String methodName = method.toString();
36+
if (methodName.contains("InstallV1") && methodName.contains("loadInstallProfile")) {
37+
isV1 = true;
38+
break;
39+
}
40+
}
41+
return isV1 ? new InstallerV1() : new InstallerV0();
42+
}
3043
case 1: return new InstallerV1();
3144
default: throw new IllegalArgumentException("Invalid installer profile spec: " + installerSpec);
3245
}

0 commit comments

Comments
 (0)