mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-06 07:30:35 +07:00
Log incompatible mod class loaders
This commit is contained in:
parent
4734261097
commit
ccb973d1dd
@ -785,6 +785,17 @@ public class Mods implements Loadable{
|
||||
loader = platform.loadJar(sourceFile, mainLoader);
|
||||
mainLoader.addChild(loader);
|
||||
Class<?> main = Class.forName(mainClass, true, loader);
|
||||
|
||||
//detect mods that incorrectly package mindustry in the jar
|
||||
if((main.getSuperclass().getName().equals("mindustry.mod.Plugin") || main.getSuperclass().getName().equals("mindustry.mod.Mod")) &&
|
||||
main.getSuperclass().getClassLoader() != Mod.class.getClassLoader()){
|
||||
throw new IllegalArgumentException(
|
||||
"This mod/plugin has loaded Mindustry dependencies from its own class loader. " +
|
||||
"You are incorrectly including Mindustry dependencies in the mod JAR - " +
|
||||
"make sure Mindustry is declared as `compileOnly` in Gradle, and that the JAR is created with `runtimeClasspath`!"
|
||||
);
|
||||
}
|
||||
|
||||
metas.put(main, meta);
|
||||
mainMod = (Mod)main.getDeclaredConstructor().newInstance();
|
||||
}else{
|
||||
|
Loading…
Reference in New Issue
Block a user