package impsoft.nexus.storage; import impsoft.nexus.gui.threads.GuiThread; import java.io.File; import java.io.IOException; import java.net.JarURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Enumeration; import java.util.jar.JarEntry; import java.util.jar.JarFile; public class iDirClassLoader extends iClassLoader { String theLocation; String theName; public iDirClassLoader(String location,String name) { theLocation = location; theName=name; update(); } @Override public void update() { CoreScriptStorage.clear(theLocation); try { File scriptDir = new File(theLocation); URLClassLoader ucl = new URLClassLoader(new URL[] { scriptDir.toURL() }); for (File f : scriptDir.listFiles()) { String name = f.getName(); if(name.endsWith(".class") && name.indexOf("$") == -1){ String className = f.getName().substring(0, f.getName().indexOf(".")); try { Class c = ucl.loadClass(className); CoreScriptStorage.addScriptClass(c,theName); } catch (ClassNotFoundException e) { GuiThread.exception(e); } } } } catch (MalformedURLException e) { GuiThread.exception(e); } CoreScriptStorage.guiRefresh(); } } package impsoft.nexus.storage; import impsoft.nexus.gui.threads.GuiThread; import java.io.IOException; import java.net.JarURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Enumeration; import java.util.jar.JarEntry; import java.util.jar.JarFile; public class iJarClassLoader extends iClassLoader { String theLocation; String theName; public iJarClassLoader(String location, String name) { theLocation = location; theName=name; update(); } @Override public void update() { CoreScriptStorage.clear(theLocation); try { URL url = new URL("jar:" + theLocation + "!/"); JarURLConnection conn = (JarURLConnection) url.openConnection(); JarFile jarfile = conn.getJarFile(); Enumeration entires = jarfile.entries(); ArrayList classNames = new ArrayList(10); while (entires.hasMoreElements()) { JarEntry entry = entires.nextElement(); String name = entry.toString(); if ((name.endsWith(".class") && name.indexOf("$") == -1)) { classNames.add(name); } } URLClassLoader urlCL = new URLClassLoader(new URL[] { url }); for (String className : classNames) { try { Class c = urlCL.loadClass(className.replace(".class", "")); CoreScriptStorage.addScriptClass(c,theName); } catch (ClassNotFoundException e) { GuiThread.exception(e); } } } catch (MalformedURLException e) { GuiThread.exception(e); } catch (IOException e) { GuiThread.exception(e); } CoreScriptStorage.guiRefresh(); } } package impsoft.nexus.storage; import impsoft.nexus.bots.core.interfaces.CoreScript; import impsoft.nexus.gui.threads.GuiThread; import impsoft.nexus.handlers.Handler; import impsoft.nexus.handlers.storage.ActiveHandlerStorage; import impsoft.nexus.handlers.storage.HandlerStorage; import java.util.ArrayList; import java.util.List; public class CoreScriptStorage { public static List scripts = new ArrayList(0); public static void clear(String location){ for(int i=0;i