mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-24 11:38:26 +01:00
Change classpath method to Thread.setContextClassLoader()
This commit is contained in:
parent
1fd631de49
commit
9eea988e48
@ -57,6 +57,7 @@ public class Citizens extends JavaPlugin {
|
|||||||
private CitizensNPCManager npcManager;
|
private CitizensNPCManager npcManager;
|
||||||
private Storage saves;
|
private Storage saves;
|
||||||
private CitizensTraitManager traitManager;
|
private CitizensTraitManager traitManager;
|
||||||
|
private ClassLoader contextClassLoader;
|
||||||
|
|
||||||
public CommandManager getCommandManager() {
|
public CommandManager getCommandManager() {
|
||||||
return commands;
|
return commands;
|
||||||
@ -116,6 +117,8 @@ public class Citizens extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
Thread.currentThread().setContextClassLoader(contextClassLoader);
|
||||||
|
// replace previous classloader
|
||||||
// Don't bother with this part if MC versions are not compatible
|
// Don't bother with this part if MC versions are not compatible
|
||||||
if (compatible) {
|
if (compatible) {
|
||||||
save();
|
save();
|
||||||
@ -141,6 +144,9 @@ public class Citizens extends JavaPlugin {
|
|||||||
getServer().getPluginManager().disablePlugin(this);
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.contextClassLoader = Thread.currentThread().getContextClassLoader();
|
||||||
|
Thread.currentThread().setContextClassLoader(this.getClassLoader());
|
||||||
|
// workaround to fix scripts not loading plugin classes properly
|
||||||
|
|
||||||
config = new Settings(getDataFolder());
|
config = new Settings(getDataFolder());
|
||||||
|
|
||||||
@ -238,7 +244,6 @@ public class Citizens extends JavaPlugin {
|
|||||||
private void registerScriptHelpers() {
|
private void registerScriptHelpers() {
|
||||||
ScriptCompiler compiler = CitizensAPI.getScriptCompiler();
|
ScriptCompiler compiler = CitizensAPI.getScriptCompiler();
|
||||||
compiler.registerGlobalContextProvider(new EventRegistrar(this));
|
compiler.registerGlobalContextProvider(new EventRegistrar(this));
|
||||||
compiler.addToClasspath(this.getClassLoader(), new File("plugins"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reload() throws NPCLoadException {
|
public void reload() throws NPCLoadException {
|
||||||
|
Loading…
Reference in New Issue
Block a user