Class EntityDataClassInfo.EntityDataSerializer
java.lang.Object
ch.njol.yggdrasil.YggdrasilSerializer<EntityData>
ch.njol.skript.classes.Serializer<EntityData>
org.skriptlang.skript.bukkit.entity.EntityDataClassInfo.EntityDataSerializer
- All Implemented Interfaces:
ClassResolver
- Enclosing class:
EntityDataClassInfo
-
Field Summary
Fields inherited from class Serializer
info -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether the class should be instantiated using its nullary constructor or not.protected EntityDatadeserialize(Fields fields) Used to deserialise Bukkit objects and other stuff that cannot be instantiated, e.g.voiddeserialize(EntityData entityData, Fields fields) Deserializes an object.booleanNot currently used (everything happens on Bukkit's main thread).serialize(EntityData entityData) Serialises the given object.Methods inherited from class Serializer
canBeInstantiated, deserialize, deserialize, getClass, getID, newInstance
-
Constructor Details
-
EntityDataSerializer
public EntityDataSerializer()
-
-
Method Details
-
serialize
Description copied from class:SerializerSerialises 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:
serializein classSerializer<EntityData>- Parameters:
entityData- The object to serialise- Returns:
- A Fields object representing the object's fields to serialise. Must not be null.
- Throws:
NotSerializableException- If this object could not be serialized
-
canBeInstantiated
public boolean canBeInstantiated()Description copied from class:SerializerReturns 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:
canBeInstantiatedin classSerializer<EntityData>
-
deserialize
Description copied from class:YggdrasilSerializerDeserializes an object.Use fields.
setFields(o); to emulate the default behaviour.- Overrides:
deserializein classSerializer<EntityData>- Parameters:
entityData- The object to deserialize as returned byYggdrasilSerializer.newInstance(Class).fields- The fields read from stream
-
deserialize
protected EntityData deserialize(Fields fields) throws StreamCorruptedException, NotSerializableException Description copied from class:SerializerUsed 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:
deserializein classSerializer<EntityData>- 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).
- Throws:
StreamCorruptedException- If the given data is invalid or incompleteNotSerializableException
-
mustSyncDeserialization
public boolean mustSyncDeserialization()Description copied from class:SerializerNot currently used (everything happens on Bukkit's main thread).- Specified by:
mustSyncDeserializationin classSerializer<EntityData>- Returns:
- Whether deserialisation must be done on Bukkit's main thread.
-