Package net.minestom.server.data
Class DataManager
java.lang.Object
net.minestom.server.data.DataManager
public final class DataManager
extends java.lang.Object
Manager used to register types which can be serialized and deserialized back.
Registering happens with registerType(Class, DataType)
,
you can then retrieve the DataType
with getDataType(Class)
.
A lot of types are already registered by default so you do not have to add all of them manually,
you can verify if getDataType(Class)
returns null for the desired type, if it is then you will need to register it.
-
Constructor Summary
Constructors Constructor Description DataManager()
-
Method Summary
Modifier and Type Method Description <T> DataType<T>
getDataType(java.lang.Class<T> clazz)
Gets the data type associated with a class.<T> void
registerType(java.lang.Class<T> clazz, DataType<T> dataType)
Registers a new data type.
-
Constructor Details
-
DataManager
public DataManager()
-
-
Method Details
-
registerType
Registers a new data type.- Type Parameters:
T
- the data type- Parameters:
clazz
- the data classdataType
- the data type associated- Throws:
java.lang.IllegalStateException
- if the typeclazz
is already registered
-
getDataType
Gets the data type associated with a class.- Type Parameters:
T
- the data type- Parameters:
clazz
- the data class- Returns:
- the
DataType
associated to the class, null if not found
-