I'm facing this issue since I notice error can occur in the loading process and I want, when this occurred, stop the loading process of the plugin. I don't know if this already possible with bukkit, but it would be nice to have the possibility to do it. So, how to cancel the loading of a plugin?
I'm not sure if you can cancel the loading, but you can try to disable it again via the Pluginmanager. Code: plugin.getServer().getPluginManager().disablePlugin(arg0)
Forgot to say that I have already try this. When you are in the loading process, this mutator have no effect.
I just took a look to the CraftBukkit code to see how a plugin is enable. Since the way the onEnable method is called, there no possibilities to do what I need to do. So, I request the implementation of a way to cancel a plugin from the onEnable method (like a specific exception to throw, a setCancelled mutator or a true/false boolean to return).
I suspect you should probably file a feature request if there isn't one already. http://bugs.bukkit.org/
Let me clarify here. You want to disable your own plugin, if for some reason it fails to properly initialize? This seems like a logical thing to do and we can look into it. We will NOT however provide a mechanism to prevent the loading of other plugins if it is that that you want to do.
This. Like I said, I need a way, from inside the onEnable method, to cancel a plugin from finishing its loading. I was thinking about a specific exception to throw, and I'm pretty convince that is the best way to do it.
*Facepalm* While I was took a look to the CraftBukkit code, I had seen this method (setEnabled) but I don't realized that is what I've searching for. I will try it soon. Thanks Afforess !