Home Commands Examples Getting Started With Scripts Global Keywords

ServerPlayer

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.

script.zs
import crafttweaker.api.entity.type.player.ServerPlayer;

Extending Player

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

Methods

Gets the persistent NBT data for this player.

Persistent data is kept through deaths

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

script.zs
// ServerPlayer.getPersistentData() as MapData
myServerPlayer.getPersistentData();

Updates the persistent NBT data for this player.

Persistent data is kept through deaths

script.zs
// ServerPlayer.updatePersistentData(data as MapData)
myServerPlayer.updatePersistentData({custom: "data"});
ParameterTypeDescription
Parameter
data
Type
MapData
Description
The custom data to store.

Properties

NameTypeHas GetterHas SetterDescription
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