Class ConfigurationSerialization
java.lang.Object
org.bukkit.configuration.serialization.ConfigurationSerialization
Utility class for storing and retrieving classes for
Configuration
.-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
ConfigurationSerialization
(Class<? extends ConfigurationSerializable> clazz) -
Method Summary
Modifier and TypeMethodDescriptiondeserialize
(Map<String, ?> args) static ConfigurationSerializable
deserializeObject
(Map<String, ?> args) Attempts to deserialize the given arguments into a new instance of the given class.static ConfigurationSerializable
deserializeObject
(Map<String, ?> args, Class<? extends ConfigurationSerializable> clazz) Attempts to deserialize the given arguments into a new instance of the given class.protected ConfigurationSerializable
deserializeViaCtor
(Constructor<? extends ConfigurationSerializable> ctor, Map<String, ?> args) protected ConfigurationSerializable
deserializeViaMethod
(Method method, Map<String, ?> args) static String
getAlias
(Class<? extends ConfigurationSerializable> clazz) Gets the correct alias for the givenConfigurationSerializable
classstatic Class
<? extends ConfigurationSerializable> getClassByAlias
(String alias) Attempts to get a registeredConfigurationSerializable
class by its aliasprotected Constructor
<? extends ConfigurationSerializable> protected Method
static void
registerClass
(Class<? extends ConfigurationSerializable> clazz) Registers the givenConfigurationSerializable
class by its aliasstatic void
registerClass
(Class<? extends ConfigurationSerializable> clazz, String alias) Registers the given alias to the specifiedConfigurationSerializable
classstatic void
unregisterClass
(Class<? extends ConfigurationSerializable> clazz) Unregisters any aliases for the specifiedConfigurationSerializable
classstatic void
unregisterClass
(String alias) Unregisters the specified alias to aConfigurationSerializable
-
Field Details
-
SERIALIZED_TYPE_KEY
- See Also:
-
-
Constructor Details
-
ConfigurationSerialization
-
-
Method Details
-
getMethod
-
getConstructor
-
deserializeViaMethod
@Nullable protected ConfigurationSerializable deserializeViaMethod(@NotNull Method method, @NotNull Map<String, ?> args) -
deserializeViaCtor
@Nullable protected ConfigurationSerializable deserializeViaCtor(@NotNull Constructor<? extends ConfigurationSerializable> ctor, @NotNull Map<String, ?> args) -
deserialize
-
deserializeObject
@Nullable public static ConfigurationSerializable deserializeObject(@NotNull Map<String, ?> args, @NotNull Class<? extends ConfigurationSerializable> clazz) Attempts to deserialize the given arguments into a new instance of the given class.The class must implement
ConfigurationSerializable
, including the extra methods as specified in the javadoc of ConfigurationSerializable.If a new instance could not be made, an example being the class not fully implementing the interface, null will be returned.
- Parameters:
args
- Arguments for deserializationclazz
- Class to deserialize into- Returns:
- New instance of the specified class
-
deserializeObject
Attempts to deserialize the given arguments into a new instance of the given class.The class must implement
ConfigurationSerializable
, including the extra methods as specified in the javadoc of ConfigurationSerializable.If a new instance could not be made, an example being the class not fully implementing the interface, null will be returned.
- Parameters:
args
- Arguments for deserialization- Returns:
- New instance of the specified class
-
registerClass
Registers the givenConfigurationSerializable
class by its alias- Parameters:
clazz
- Class to register
-
registerClass
public static void registerClass(@NotNull Class<? extends ConfigurationSerializable> clazz, @NotNull String alias) Registers the given alias to the specifiedConfigurationSerializable
class- Parameters:
clazz
- Class to registeralias
- Alias to register as- See Also:
-
unregisterClass
Unregisters the specified alias to aConfigurationSerializable
- Parameters:
alias
- Alias to unregister
-
unregisterClass
Unregisters any aliases for the specifiedConfigurationSerializable
class- Parameters:
clazz
- Class to unregister
-
getClassByAlias
@Nullable public static Class<? extends ConfigurationSerializable> getClassByAlias(@NotNull String alias) Attempts to get a registeredConfigurationSerializable
class by its alias- Parameters:
alias
- Alias of the serializable- Returns:
- Registered class, or null if not found
-
getAlias
Gets the correct alias for the givenConfigurationSerializable
class- Parameters:
clazz
- Class to get alias for- Returns:
- Alias to use for the class
-