Class DataRegistry
java.lang.Object
me.thehandsomeyoni.persistentdataapi.manager.DataRegistry
Handles all persistent data registry operations.
- Since:
- 1.0
- Author:
- TheHandsomeYoni
-
Constructor Summary
ConstructorsConstructorDescriptionDataRegistry
(org.bukkit.block.Block block) Initializes the DataRegistry of a block.DataRegistry
(org.bukkit.entity.Player player) Initializes the DataRegistry of a player.DataRegistry
(org.bukkit.inventory.ItemStack itemStack) Initializes the DataRegistry of an item. -
Method Summary
Modifier and TypeMethodDescriptionboolean
dataExists
(String dataName) Checks if a data exists.boolean
Checks if a data exists.Gets the value of a data.Gets the value of a data.byte[]
getDataAsBytes
(String dataName) Gets the value of a data as its primitive type.byte[]
Gets the value of a data as its primitive type.getKeys()
void
registerData
(String dataName, Serializable dataValue) Registers a new data with the given name and type.void
Registers a new data from a class that extends AbstractPersistentData.void
setData
(String dataName, Serializable dataValue) Changes the values of a data.void
Changes the values of a data.void
unregisterData
(String dataName) Removes a data from the data container.void
Removes a data from the data container.
-
Constructor Details
-
DataRegistry
Initializes the DataRegistry of a player.- Parameters:
player
- The player that the data is stored in.- Throws:
NullPointerException
- If the player is null.
-
DataRegistry
Initializes the DataRegistry of an item.- Parameters:
itemStack
- The item that the data is stored in.- Throws:
NullPointerException
- If the item is null.
-
DataRegistry
public DataRegistry(org.bukkit.block.Block block) throws UnacceptableBlockException, NullPointerException Initializes the DataRegistry of a block.- Parameters:
block
- The block that the data is stored in.- Throws:
UnacceptableBlockException
- If the block isn't acceptable/doesn't have a persistent data container.NullPointerException
- If the block is null.
-
-
Method Details
-
registerData
Registers a new data with the given name and type.- Parameters:
dataName
- the name of the data.dataValue
- the value of the data.- Throws:
DataException
- if the data already exists.
-
registerData
Registers a new data from a class that extends AbstractPersistentData.- Parameters:
data
- The data that is being registered. This data must extend AbstractPersistentData.- Throws:
DataException
- if the data already exists.
-
unregisterData
Removes a data from the data container.- Parameters:
dataName
- The name of the data that is being removed.- Throws:
DataException
-
unregisterData
Removes a data from the data container.- Parameters:
data
- The data that is being removed.- Throws:
DataException
-
setData
Changes the values of a data.- Parameters:
data
- the data that is being changed.
-
setData
Changes the values of a data.- Parameters:
dataName
- name of the data that is being changed.dataValue
- the new value of the data.
-
getData
Gets the value of a data.- Parameters:
dataName
- the name of the data.- Returns:
- the value of the data.
- Throws:
DataException
- if the data doesn't exist.
-
getData
Gets the value of a data.- Parameters:
data
- the data that is being gotten.- Returns:
- the value of the data.
- Throws:
DataException
- if the data doesn't exist.
-
getAllData
-
getKeys
-
getDataAsBytes
Gets the value of a data as its primitive type.- Parameters:
dataName
- the name of the data.- Returns:
- the value of the data in bytes.
- Throws:
DataException
- if the data doesn't exist.
-
getDataAsBytes
Gets the value of a data as its primitive type.- Parameters:
data
- the data that is being gotten.- Returns:
- the value of the data in bytes.
- Throws:
DataException
- if the data doesn't exist.
-
dataExists
Checks if a data exists.- Parameters:
dataName
- the name of the data.- Returns:
- true if the data exists, false if it doesn't.
-
dataExists
Checks if a data exists.- Parameters:
data
- the data that is being checked.- Returns:
- true if the data exists, false if it doesn't.
-