Discussion in 'Plugin Development' started by Codex Arcanum, Oct 30, 2011.
Title says it all. How do I get a plugin to disable itself? Thanks!
Don't know why you would want to but:
that's how you do it in the main class (the file containing onEnable etc.)
Assuming this is in your main plugin class.
Ahhh I didn't know that
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.
Does this unregister the events too?
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.
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.
Yes, I know...But its the closests you can get
Separate names with a comma.