From 9eea988e481f6560c652413941d091801febf14e Mon Sep 17 00:00:00 2001 From: fullwall Date: Sun, 15 Apr 2012 22:39:17 +0800 Subject: [PATCH] Change classpath method to Thread.setContextClassLoader() --- src/main/java/net/citizensnpcs/Citizens.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/citizensnpcs/Citizens.java b/src/main/java/net/citizensnpcs/Citizens.java index 1d9fe45d1..d2dab81e8 100644 --- a/src/main/java/net/citizensnpcs/Citizens.java +++ b/src/main/java/net/citizensnpcs/Citizens.java @@ -57,6 +57,7 @@ public class Citizens extends JavaPlugin { private CitizensNPCManager npcManager; private Storage saves; private CitizensTraitManager traitManager; + private ClassLoader contextClassLoader; public CommandManager getCommandManager() { return commands; @@ -116,6 +117,8 @@ public class Citizens extends JavaPlugin { @Override public void onDisable() { + Thread.currentThread().setContextClassLoader(contextClassLoader); + // replace previous classloader // Don't bother with this part if MC versions are not compatible if (compatible) { save(); @@ -141,6 +144,9 @@ public class Citizens extends JavaPlugin { getServer().getPluginManager().disablePlugin(this); return; } + this.contextClassLoader = Thread.currentThread().getContextClassLoader(); + Thread.currentThread().setContextClassLoader(this.getClassLoader()); + // workaround to fix scripts not loading plugin classes properly config = new Settings(getDataFolder()); @@ -238,7 +244,6 @@ public class Citizens extends JavaPlugin { private void registerScriptHelpers() { ScriptCompiler compiler = CitizensAPI.getScriptCompiler(); compiler.registerGlobalContextProvider(new EventRegistrar(this)); - compiler.addToClasspath(this.getClassLoader(), new File("plugins")); } public void reload() throws NPCLoadException {