How to cancel the loading of a plugin?

Discussion in 'Plugin Development' started by DjDCH, Jan 19, 2011.

  1. Offline

    DjDCH

    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?
  2. Offline

    MysticX

    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)
  3. Offline

    DjDCH

    Forgot to say that I have already try this. When you are in the loading process, this mutator have no effect.
  4. Offline

    DjDCH

  5. Offline

    DjDCH

    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).
  6. Offline

    matjam

  7. Offline

    DjDCH

  8. Offline

    Tahg Bukkit Team Member Moderator

    dev.bukkit.org profile:
    Tahg
    My Plugins
    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.
  9. Offline

    DjDCH

    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.
  10. Offline

    Tahg Bukkit Team Member Moderator

    dev.bukkit.org profile:
    Tahg
    My Plugins
    Thanks for the clarification. I will bring this up with the team, but it sounds reasonable to me.
  11. Offline

    Afforess

    dev.bukkit.org profile:
    Afforess
    My Plugins
    Look at how MMA or MMS disables itself if MMC is not installed.
  12. Offline

    DjDCH

    *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 ! :D

Share This Page