What happens when disabling a plugin?

Discussion in 'Plugin Development' started by TheDiamond06, Jan 22, 2018.

Thread Status:
Not open for further replies.
  1. Offline

    TheDiamond06

    When calling Bukkit#getServer()#getPluginManager()#disablePlugin(Plugin), it disables the plugin in the parameter. However, it still will execute code from this plugin if there is more left after calling this line. In addition, even after all its code has run, it will have no mutability on the .jar file itself. You cannot delete, rename, or move the jar file.

    1.) What does Bukkit do when you use this method to disable your plugin?
    2.) Is there a way to *completely* disable a plugin to have it run no more code from it and make it have mutability and be susceptible to renames, deletions, and changes in a directory *while still running other plugins and not stopping the server*?
     
    Last edited: Jan 22, 2018
  2. Offline

    timtower Administrator Administrator Moderator

    @TheDiamond06 1. Calls onDisable, destroys all non-static instances, kills all timers and listeners, not in this order though.
    2. Stopping the server will do.
     
  3. Offline

    TheDiamond06

    I was not clear enough with my question, the original one has been edited. I want only the plugin I want to disable to *completely* stop and not the entire server along with other plugins.
     
  4. Offline

    timtower Administrator Administrator Moderator

    Then you need to somehow unload all classes that got loaded for the plugin.
    But why do you want to modify those things from another plugin?
     
  5. Offline

    TheDiamond06

    Would unloading all the classes via internally in the plugin be possible? I thought Bukkit was the one that handles the loading of plugins?

    I would want to have mutability to the jar file itself to move it to another location and have it not be used by the server unless the user manually puts it back in before next startup.
     
  6. Offline

    timtower Administrator Administrator Moderator

    Possible: probably, worth the effort: doubt it.
    If it is the plugin itself then why not just set a boolean in the config for "enabled"
     
  7. Offline

    TheDiamond06

    I'll see what I can do with this then but I feel Bukkit itself should have some help with this. Although it is a rare occasion in which someone would want to fully unload a plugin.

    I don't want the plugin to be enabled or disabled. It is not the reason I am trying to do this. Ultimately, I am getting rid of that jar file completely but am not deleting it because the user still may want it. What I am fully doing is changing the plugin.yml and creating a duplicate jar of the plugin in its datafolder directory with the changed plugin.yml. Since you can not easily change files in a running jar without problems I did that. If I am in need to change the plugin.yml and generate the jar, the old jar will be moved like I said while the server is running, and then the new jar will take its place and will either be enabled while the server is running (if I find a way) or will be there for when the server next starts.
     
  8. Offline

    timtower Administrator Administrator Moderator

    It never happens because nobody needs (or should) touch the jars.
    I really don't see the point in doing all that effort when a boolean does the same trick.
    What kind of plugin would remove itself (which it can't because it still needs the deletion code while being removed)
     
  9. Offline

    Colinus999

    You can do it using a second JAR with the deletion code that is deleted after next restart when it is not loaded.

    But I still agree with you.
     
  10. Offline

    timtower Administrator Administrator Moderator

    But then you need to think about what you are gonna do with the second jar.
     
  11. Offline

    Colinus999

    Well, the plugin is unloaded. The deletion code does not have to be unloaded and is not loaded after the next restart when it is saved in the Config folder of the plugin. You may even create it as a temp file so your System will take care of it when the server stops.
     
  12. Do you know specifically the order that this occurs?
     
  13. Offline

    timtower Administrator Administrator Moderator

    I do not.
     
Thread Status:
Not open for further replies.

Share This Page