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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • registerType

      public <T> void registerType​(@NotNull java.lang.Class<T> clazz, @NotNull DataType<T> dataType)
      Registers a new data type.
      Type Parameters:
      T - the data type
      Parameters:
      clazz - the data class
      dataType - the data type associated
      Throws:
      java.lang.IllegalStateException - if the type clazz is already registered
    • getDataType

      @Nullable public <T> DataType<T> getDataType​(@NotNull java.lang.Class<T> clazz)
      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