Access offline player data

Discussion in 'Spigot Plugin Development' started by MisterSyx, Jun 5, 2017.

Thread Status:
Not open for further replies.
  1. Hello,

    I need to get the level of an offline player and also change it. I have tried tried using OfflinePlayer, however, #getPlayer() returns null and OfflinePlayer itself doesn't offer the needed methods.
    Do I have to work with NBT or is there any library that does that for me?

    Thanks in advance.
  2. I see two options here:
    1. Save the player's XP to a file on disk anytime they log out. If the file doesn't exist, they haven't joined and so their XP is 0.
    2. Read from the .dat files in the server's ./world/playerdata folder
    • Agree Agree x 1
    • Winner Winner x 1
  3. Maybe you could trick bukkit into thinking the player has come online, get the data and trick bubbkit into thinking the player has left.
  4. Hello,

    thanks for your replies. I solved the problem by using an ImprovedOfflinePlayer class provided in the bukkit forums. It basically reads and writes NBT data, updating it to support UUIDs shouldn't be that hard. You can google it if you need it.

Thread Status:
Not open for further replies.