Class EntityType
java.lang.Object
ch.njol.skript.entity.EntityType
org.skriptlang.skript.bukkit.entity.EntityType
- All Implemented Interfaces:
YggdrasilSerializable, YggdrasilSerializable.YggdrasilExtendedSerializable, Cloneable
public class EntityType
extends EntityType
implements Cloneable, YggdrasilSerializable.YggdrasilExtendedSerializable
Class that represents x amount of an
EntityData-
Nested Class Summary
Nested classes/interfaces inherited from interface YggdrasilSerializable
YggdrasilSerializable.YggdrasilExtendedSerializable, YggdrasilSerializable.YggdrasilRobustEnum, YggdrasilSerializable.YggdrasilRobustSerializable -
Field Summary
Fields inherited from class EntityType
amount, data -
Constructor Summary
ConstructorsConstructorDescriptionUsed for deserialization.EntityType(EntityData<?> entityData, int amount) Constructs a newEntityType. -
Method Summary
Modifier and TypeMethodDescriptionclone()voiddeserialize(@NotNull Fields fields) Deserializes this object.booleanintEntityData<?> getData()inthashCode()booleanisInstance(org.bukkit.entity.Entity entity) Whetherentityis instance ofthis.static @Nullable EntityTypebooleansameType(EntityType other) Whetherotherhas the sameEntityData.Serialises this object.voidsetAmount(int entityAmount) Sets the amountthiscorresponds to withgetData().toString()toString(int flags) Returns the string representation ofthis.Methods inherited from class EntityType
sameType
-
Constructor Details
-
EntityType
@Internal public EntityType()Used for deserialization. -
EntityType
Constructs a newEntityType.- Parameters:
entityData- The correspondingEntityData.amount- The amount ofdata.
-
-
Method Details
-
parse
Parses the providedstringinto aEntityDataand stores in a newEntityType.The
stringallows formats of "number + entity" and "article + entity", but never "article + number + entity" or "number + article + entity". Allowed: - 1 zombie, 3 pigs, 5 endermen - a zombie, a pig, an endermen Not-Allowed: - a 1 zombie, a 3 pigs, an 5 endermen - 1 a zombie, 3 a pigs, 5 an endermen- Parameters:
string- TheStringto parse.- Returns:
EntityTypecontaining the parsedEntityDataand provided amount if present instringor -1 if not present. Otherwisenullif the parse failed.
-
isInstance
public boolean isInstance(org.bukkit.entity.Entity entity) Whetherentityis instance ofthis.- Overrides:
isInstancein classEntityType- Parameters:
entity- TheEntityto check.- Returns:
trueif instance of, otherwisefalse.- See Also:
-
toString
- Overrides:
toStringin classEntityType
-
toString
Returns the string representation ofthis.- Overrides:
toStringin classEntityType- Parameters:
flags- The flags to determine singular or plurality.- Returns:
- The string representation.
-
getAmount
public int getAmount()- Overrides:
getAmountin classEntityType- Returns:
- The amount of
thiscorresponds to withgetData().
-
setAmount
public void setAmount(int entityAmount) Sets the amountthiscorresponds to withgetData().- Parameters:
entityAmount- The new amount.
-
getData
- Returns:
- The
EntityDatathiscorresponds to.
-
sameType
Whetherotherhas the sameEntityData.- Parameters:
other- The otherEntityType.- Returns:
trueif theEntityDatas are the same, otherwisefalse.- See Also:
-
clone
- Overrides:
clonein classEntityType
-
hashCode
public int hashCode()- Overrides:
hashCodein classEntityType
-
equals
- Overrides:
equalsin classEntityType
-
serialize
Description copied from interface:YggdrasilSerializable.YggdrasilExtendedSerializableSerialises this object. Only fields contained in the returned Fields object will be written to stream.You can use return new
Fields(this); to emulate the default behaviour.- Specified by:
serializein interfaceYggdrasilSerializable.YggdrasilExtendedSerializable- Returns:
- A Fields object containing all fields that should be written to stream
- Throws:
NotSerializableException- If this object or one of its fields is not serializable
-
deserialize
public void deserialize(@NotNull @NotNull Fields fields) throws StreamCorruptedException, NotSerializableException Description copied from interface:YggdrasilSerializable.YggdrasilExtendedSerializableDeserializes this object. No fields have been set when this method is called, use fields.setFields(this, yggdrasil) to set all compatible non-transient and non-static fields (and call incompatible/missing field handlers if applicable – this implies that errors will be thrown if the fields object is invalid).You can use fields.
setFields(this); to emulate the default behaviour.- Specified by:
deserializein interfaceYggdrasilSerializable.YggdrasilExtendedSerializable- Parameters:
fields- A Fields object containing all fields read from stream- Throws:
StreamCorruptedException- If the Fields object is invalid, i.e. was not written byYggdrasilSerializable.YggdrasilExtendedSerializable.serialize()or Yggdrasil's default serialisation.NotSerializableException
-