#Custom player data
1 messages · Page 1 of 1 (latest)
what player nbt are you saving?
i am serializing entire player object to make it persistent across servers
pretty much everything that's saved to level.dat for the player
<player>.dat files are used by servers to store the state of individual players. The format is also used within level.dat files to store the state of the singleplayer player, which overrides any <player>.dat files with the same name as the singleplayer player. These files are in NBT format.
and i have some custom plugin specific data assigned to each user like next time the user can use an item or cooldowns
a player object is saved into the .dat files right?
it's and also it's serialized and saved to my mongodb so that other servers can access it
ah i understand where you're talking about, you're trying to get the same state of the player on a different server
yup
hmm this is beyond my knowledge
i have that working - i just don't know is it better to save my custom properties in wrapper class like
class User {
private final Player player;
private int points;
private int nextSpecialItemUse;
}
or PersistentDataContainer on the Player itself.
i wouldn't store the actual player object
since it can become invalid
whenever the player leaves the server
obviously i save it and remove player object onQuit, the wrapper class is just for my plugin internals
then i just call ServerPlayer::restoreFrom(ServerPlayer oldPlayer, boolean alive) onJoin where oldPlayer is my database serialized player
and load custom data for my User.class
at this point it just seems as a better solution to use PersistentDataContainer if it works how I think it is
you can store primitives and strings in it
i can store byte[] - thus everything
i don't have anything big to store, skill cooldowns, points etc.
i think it would be better to store it in some type of file/ db
I do, i just don't know if it's better to store player and custom data separately or custom data inside PersistentDataStorage (which i assume just adds it to player's CompoundTag which i do save anyway)
well i think its useless to store it in the pdc as its a new server and the pdc is different there for the player than the other server
that's why i am overwriting it using NMS on the new server