From b8b2e173656346f2b82eb629a0797c8bd6b0395d Mon Sep 17 00:00:00 2001 From: makamys Date: Fri, 8 Dec 2023 18:22:19 +0100 Subject: Un-hardcode package name in VirtualJar (Makes it easier to drag and drop into other mods.) --- src/main/java/makamys/neodymium/util/virtualjar/VirtualJar.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/makamys/neodymium/util/virtualjar/VirtualJar.java b/src/main/java/makamys/neodymium/util/virtualjar/VirtualJar.java index d5049b4..21f5f33 100644 --- a/src/main/java/makamys/neodymium/util/virtualjar/VirtualJar.java +++ b/src/main/java/makamys/neodymium/util/virtualjar/VirtualJar.java @@ -30,7 +30,7 @@ public class VirtualJar { LOGGER.debug("Registering URL protocol handler: " + PROTOCOL); // We want the Handler to always be loaded by the same class loader. - Launch.classLoader.addClassLoaderExclusion("makamys." + MODID + ".util.virtualjar.protocol." + PROTOCOL); + Launch.classLoader.addClassLoaderExclusion(getPackage() + ".protocol." + PROTOCOL + "."); // The Handler is loaded by the AppClassLoader, but it needs to access the state of VirtualJar, which is loaded // by the LaunchClassLoader. The solution? Make the Handler just a proxy that delegates the real work to @@ -42,6 +42,11 @@ public class VirtualJar { registered = true; } + private static String getPackage() { + String name = VirtualJar.class.getName(); + return name.substring(0, name.lastIndexOf('.')); + } + public static void add(IVirtualJar jar) { registerHandler(); -- cgit