Solved OfflinePlayer hasPlayedBefore() conditions

Discussion in 'Plugin Development' started by PandazNWafflez, Jul 23, 2014.

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

    PandazNWafflez

    Should I call hasPlayedBefore() on a currently online player who has just joined for the first time, would this return false, or is it updated to true the first time the player logs in straight away? If the latter is correct, how would I identify whether an online player is logging in for the first time?
     
  2. Offline

    Dragonphase

  3. Offline

    PandazNWafflez

  4. Offline

    1Rogue


    IIRC that method checks for a data file, which is only saved by their first logout. Using it would be fine.
     
  5. Offline

    PandazNWafflez

    1Rogue Welp I already finished the plugin so I'll change it the next time I update it or something :p
     
  6. Offline

    Dragonphase

    1Rogue

    So if the player had never joined the server before, that method would return null?
     
  7. Offline

    1Rogue


    No, it's a boolean return value. It checks for the file, and returns true if it exists. False otherwise.
     
  8. Offline

    Dragonphase

    1Rogue

    AsyncPlayerPreLoginEvent#getUniqueId()? The javadocs say it returns a UUID.
     
  9. Offline

    1Rogue


    Code:java
    1. public void onJoin(PlayerJoinEvent event) {
    2. if (event.getPlayer().hasPlayedBefore()) {
    3. //has played on the server before
    4. } else {
    5. //first time on the server
    6. }
    7. }
     
  10. Offline

    Dragonphase

Thread Status:
Not open for further replies.

Share This Page