Solved Quick onCommand question

Discussion in 'Plugin Development' started by pookeythekid, Oct 12, 2014.

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

    pookeythekid

    Hey there. I just had a curiosity on my mind that's never been satisfied: does it matter what your onCommand method returns? What does the Bukkit code do with that method, and does it even use it for a true or false value? If it doesn't use it as a true or false check, could I just turn it into a void instead of a boolean?

    Thanks.
     
  2. pookeythekid true = don't show usage
    false = show usage
     
  3. Offline

    pookeythekid

    AdamQpzm Show usage in the console, or to other command-listening plugins?
     
  4. Offline

    Rocoty

    pookeythekid Generally, returning false tells Bukkit that the command was not properly executed, and returning true signifies that the command was properly executed. Whether you decide to follow this rule is up to you, but I see this as a contract you sign when you decide to override onCommand/implement CommandExecutor. I recommend you follow it.

    To answer your second question
    No. Well, strictly yes you could, but you'd have to remove the @Override annotation as it wouldn't override any method anymore, but rather overload it, which is completely different. Furthermore, the method could also no longer be used by Bukkit for command handling. Short answer: Don't do it.

    EDIT: Thinking about it, the method wouldn't overload either. Basically it wouldn't work at all.
     
    pookeythekid and AdamQpzm like this.
  5. pookeythekid By default, Bukkit automatically send the usage message to the CommandSender (be in console/player/whatever) when you return false.
     
  6. Offline

    pookeythekid

    Rocoty Perfect answer. :) Thanks.
     
Thread Status:
Not open for further replies.

Share This Page