Checking if user has sent wrong arguments

Discussion in 'Spigot Plugin Development' started by Buby, May 14, 2016.

  1. Hey guys! I was messing around with commands and I have run over a bug that I cant really get past.. I think I am just not doing it right.. someone help.
    Code (Text):

                                    case "add":
                                        if(!(args[2] == null)){
                                            sendMessage(player, "alreadyadded", "");
                                            ArrayList<String> list = (ArrayList<String>) config.getStringList("BlackListed_Worlds");
                                            this.getConfig().set("BlackListed_Worlds", list);
                                                sendMessage(player, "addedworld", args[2]);
                                            sendMessage(player, "blacklistusage", "");
    sendMessage is my method.
    But for the first if statement, I am seeing if there is no argument for the 3rd argument. I am not sure if I am doing it correctly. am I suposed to do
    Code (Text):

    if(args[2] !=null){
  2. No just check the length of the string array.
    • Like Like x 1