Title is self explanatory
EDIT: I need to check my title.
You can check the JoinData#firstPlayed()
- if it’s present they’ve played before.
Or you can use Keys.FIRST_DATE_PLAYED
too.
Ignore the above - I believe JoinData
will not even exist if they have not played before. That should be the way you check eg with Player#get(JoinData.class).isPresent()
The absolute best way is checking ClientConnectionEvent.Join
, since you have the Player
object, you can get the join date from Keys.FIRST_JOIN_DATE
and Keys.LAST_PLAY_DATE
and check if both Instant
objects are the same.
Edit: Note that with our awesomeness, we also preserve old Bukkit data specifically dictating the previous login date and first join date if the world is being launched with Sponge for the first time. This allows for easy drop in of Bukkit worlds into Sponge without worrying that all that information is lost
Hmm… dangit. I’m getting a “Null Pointer Exception” error on a ClientConnectionEvent.Join:
Optional<Instant> first = event.getTargetEntity().get(Keys.FIRST_DATE_PLAYED)
However, using ZephireNZ’s approach worked, and seemed much less code-y.