cmd , commandLabel differences?

Discussion in 'Plugin Development' started by jacklin213, Oct 17, 2012.

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

    jacklin213

    I've see a lot of tutorials on youtube and i get confused over the fact some people use
    Code:java
    1. cmd.getName().equalsIgnoreCase("command")

    and some people use
    Code:java
    1. commndLabel.equalsIgnoreCase("command")


    Is there a particular difference? , Which way is "better" ?
     
  2. Offline

    makskay

    commandLabel refers to the alias used, whereas cmd.getName() refers to the name of the command: that is, if I set up
    /c as an alias for /command and then type /c into server chat, commandLabel will be "c" while cmd.getName() will return "command".
     
    kroltan likes this.
  3. Offline

    jacklin213

    so which one should u use?
     
  4. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı Retired Staff

    Depends on what you're trying to do.
     
  5. Offline

    jacklin213

    make a normal command
     
  6. Offline

    Sagacious_Zed Bukkit Docs

    If you need to check which command was fired, use the commands name

    if you need to echo back to the sender what they typed, used the label.
     
  7. Well I suggest using
    Code:
    cmd.getName()
    because you don't have to make a console version of the command so it doesn't crash the server
     
  8. Offline

    jacklin213

    if you do that does it automaticly make the sender player? im pretty sure that doesnt do it.
     
  9. Offline

    Sagacious_Zed Bukkit Docs

    All Players are CommandSenders. Not all CommandSenders are Players. All CommandSenders have names.
     
Thread Status:
Not open for further replies.

Share This Page