Importing the class

Link to importing-the-class

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

ZenScript
Copy
import crafttweaker.api.entity.type.player.ServerPlayer;

Extending Player

Link to extending-player

ServerPlayer extends Player. That means all methods available in Player are also available in ServerPlayer

Link to getPersistentData

Name: getPersistentData

Gets the persistent NBT data for this player.

Persistent data is kept through deaths

Returns: The persistent data for this Entity.
Return Type: MapData

ZenScript
Copy
// ServerPlayer.getPersistentData() as MapData

myServerPlayer.getPersistentData();

Link to updatePersistentData

Name: updatePersistentData

Updates the persistent NBT data for this player.

Persistent data is kept through deaths

ZenScript
Copy
// ServerPlayer.updatePersistentData(data as MapData)

myServerPlayer.updatePersistentData({custom: "data"});
ParameterTypeDescription
Parameter
data
Type
MapData
Description
The custom data to store.
NameTypeHas GetterHas SetterDescription
Name
advancements
Type
PlayerAdvancements
Has Getter
true
Has Setter
false
Description
Gets the PlayerAdvancements for this player.
Name
persistentData
Type
MapData
Has Getter
true
Has Setter
false
Description
Gets the persistent NBT data for this player.

Persistent data is kept through deaths