Okay in version 2.0 of SpongeAPI, there was a way to figure out if it’s the first time for a player to join the server through:
player.getJoinData().hasJoinedBefore();
The hasJoinedBefore() method was removed in 2.1 snapshot of SpongeAPI . Now, there are only two methods for JoinData class and they are getFirstPlayed() and getLastPlayed(). I think it’ll be too much of a hassle to figure out if a player has joined the server for the first time by figuring out the date in getFirstPlayed() method.
Like OP said, it would make more sense to have a method that determines this logic for you. Doing date and time math isn’t a fun thing to do (personally) and could be avoided entirely if there was a method provided by sponge.
If a User has NEVER logged into the server before, there wouldn’t be a JoinData to be created. Only if you call getOrCreate(JoinData.class) would it be created always for any User or Player.
@gabizou so if I’m trying to detect if a player has ever been on the server before when they join, JoinData will always be present if they have joined before or do I have to use getOrCreate(JoinData.class) to create it?
You can save player data in a file (config file for example) when connected and check in the file if this UUID is writed, if it is, the player isn’t a new player.