I just found out how to do it right after posting this. For anyone who needs to know this too, here's the answer:
This is what I used before changing the base to an abstract class:
PluginManager pm = PluginManagerFactory.createPluginManager();
PluginManagerUtil pmu = new PluginManagerUtil(pm);
pm.addPluginsFrom(new File("Path/to/plugins").toURI());
for(MyPlugin pluginToLoad : pluginManagerUtil.getPlugins(MyPlugin.class) {
//Do things with pluginToLoad here...
}
This is what I use now:
PluginManager pm = PluginManagerFactory.createPluginManager();
PluginManagerUtil pmu = new PluginManagerUtil(pm);
pm.addPluginsFrom(new File("Path/to/plugins").toURI());
for(Plugin plugin : pluginManagerUtil.getPlugins() {
if (plugin instanceof MyPlugin) {
MyPlugin pluginToLoad = (MyPlugin) plugin;
//Do things with pluginToLoad here...
}
}
Please tell me if anything I did here is wrong.
For me this worked so I assume that it's correct.