Topic: Class loader
can someone help me repair this class loader???
public static void loadScripts(mudclient m1, String directory) {
System.out.println("Loading scripts...");
macroTable = new Hashtable();
File f = new File(directory);
if (!f.exists()) {
System.out.println("Script directory does not exist!");
return;
} else {
String[] files = f.list();
for (int i=0;i<files.length;i++) {
try {
if (files[i].endsWith(".class") && files[i].indexOf("$") == -1) {
System.out.print("Script found, registering command...");
Class c = Class.forName(files[i].substring(0,files[i].length()-6));
Script s = (Script)c.getConstructor(new Class[]{mudclient.class}).newInstance(new Object[]{m1});
String[] commands = s.getCommands();
for (int j=0;j<commands.length;j++) {
macroTable.put(commands[j], s);
}
System.out.println("done!");
}
} catch (Exception e) {
e.printStackTrace();
e.toString();
}
}
}
System.out.println("done!");
}
then here is my Script.java file
public class Script {
public mudclient globalRs;
public abstract String[] getCommands();
public abstract boolean start(String name, String[] args);
public abstract void init();
public abstract void run();
public abstract void stop();
public Script(mudclient rs) {
globalRs = rs;
}
}
Help
Cows