[SOLVED]An internal error occured with this command it's something wrong with isOnline().

Discussion in 'Plugin Development' started by Relentless_x, Apr 8, 2011.

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

    Relentless_x

    An internal error occurred with this command it's something wrong with checking if someone is online but i don't know what?!

    Code:
    			if (commandName.equalsIgnoreCase("castrate") && getServer().getPlayer(split[0]).isOnline()) {
    				String castratee = split[0];
    				getServer().broadcastMessage(ChatColor.RED + castratee + " has been castrated by " + sender);
    				return true;			}
    NOTE: this is just a test command that i used to test what was wrong with my real command, and it turned out to be checking to see if someone is online, it says an internal error occurred while executing that command (or something along those lines) in game and in console it gives me a null pointer error, but i dont really see whats wrong with it. Thanks in advance!

    None, i really can't figure this one out, how does it check if a player is online? Does it check if they are logged on or if they exist and are logged on? Because i typed in names which probably dont exist to test it is that it? i dont know...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 13, 2016
  2. Offline

    Edward Hand

    Code:
    if (commandName.equalsIgnoreCase("castrate") && getServer().getPlayer(split[0]).isOnline()) {
    should be:
    Code:
    if (commandName.equalsIgnoreCase("castrate") && getServer().getPlayer(split[0])!= null && getServer().getPlayer(split[0]).isOnline()) {
     
    Relentless_x likes this.
  3. Offline

    Relentless_x

    thanks soo much! Worked a charm!
     
Thread Status:
Not open for further replies.

Share This Page