Ok, so I have this simple TP command. When a user types /otp <player> it teleports them to the player and gives the player a message if the player is OP. The problem is, if a user types /otp, it returns an ArrayIndexOutOfBoundsException, and I have no idea how to fix this. I've tried making an if statement to check if args[0].isEmpty(), but it doesn't work, it returns the same error, and the error is this line here: Code: Player player = plugin.getServer().getPlayer(args[0]); I assume the error is because the 0 index is empty, but I don't know how to display a message if it is empty, because the if statement did not work. Any help would be greatly appreciated.
if (args.length >= 1) { //see whether args[] contains at least one element, which then has the index 0 }