Skip to content

Commit

Permalink
Use correct addURL method
Browse files Browse the repository at this point in the history
  • Loading branch information
LunNova committed Feb 7, 2016
1 parent 6ab6152 commit de36529
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/main/java/me/nallar/modpatcher/ModPatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.google.common.io.Resources;
import me.nallar.javapatcher.patcher.Patcher;
import net.minecraft.launchwrapper.LaunchClassLoader;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand Down Expand Up @@ -197,14 +196,14 @@ private static String getModPatcherRelease() {
private static void addToCurrentClassLoader() {
ClassLoader cl = ModPatcher.class.getClassLoader();

if (cl instanceof LaunchClassLoader) {
LaunchClassLoader lcl = (LaunchClassLoader) cl;
cl = ReflectionHelper.<ClassLoader, LaunchClassLoader>getPrivateValue(LaunchClassLoader.class, lcl, "parent");
lcl.addTransformerExclusion("me.nallar.modpatcher");
}

try {
Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);

if (cl instanceof LaunchClassLoader) {
LaunchClassLoader lcl = (LaunchClassLoader) cl;
lcl.addTransformerExclusion("me.nallar.modpatcher");
method = LaunchClassLoader.class.getDeclaredMethod("addURL", URL.class);
}
method.setAccessible(true);
method.invoke(cl, modPatcherPath.toUri().toURL());
} catch (Exception e) {
Expand Down

0 comments on commit de36529

Please sign in to comment.