Checking commands made easier!

Discussion in 'Resources' started by oyasunadev, Aug 22, 2011.

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

    oyasunadev

    This is just a simple code I just whipped up. It's basic Java, so I'm not going to answer dumb questions. Basically what it does is allow you to put in a unlimited amount of strings to a method.

    Code:
    private boolean chk(String read, String ... inputs)
        {
            for(final String i : inputs)
            {
                if(read.equalsIgnoreCase(i))
                {
                    return true;
                }
            }
    
            return false;
        }
    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String cmdString, String[] args)
        {
            if(chk(cmdString, "test1", "test2", "test3"))
            {
                return true;
            }
    
            return false;
        }
    Thanks for reading! Press like!
     
    Daniel Heppner likes this.
Thread Status:
Not open for further replies.

Share This Page