How do you disable commands?

Discussion in 'Plugin Development' started by RandomGuy137, Jul 23, 2014.

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


    Hi guys,
    So I'm gonna be creating a fairly big plugin and I was just wondering: If somebody already have a plugin installed that handled /mute (for example) but my plugin also did and I wanted a config option to disable /mute in my plugin, How would I go about this?

    My current findings:
    You can get a config options to be able to decide whether or not to actually execute anything in the if(command.getname.equalsignorecase("mute") {, However the command's still registered in the plugin.yml so it doesn't let the other plugin handle it anyway.

    Basically: I'm wondering if I can bypass registering the command in the plugin.yml e.t.c?
  2. Offline


    RandomGuy137 On the PlayerCommandPreprocessEvent, if the command is "mute" for example, cancel the event then execute your code. This will stop any other plugin from performing anything on that command.
  3. Offline


    So I should do every command in my plugin with the PlayerCommandPreProcessEvent?
  4. Offline


    RandomGuy137 If you think another plugin may be trying to perform an action on that command and you wish to prevent it from doing so, use the logic outlined in my previous post.

    Usually however the onCommand method should be adequate; it's only in some special cases, as I've mentioned before such as when the /mute command is potentially being used by a number of plugins (and you wish to prevent that) where I can see any advantage in using PlayerCommandPreprocessEvent instead.

    In short: either way should be fine, just play around with both and see what happens.
  5. Offline


    I've seen some plugins whom use the PlayerCommandPreprocessEvent to execute their command instead of onCommand.

    Using dsouzamatt 's method, you might also want to consider prioritizing your method to HIGHEST to ensure that your method gets through before others.
  6. Offline


Thread Status:
Not open for further replies.

Share This Page