mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-23 10:35:18 +01:00
Fix DependencyLoader if ClassLoader is a AppClassLoader
This commit is contained in:
parent
b2e842c805
commit
8289dae0f8
@ -32,12 +32,22 @@ public class DependencyLoader {
|
||||
private final ClassLoaderAccess parentClassLoaderAccess;
|
||||
public DependencyLoader(Plugin plugin) {
|
||||
//Bind loaded dependencies to the plugin's parent class loader so classes could be accessed across plugins
|
||||
URLClassLoader parentClassLoader = (URLClassLoader) plugin.getClass().getClassLoader().getParent();
|
||||
this.libraryLoader = new LibraryLoader(
|
||||
parentClassLoader,
|
||||
new File(plugin.getDataFolder().getParentFile(), CraftaroCoreConstants.getProjectName() + "/dependencies/v" + DEPENDENCY_VERSION),
|
||||
SongodaCore.getLogger()
|
||||
);
|
||||
ClassLoader parentClassLoader = plugin.getClass().getClassLoader().getParent();
|
||||
if (parentClassLoader instanceof URLClassLoader) {
|
||||
this.libraryLoader = new LibraryLoader(
|
||||
(URLClassLoader) parentClassLoader,
|
||||
new File(plugin.getDataFolder().getParentFile(), CraftaroCoreConstants.getProjectName() + "/dependencies/v" + DEPENDENCY_VERSION),
|
||||
SongodaCore.getLogger()
|
||||
);
|
||||
} else {
|
||||
//We have AppClassLoader here
|
||||
this.libraryLoader = new LibraryLoader(
|
||||
parentClassLoader,
|
||||
new File(plugin.getDataFolder().getParentFile(), CraftaroCoreConstants.getProjectName() + "/dependencies/v" + DEPENDENCY_VERSION),
|
||||
SongodaCore.getLogger()
|
||||
);
|
||||
}
|
||||
|
||||
this.parentClassLoaderAccess = new ClassLoaderAccess(parentClassLoader);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user