Commands With More Than One Word

Discussion in 'Plugin Development' started by hi_guy_5, Feb 24, 2014.

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


    Hello Im Making A help Menu For My Plugin and I'm trying to see if the word after the initial command equals help is this the right way?

                if(args.length == 0){
                    player.sendMessage(ChatColor.YELLOW +"-=<!Donator Menu By MasterKraft!>=-");
                    player.sendMessage(ChatColor.AQUA + "For The Help Menu Type /dm help");
                    player.sendMessage(ChatColor.AQUA +"To Check Your Version Type /dm ver");
                    return true;
  2. Offline


    That should work, yes. However, you may wish to use equalsIgnoreCase() because you can't predict the user. The other option would be args[1].toLowerCase().equals("help"). I think the former is slightly more efficient, though I could be mistaken.
  3. Offline


    You might want to use an else if statement when checking for args[1]. While your code is correct as it is, it helps to be as specific as possible. Like Alshain01 said, you may want to ignore case.

    Your code looks fine to me! It's valid, and if your plugin doesn't work, this does not seem to be the issue.
  4. Offline


    Remember that array indexes start at 0 (the command is not the first argument), meaning in /dm help, "help" would be args[0]
    Alshain01 likes this.
  5. Offline


    He's returning in all cases where args.length is 0, so an else/if would be irrelevant. But do change that index as Chinwe said.
  6. Offline


    wow thank you XD i completely messed up and i will change it to ignore case. Simple brain fart on my part
Thread Status:
Not open for further replies.

Share This Page