Okay, so I’m making a plugin loader for my project, and this is essentially the code to it:
File folder = new File(System.getProperty("user.dir")+"/res/modules/");
File files[] = folder.listFiles();
for (int a = 0; a < files.length; a++){
String classToUse = files[a].getName().replace(".class", "");
ClassLoader loader = URLClassLoader.newInstance(
new URL[] { folder.toURL() }, getClass().getClassLoader());
Class<?> clazz = Class.forName(classToUse, true, loader);
Class<? extends Object> starter = clazz.asSubclass(Object.class);
Constructor<? extends Object> constructor =
starter.getDeclaredConstructor(String[].class, String[].class, String.class);
Object start = constructor.newInstance(sent, tags, sentence);
}
It passes in some necessary variables the engine itself generates for the modder to work with but there is actually one very necessary object that needs to be passed through, and that is the Brain object. This gives them access to all of the programs information that’s stored in it, but I have no way of sending this seemingly.
Essentially, what I’m asking, is how would I import aida.neural.Brain into a class that is in the resources folder and not in any way connected to the rest and be able to call functions from it? I just need to it to call them blindly if so needed, just compile and do what it’s supposed to once loaded.
Please also know I’m a novice with ClassLoader, so don’t make fun of me too bad if this is easy, Hahah.