How does player.hasPlayedBefore work?

Discussion in 'Plugin Development' started by n31ln3t, Jul 25, 2014.

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

    n31ln3t

    I assume it checks if the username has played before or it gets the UUID of the player and then checks if that UUID played before.

    Just need to know if it checks to see if the UUID has played before because when the name changing update comes out, it will be hard to manage UUIDS.
     
  2. Offline

    AoH_Ruthless

    n31ln3t

    Player#hasPlayedBefore will return false if the player has never joined the server OR if they are playing for the first time. Upon first logout, hasPlayedBefore() will return true for that player.
     
  3. It very simple (i think it works like this):
    The method returns, if this file exists: return new File("world/players/" + player.getName() + ".dat").exists();
     
  4. Offline

    n31ln3t

    So I didn't get a specific answer:

    Does it use UUID to check if the UUID of the player defined exists or does it check if the player with only the specified name exists?
     
  5. Offline

    Zarkopafilis

    There is a playerstats folder inside the world data(or something similar to that name)
     
  6. Offline

    n31ln3t

    Still didn't get a specific answer :(

    All I find is a playerdata inside the worlds folder and that has UUIDs, so

    1234-FAKEUUID-5678.dat (as an example), so I'm assuming it gets the UUID of the player than checks to see if the player with that specific UUID has played.

    Can someone else verify this?

    Thanks.
     
  7. Offline

    fireblast709

    n31ln3t confirmed (such surprise xD)
     
    n31ln3t likes this.
  8. I FOUND THE SOLUTION!!! :D
    I looked in the javadocs:
    087 public boolean hasPlayedBefore();
    088
    089 /**
    090 * Gets the Location where the player will spawn at their bed, null if they
    091 * have not slept in one or their current bed spawn is invalid.
    092 *
    093 * @return Bed Spawn Location if bed exists, otherwise null.
    094 */
    095 public Location getBedSpawnLocation();
    096
    097 }
     
  9. Offline

    Necrodoom

    FisheyLP ....Wrong method javadoc. Scroll up. Not that it answers the question anyway.
     
    MCForger likes this.
Thread Status:
Not open for further replies.

Share This Page