Skip to content
This repository was archived by the owner on Oct 29, 2019. It is now read-only.

Commit c9504f0

Browse files
committed
fix optifine patching for some version of java
1 parent 1cdea5e commit c9504f0

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

src/main/java/cc/hyperium/installer/api/Installer.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,7 @@ public void install() {
179179
optifineLibDir.mkdirs();
180180
File optifineLib = new File(optifineLibDir, "OptiFine-1.8.9_HD_U_I7.jar");
181181

182-
InstallerUtils.loadURL(optifine.toURI().toURL());
183-
184-
Class<?> patcher = Class.forName("optifine.Patcher");
182+
Class<?> patcher = InstallerUtils.loadClass(optifine.toURI().toURL(), "optifine.Patcher");
185183
Method main = patcher.getMethod("main", String[].class);
186184
main.invoke(null, new Object[]{new String[]{originJar.getAbsolutePath(), optifine.getAbsolutePath(), optifineLib.getAbsolutePath()}});
187185
} catch (Exception ex) {

src/main/java/cc/hyperium/utils/InstallerUtils.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,8 @@ public static String toHex(byte[] bytes) {
106106
return r.toString();
107107
}
108108

109-
public static void loadURL(URL url) throws Exception {
110-
URLClassLoader ucl = (URLClassLoader) InstallerMain.class.getClassLoader();
111-
Method m = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
112-
m.setAccessible(true);
113-
m.invoke(ucl, url);
109+
public static Class<?> loadClass(URL url, String c) throws ClassNotFoundException {
110+
return new URLClassLoader(new URL[]{url}).loadClass(c);
114111
}
115112

116113
}

0 commit comments

Comments
 (0)