Solved Strange NPE where npe shouldnt be showing..

Discussion in 'Plugin Development' started by Scorpionvssub, Mar 15, 2016.

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

    Scorpionvssub

    Code:
                if (args[0].equalsIgnoreCase("compare")) {
                    if (args[1] == null) {
                        Main.get().sendConfigMessage(p, "compareerror");
                        return true;
                    }
                    if (args[2] == null) {
                        Main.get().sendConfigMessage(p, "comparenoplayer");
                        return true;
                    }
    there is more to the code but it already has issues with args[1] == null
     
  2. Offline

    Zombie_Striker

    @Scorpionvssub
    If your problem has been solved, please post how it was solved.
     
  3. Offline

    N00BHUN73R

    @Scorpionvssub
    If you're using the onCommand method which I presume you are, try checking if the argument length is != 1 or != 2
    Better yet, you could check if it's empty
    Code:
    if(args[1].isEmpty()){
    //DoSomething
    }
    
    //OR
    
    if(args.length <= 1){
      //DoSomething?
    }
    
     
Thread Status:
Not open for further replies.

Share This Page