0

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!

2
  • I mean there are plugins that do this for you like PlugmanX. I've tried looking into this myself and when I tried to do it, it was very tricky and finicky. You could try reverse engineering some plugins like PlugmanX. If you really want to persue this I might be able to try to continue what I was doing one time and report back to you how I did it. That is, if I can figure it out Commented Jan 1, 2024 at 7:14
  • That sounds great, I appreciate the tip. Thank you! Commented Jan 1, 2024 at 7:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.