Package wbs.utils.util.entities.state
Class EntityStateManager
java.lang.Object
wbs.utils.util.entities.state.EntityStateManager
A registry of classes that implement both
EntityState and ConfigurationSerializable,
so they can be referenced during deserialization of SavedEntityStates.-
Method Summary
Modifier and TypeMethodDescriptionstatic @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)static <T extends EntityState<?>>
voidRegister anEntityStatethat can be deserialized, with the function provided.
If a class is registered beforeJavaPlugin.onEnable()(such as inJavaPlugin.onLoad()) in the WbsUtils main instance, it will be automatically registered inConfigurationSerialization.static voidRegisters the classes in this registry against Bukkit'sConfigurationSerializationregistry.static voidRegistersEntityStates native to WbsUtils.
-
Method Details
-
registerNativeDeserializers
public static void registerNativeDeserializers()RegistersEntityStates native to WbsUtils. -
register
public static <T extends EntityState<?>> void register(Class<T> clazz, Function<Map<String, Object>, T> function) Register anEntityStatethat can be deserialized, with the function provided.
If a class is registered beforeJavaPlugin.onEnable()(such as inJavaPlugin.onLoad()) in the WbsUtils main instance, it will be automatically registered inConfigurationSerialization. Otherwise, it will need to be registered manually.- Type Parameters:
T- A type that extendsEntityState, for registration and deserialization methods.- Parameters:
clazz- The EntityState that class that will be produced by the provided functionfunction- The deserializer that accepts a map of String keys to objects and returns theEntityStatethat matches the given clazz.
-
registerConfigurableClasses
public static void registerConfigurableClasses()Registers the classes in this registry against Bukkit'sConfigurationSerializationregistry. -
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 bygetEscapedClassName(Class)map- The object map representing a partially deserialized object.- Returns:
- The deserialized
EntityState
-