I am currently working on a Minecraft plugin using the Bukkit API. The plugin needs to, at runtime, add additional plugins to the server programatically. In SimplePluginManager, used by the CraftServer class to load Java plugins, there is a method called registerInterface() which takes in a class that implements the PluginLoader interface. I was able to implement this interface myself for a class, and was able to call registerInterface() with no issues.
However, by the time onLoad() is called for my plugin, calling registerInterface() will do nothing. I know that this is because the loadPlugins() method has already been called, so registering an interface then means nothing will occur. I tried getting around this by simply calling loadPlugins() again; with the argument for the directory being my plugin's parent directory (i.e., /plugins). This somewhat works, but it results in previously loaded plugins being loaded and registered again.
I know that loadPlugin() exists, which just loads a single plugin file. This works, but looking at its implementation in SimplePluginManager seems to reveal that it lacks any dependency validation/resolution/etc. That is only done by loadPlugins().
With that, my question is: How can one properly add plugins to a Bukkit server at runtime from another plugin programatically? If you need any more information on the problem, please ask me in the comments and I will happily update the question. Thank you!