I’m trying to get the player NBT in order to serialize it and store it into a database. I know that I should’nt be accessing NBT Data directly from the Sponge API but in this case that’s the only way I found to correctly syncronize player data with a database.
How should I do it ?
NBT is not exposed in the API. Instead, you can get the
player.getContainer(). It’s a tree structure similar to NBT.
Additionally, it can be exported to different formats, here are the built-in ones:
Does the DataContainer contains all the data of the player ? Even modded data ?
Yes, the DataContainer contains all player data.
OK thank you ! And is there a way to deserialize the data from the DataContainer and apply it to the player ?
Look up how custom data works.
Keep in mind the recent annoucement gabizou mentioned if you are doing an API 6 plugin. Sorry I can’t help more. Going to sleep.