Class EntityStateManager

java.lang.Object
wbs.utils.util.entities.state.EntityStateManager

public final class EntityStateManager extends Object
A registry of classes that implement both EntityState and ConfigurationSerializable, so they can be referenced during deserialization of SavedEntityStates.
  • Method Details

    • registerNativeDeserializers

      public static void registerNativeDeserializers()
      Registers EntityStates native to WbsUtils.
    • register

      public static <T extends EntityState<?>> void register(Class<T> clazz, Function<Map<String,Object>,T> function)
      Register an EntityState that can be deserialized, with the function provided.
      If a class is registered before JavaPlugin.onEnable() (such as in JavaPlugin.onLoad()) in the WbsUtils main instance, it will be automatically registered in ConfigurationSerialization. Otherwise, it will need to be registered manually.
      Type Parameters:
      T - A type that extends EntityState, for registration and deserialization methods.
      Parameters:
      clazz - The EntityState that class that will be produced by the provided function
      function - The deserializer that accepts a map of String keys to objects and returns the EntityState that matches the given clazz.
    • registerConfigurableClasses

      public static void registerConfigurableClasses()
      Registers the classes in this registry against Bukkit's ConfigurationSerialization registry.
    • deserialize

      @Nullable public static @Nullable EntityState<?> deserialize(String escapedClassName, Map<String,Object> map)
      Converts the given map to the class represented by the class name (escaped for use in serialization)
      Parameters:
      escapedClassName - The class name, escaped by getEscapedClassName(Class)
      map - The object map representing a partially deserialized object.
      Returns:
      The deserialized EntityState