Meaning of "valid command"

Discussion in 'Spigot Plugin Development' started by NoobDoesMC, Nov 9, 2018.

  1. Just a guess here, is it not referring to whether or not the command is registered with the server instance?
  2. md_5

    Administrator Developer

    If you return false, Bukkit will send the user the message you defined as "usage" in plugin.yml
    If you haven't defined a usage message it sends a default message (can't remember what it is off the top of my head, try it).
  3. OH THAT! /me feels dumb.
  4. If i'm not mistaken if you have no usage defined, and you return false, then no message is sent.

  5. My onCommand method sends custom error messages.

    I think what I'm going to do is return true then.

    Even though the command is technically "invalid", I am handling it myself in the onCommand method, so I don't want the server to also send the player the usage message.
    • Winner Winner x 1
  6. I would guess he boolean method itself returns whether or not the command should be executed, given there are parameters for the command to actually be registered and ready to use.

    You have to:
    - Register the executor through the code in the bukkit instance on enable.
    - Register the command itself and other properties through the plugin.yml

    I haven't checked the spigot code for the handling of executions of commands however I'm guessing the method it inherits from the CommandExecutor interface (the onCommand) has checks for firing.

    It's an intresting question though, never made it return true....
  7. That's one way of doing it, the benefits are instead of always showing a generic usage message upon command failure you can customize it depending on what went wrong. "Too few arguments", etc.

    It doesn't return whether it should be executed, it returns whether it did execute. As md_5 stated above, returning false sends the sender the usage message defined in the plugin.yml, returning true tells the server that the command executed successfully and no further action is required.
    If no usage message is defined then no message is sent, in which case I guess there is no noticeable difference between returning true and false.

  8. return true, means that your coding has accepted the command and there will be no further action taken.

    As @md_5 said
    return false returns the commands.yourcommand.usage as defined in the plugin.yml

Share This Page