mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-29 12:37:40 +01:00
Fix NoClassDefFoundError when loading extensions on non-JiJ platforms
This commit is contained in:
parent
88f040e822
commit
16ee500054
@ -27,7 +27,6 @@ package me.lucko.luckperms.common.extension;
|
|||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.loader.JarInJarClassLoader;
|
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.util.gson.GsonProvider;
|
import me.lucko.luckperms.common.util.gson.GsonProvider;
|
||||||
|
|
||||||
@ -144,7 +143,7 @@ public class SimpleExtensionManager implements ExtensionManager, AutoCloseable {
|
|||||||
throw new IllegalArgumentException("class is null");
|
throw new IllegalArgumentException("class is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useParentClassLoader && getClass().getClassLoader() instanceof JarInJarClassLoader) {
|
if (useParentClassLoader && isJarInJar()) {
|
||||||
try {
|
try {
|
||||||
addJarToParentClasspath(path);
|
addJarToParentClasspath(path);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -196,6 +195,11 @@ public class SimpleExtensionManager implements ExtensionManager, AutoCloseable {
|
|||||||
return this.extensions.stream().map(e -> e.instance).collect(Collectors.toSet());
|
return this.extensions.stream().map(e -> e.instance).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isJarInJar() {
|
||||||
|
String thisClassLoaderName = SimpleExtensionManager.class.getClassLoader().getClass().getName();
|
||||||
|
return thisClassLoaderName.equals("me.lucko.luckperms.common.loader.JarInJarClassLoader");
|
||||||
|
}
|
||||||
|
|
||||||
private static void addJarToParentClasspath(Path path) throws Exception {
|
private static void addJarToParentClasspath(Path path) throws Exception {
|
||||||
ClassLoader parentClassLoader = SimpleExtensionManager.class.getClassLoader().getParent();
|
ClassLoader parentClassLoader = SimpleExtensionManager.class.getClassLoader().getParent();
|
||||||
if (!(parentClassLoader instanceof URLClassLoader)) {
|
if (!(parentClassLoader instanceof URLClassLoader)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user