Lenni0451 / SpigotPluginManager

A fresh and easy to use plugin manager for spigot
MIT License
27 stars 11 forks source link

API #14

Closed BaxAndrei closed 2 years ago

BaxAndrei commented 2 years ago

Is there any support for API?

Lenni0451 commented 2 years ago

Support for what API?

BaxAndrei commented 2 years ago

For example to attach another plugin to it to initiate some kind of update. I want to add a command that will download latest file from Jenkins, remove the curent one and then uses api to unload old one and load the new one.

Lenni0451 commented 2 years ago

You can add SpigotPluginManager as a depend/softdepend in your Plugin and call the PluginManager.getInstance() method and access the instance of the PluginUtils.

You could use the PluginManager internal updater as some inspiration for an updater: https://github.com/Lenni0451/SpigotPluginManager/blob/948d735f04ae400c99973faf7a4fda93abad501d/src/main/java/net/lenni0451/spm/PluginManager.java#L94-L113

Or better you could download the new plugin file into the plugins/update (PluginManager.getInstance().getPluginUtils().getUpdateDirectory()) directory and call:

PluginManager.getInstance().getPluginUtils().reloadPlugin(plugin);

PM then unloads the plugin, moves the new plugin file and loads it again. Make sure to name the updated file in the plugins/update folder exactly like the current one since PM would be unable to find it and your plugins would just get reloaded.

Here is a bit example code for that: grafik

BaxAndrei commented 2 years ago

Thank you very much!

BaxAndrei commented 2 years ago

Is it ok if I uploaded the jar file to my server? (I'm the only person who knows the location). I use Jenkins and it is much easier for me to create a repo in which to put the jar for self-build. If you want, I can give you the public address. Thanks again for the help.

Lenni0451 commented 2 years ago

I guess you are speaking of PM. You can do that and I don't want the url. But thanks for asking