How to make plugin disable itself? (Java beginner)

Discussion in 'Plugin Development' started by Codex Arcanum, Oct 30, 2011.

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

    Codex Arcanum

    Title says it all. How do I get a plugin to disable itself? Thanks!
  2. Don't know why you would want to but:
    that's how you do it in the main class (the file containing onEnable etc.)
  3. Offline


    Assuming this is in your main plugin class.
    randomer679 likes this.
  4. Ahhh I didn't know that :)
  5. Offline

    Codex Arcanum

    Thanks! And I want to do this so I can make 100% sure people are not using outdated configuration files by checking for a config value that no longer exists and disabling it if it is still present.
  6. Offline


    Does this unregister the events too?
  7. Pretty sure you shouldn't do that, as Bukkit doesn't disable it, which causes problems. Use this.getServer().getPluginMangaer().disablePlugin(this);

    That way, Bukkit knows the plugin is disabled, and can properly disable it.

    Why not just save the old values that are persistant, delete the old file, and create the new one with the values that are persistant and the new default values?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 20, 2016
  8. To clarify this:

    NOPE, bukkit won't properly disable your plugin when calling disablePlugin. There is no API to do it properly, and it is only possible with lots of ugly reflection hooks, which is totally not appropiate here.

    @Codex Arcanum Auto-updating the config file is a lot more user-friendly and easier. You can just write your updated default config from a contained resource.
  9. Yes, I know...But its the closests you can get :p
Thread Status:
Not open for further replies.

Share This Page