Problem with getplayer coming out NULL

Discussion in 'Plugin Development' started by chriztopia, Jul 9, 2013.

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

    chriztopia

    Code:
    String[] loc = in1.readLine().split(":");
     
    loc.toString(); 
     
    //Loc1 is Command
    //Loc2 is Player
     
     
    if (loc[1].equals("heal")){
     
     
    Bukkit.getServer().getPlayer("chriztopia").setHealth(20);
     
    Bukkit.getServer().getPlayer("chriztopia").sendMessage("From Server: " + loc[2] + " you have been healed!");
    }
     
    
    Using the exact username as "chriztopia" works fine but if I attempt to use loc[2] it returns NULL...
     
  2. Offline

    adam753

    What string are you passing in from in1?
     
  3. Offline

    Pawnguy7

    Not sure what you are trying to do here.

    If it is null, then it is null. Not sure how you are getting it in the first place.

    As far as getPlayer goes, it returns null if the player is offline/non existant.
     
  4. Offline

    Ragnazar

    chriztopia
    If you means loc array is player location, so use player.getLocation()
    You can extract x,y,z,world from Location
     
  5. Offline

    chriztopia

    The string is test:heal:playersid my test broadcast message shows the players name correctly but it returns a null for getplayer. And as for it being names loc that has nothing to do with anything lol.
     
  6. chriztopia
    do this:
    Code:
    if (loc2 == null){
    //do stuff because the player isn't online
    }
    Dont know if that is what doesn't work.
     
Thread Status:
Not open for further replies.

Share This Page