Get Aliases

Discussion in 'Plugin Development' started by Vinceguy1, Jun 5, 2012.

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

    Vinceguy1

    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
    {
    if(label.equalsIgnoreCase("ping") || cmd.getAliases())
    {
    sender.sendMessage("Pong!")
    }
    }

    How do i get the aliases of a command?

    PLEASE

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  2. Offline

    Njol

    You should use cmd.getName().equalsIgnoreCase("ping") - the name of the command stays the same no matter which alias was used.
     
  3. Offline

    CorrieKay

    cmd.getAliases() returns a List<String> of the commands aliases.

    but to expand on what Njol said, lets say for instance, you have a command called derp, with an alias of herp.

    If you type /herp, cmd.getName() will return "derp" because thats the name of the command. label, however would return "herp" because thats the alias that you used.
     
    fromgate likes this.
  4. Offline

    Vinceguy1

    Oh, so your saying i should use cmd in replace of label?

    Edit: TY, it works like a charm!
     
  5. Offline

    CorrieKay

    Not necessarily, the alias definitely has its uses!
     
  6. Offline

    Vinceguy1

    Ya, but this is what i wanted so ty so much!
     
Thread Status:
Not open for further replies.

Share This Page