-
Notifications
You must be signed in to change notification settings - Fork 0
Accessing Data
Evyatar edited this page Aug 4, 2022
·
11 revisions
The API was designed mainly to perform great while providing an easy and accessible approach.
Using the class: DataRegistry, you can easily access an item's, a player's or a block's persistent data.
The method used to access persistent data is:
@Override
public void onEnable() {
PersistentDataAPI api = new PersistentDataAPI(this);
DataRegistry data = api.getDataRegistry(player/item/block object);
}After accessing an object's Dataregistry, we can use some methods:
| Method | Parameters | throws | Description | | ------------- | ------------- | ------------- | | registerData() | player / item / block, AbstractPersistentData / dataName, dataValue | DataException if data already exists | Registers a new data That wasn't registered yet | unregisterData() | player / item / block, AbstractPersistentData / dataName | DataException if data doesn't exist | Deletes a registered data