Need some help with onCommand

Discussion in 'Plugin Development' started by gjossep, Jan 28, 2012.

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

    gjossep

    Hello, i am having a problem when i do /test it will respond with Test is working, but if i try with arguments it fails and returns false....

    Code:
            public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,String[] args)
            {
               
                if(cmd.getName().equalsIgnoreCase("test")&&args.length==0)
               
                {
                   
                        sender.sendMessage("test is working!");
                        return true;
                       
                   
                }
                if(cmd.getName().equalsIgnoreCase("test")&&args.length==1&&args[0]=="help")
                {
               
                sender.sendMessage("test Help:");
                return true;
               
                }
               
                   
               
                return false;
               
           
           
           
     
            }
    Thanks for helping

    Gjosse
     
  2. Offline

    DomovoiButler

    use args[0].equalsIgnoreCase("help"){}
     
  3. Offline

    masteroftime

    never ever compare strings with == always use .eqals()!!!!!!

    == on two different strings will always return false but == on two identical strings may return both, true and false
     
Thread Status:
Not open for further replies.

Share This Page