Package com.jeff_media.jefflib.data
Class OfflinePlayerPersistentDataContainer
java.lang.Object
com.jeff_media.jefflib.data.OfflinePlayerPersistentDataContainer
- All Implemented Interfaces:
PersistentDataContainer
@NMS
public class OfflinePlayerPersistentDataContainer
extends Object
implements PersistentDataContainer
Represents a
PersistentDataContainer
from an OfflinePlayer
. Important: When changing values, you have to call save()
or saveAsync()
afterwards.- Requires NMS.
-
Constructor Summary
ConstructorsConstructorDescriptionOfflinePlayerPersistentDataContainer
(PersistentDataContainer craftPersistentDataContainer, File file, Object compoundTag) -
Method Summary
Modifier and TypeMethodDescription<T,
Z> Z get
(NamespacedKey namespacedKey, PersistentDataType<T, Z> persistentDataType) getFile()
Returns the player's data .dat filegetKeys()
<T,
Z> Z getOrDefault
(NamespacedKey namespacedKey, PersistentDataType<T, Z> persistentDataType, Z z) boolean
has
(NamespacedKey namespacedKey) <T,
Z> boolean has
(NamespacedKey namespacedKey, PersistentDataType<T, Z> persistentDataType) boolean
isEmpty()
Returns an OfflinePlayer'sPersistentDataContainer
. Important: When doing changes to the PDC, you must callsave()
orsaveAsync()
to save the changes.of
(OfflinePlayer player) Returns an OfflinePlayer'sPersistentDataContainer
. Important: When doing changes to the PDC, you must callsave()
orsaveAsync()
to save the changes.void
readFromBytes
(byte[] bytes, boolean b) void
remove
(NamespacedKey namespacedKey) void
save()
Saves the data to the player's file.Saves the data to the player's file.byte[]
<T,
Z> void set
(NamespacedKey namespacedKey, PersistentDataType<T, Z> persistentDataType, Z z)
-
Constructor Details
-
OfflinePlayerPersistentDataContainer
@Internal public OfflinePlayerPersistentDataContainer(@NotNull PersistentDataContainer craftPersistentDataContainer, @NotNull File file, @NotNull Object compoundTag) - Meant for internal use only.
- , For internal use only
-
-
Method Details
-
of
Returns an OfflinePlayer'sPersistentDataContainer
. Important: When doing changes to the PDC, you must callsave()
orsaveAsync()
to save the changes. The player's .dat file must already exist, i.e. it doesn't work for players who have never joined before.- Requires NMS.
-
of
@NotNull @NMS public static CompletableFuture<OfflinePlayerPersistentDataContainer> of(OfflinePlayer player) Returns an OfflinePlayer'sPersistentDataContainer
. Important: When doing changes to the PDC, you must callsave()
orsaveAsync()
to save the changes. The player's .dat file must already exist, i.e. it doesn't work for players who have never joined before.- Requires NMS.
-
getFile
Returns the player's data .dat file -
save
Saves the data to the player's file. This will overwrite any changes made to the original file that happened after creating this instance. -
saveAsync
Saves the data to the player's file. This will overwrite any changes made to the original file that happened after creating this instance. -
set
public <T,Z> void set(@NotNull NamespacedKey namespacedKey, @NotNull PersistentDataType<T, Z> persistentDataType, @NotNull Z z) - Specified by:
set
in interfacePersistentDataContainer
-
has
public <T,Z> boolean has(@NotNull NamespacedKey namespacedKey, @NotNull PersistentDataType<T, Z> persistentDataType) - Specified by:
has
in interfacePersistentDataContainer
-
has
-
serializeToBytes
- Throws:
IOException
- Requires Paper.
-
readFromBytes
- Throws:
IOException
- Requires Paper.
-
get
public <T,Z> Z get(@NotNull NamespacedKey namespacedKey, @NotNull PersistentDataType<T, Z> persistentDataType) - Specified by:
get
in interfacePersistentDataContainer
-
getOrDefault
@NotNull public <T,Z> Z getOrDefault(@NotNull NamespacedKey namespacedKey, @NotNull PersistentDataType<T, Z> persistentDataType, @NotNull Z z) - Specified by:
getOrDefault
in interfacePersistentDataContainer
-
getKeys
- Specified by:
getKeys
in interfacePersistentDataContainer
-
remove
- Specified by:
remove
in interfacePersistentDataContainer
-
isEmpty
- Specified by:
isEmpty
in interfacePersistentDataContainer
-
getAdapterContext
- Specified by:
getAdapterContext
in interfacePersistentDataContainer
-