Using command arguements

Discussion in 'Resources' started by tharvoil, Aug 21, 2011.

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


    I'm semi-new to java(took a semister class @ college), as well as new to plugin development. How do I pass a command arguement to a method.

    e.g. I have with onCommand - if(cmd.getName().equalsIgnoreCase("refer")) and I want to pass on a player name typed after the refer( /refer <name>, I need the <name>)
  2. Offline


    /refer args[0] args[1] args[2]
    and so on..

    so the first after the command is:

    this prints out the first thing you wrote after /refer

    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
        if (commandLabel.equalsIgnoreCase("refer")) {
            if (args.length == 1) {
                return true;
            } else {
                sender.sendMessage("Invalid arguments!");
        return false;
  3. Offline


    thanks, that makes life so much easier than what I was trying.
Thread Status:
Not open for further replies.

Share This Page