Package ch.njol.skript.classes
Class EnumSerializer<T extends Enum<T>>
java.lang.Object
ch.njol.yggdrasil.YggdrasilSerializer<T>
ch.njol.skript.classes.Serializer<T>
ch.njol.skript.classes.EnumSerializer<T>
- All Implemented Interfaces:
ClassResolver
Mainly kept for backwards compatibility, but also serves as
ClassResolver
for enums.-
Field Summary
Fields inherited from class ch.njol.skript.classes.Serializer
info
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns whether the class should be instantiated using its nullary constructor or not.deserialize
(Fields fields) Used to deserialise Bukkit objects and other stuff that cannot be instantiated, e.g.Deprecated.void
deserialize
(T o, Fields f) Deserializes an object.boolean
Not currently used (everything happens on Bukkit's main thread).Serialises the given object.Methods inherited from class ch.njol.skript.classes.Serializer
canBeInstantiated, deserialize, getClass, getID, newInstance
-
Constructor Details
-
EnumSerializer
-
-
Method Details
-
deserialize
Deprecated.Enum serialization has been using String serialization since Skript (2.7)- Overrides:
deserialize
in classSerializer<T extends Enum<T>>
- Parameters:
s
-- Returns:
- The deserialised object or null if the input is invalid. An error message may be logged to specify the cause.
-
mustSyncDeserialization
public boolean mustSyncDeserialization()Description copied from class:Serializer
Not currently used (everything happens on Bukkit's main thread).- Specified by:
mustSyncDeserialization
in classSerializer<T extends Enum<T>>
- Returns:
- Whether deserialisation must be done on Bukkit's main thread.
-
canBeInstantiated
public boolean canBeInstantiated()Description copied from class:Serializer
Returns whether the class should be instantiated using its nullary constructor or not. Return false if the class has no nullary constructor or if you do not have control over the source of the class (e.g. if it's from an API).You must override and use
Serializer.deserialize(Fields)
if this method returns false (Serializer.deserialize(Object, Fields)
will no be used anymore in this case).- Specified by:
canBeInstantiated
in classSerializer<T extends Enum<T>>
-
serialize
Description copied from class:Serializer
Serialises the given object.Use return new
Fields
(this); to emulate the default behaviour.This method must be thread-safe. Use
Task.callSync(Callable)
if you need to serialise on Bukkit's main thread.- Specified by:
serialize
in classSerializer<T extends Enum<T>>
- Parameters:
e
- The object to serialise- Returns:
- A Fields object representing the object's fields to serialise. Must not be null.
-
deserialize
Description copied from class:Serializer
Used to deserialise Bukkit objects and other stuff that cannot be instantiated, e.g. a plugin may and should not create a new instance ofWorld
, but useBukkit.getWorld(String)
to get an existing world object.- Overrides:
deserialize
in classSerializer<T extends Enum<T>>
- Parameters:
fields
- The Fields object that holds the information about the serialised object- Returns:
- The deserialised object. Must not be null (throw an exception instead).
-
deserialize
Description copied from class:YggdrasilSerializer
Deserializes an object.Use fields.
setFields
(o); to emulate the default behaviour.- Specified by:
deserialize
in classSerializer<T extends Enum<T>>
- Parameters:
o
- The object to deserialize as returned byYggdrasilSerializer.newInstance(Class)
.f
- The fields read from stream
-