An internal error.... when player not found when tp help

Discussion in 'Plugin Development' started by XxFuNxX, Oct 13, 2011.

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

    XxFuNxX

    I Have a command thats tp the sender, to args[1] nothing hard, but if the player is not online it stands an internal error occurred while attempting to perform this command, is it possible to send a message telling player not found instead?
     
  2. Offline

    nisovin

    Check for a null target before attempting to teleport.
     
  3. Offline

    bergerkiller

    Yup, I guess you get the player somewhere in your code. either using matchplayer or getPlayer.
    Simply check if the returned Player object is null. (or the list is empty)

    You should never do this btw:
    Code:
    Bukkit.getServer().getPlayer(args[1]).teleport(location);
    You don't know if the player returned by getPlayer exists...so it would cause an NPE because nothing/null is returned.
     
  4. Offline

    XxFuNxX

Thread Status:
Not open for further replies.

Share This Page