Package ch.njol.skript.entity
Class EntityData<E extends org.bukkit.entity.Entity>
java.lang.Object
ch.njol.skript.entity.EntityData<E>
- All Implemented Interfaces:
SyntaxElement
,YggdrasilSerializable
,YggdrasilSerializable.YggdrasilExtendedSerializable
- Direct Known Subclasses:
AxolotlData
,BeeData
,BoatChestData
,BoatData
,CatData
,CreeperData
,DroppedItemData
,EndermanData
,FallingBlockData
,FoxData
,FrogData
,GoatData
,LlamaData
,MinecartData
,MooshroomData
,OcelotData
,PandaData
,ParrotData
,PigData
,RabbitData
,SheepData
,SimpleEntityData
,ThrownPotionData
,TropicalFishData
,VillagerData
,WolfData
,XpOrbData
,ZombieVillagerData
public abstract class EntityData<E extends org.bukkit.entity.Entity>
extends Object
implements SyntaxElement, YggdrasilSerializable.YggdrasilExtendedSerializable
-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.njol.yggdrasil.YggdrasilSerializable
YggdrasilSerializable.YggdrasilExtendedSerializable, YggdrasilSerializable.YggdrasilRobustEnum, YggdrasilSerializable.YggdrasilRobustSerializable
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final Adjective
static final Message
static final Adjective
protected int
static Serializer
<EntityData> protected static final boolean
protected static @Nullable Method
protected static boolean
protected static @Nullable Method
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canSpawn
(@Nullable org.bukkit.World world) Check if this entity type can spawn.void
deserialize
(Fields fields) Deserializes this object.protected boolean
Deprecated.final boolean
protected abstract boolean
equals_i
(EntityData<?> obj) static <E extends org.bukkit.entity.Entity>
EntityData<? super E> static <E extends org.bukkit.entity.Entity>
EntityData<? super E> fromEntity
(E e) protected @Nullable Adjective
static <E extends org.bukkit.entity.Entity>
E[]getAll
(EntityData<?>[] types, Class<E> type, @Nullable org.bukkit.World[] worlds) static <E extends org.bukkit.entity.Entity>
E[]getAll
(EntityData<?>[] types, Class<E> type, org.bukkit.Chunk[] chunks) E[]
getAll
(org.bukkit.World... worlds) static ch.njol.skript.entity.EntityData.EntityDataInfo
<?> getInfo
(Class<? extends EntityData<?>> c) static @Nullable ch.njol.skript.entity.EntityData.EntityDataInfo
<?> protected Noun
getName()
abstract EntityData
Returns the super type of this entity data, e.g.getType()
final int
hashCode()
protected abstract int
final boolean
init
(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) Called just after the constructor.protected abstract boolean
init
(Literal<?>[] exprs, int matchedPattern, SkriptParser.ParseResult parseResult) protected abstract boolean
isBaby()
final boolean
isInstance
(@Nullable org.bukkit.entity.Entity e) isPlural()
abstract boolean
isSupertypeOf
(EntityData<?> e) protected abstract boolean
static void
static @Nullable EntityData
<?> Prints errors.static @Nullable EntityData
<?> Prints errors.static <E extends org.bukkit.entity.Entity,
T extends EntityData<E>>
voidregister
(Class<T> dataClass, String name, Class<E> entityClass, int defaultName, String... codeNames) static <E extends org.bukkit.entity.Entity,
T extends EntityData<E>>
voidSerialises this object.abstract void
final E
spawn
(org.bukkit.Location location) Spawn this entity data at a location.protected static <E extends org.bukkit.entity.Entity>
ESpawn this entity data at a location.Deprecated.final String
toString()
toString
(int flags) static String
static String
static String
toString
(org.bukkit.entity.Entity e) static String
toString
(org.bukkit.entity.Entity e, int flags) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.njol.skript.lang.SyntaxElement
getParser
-
Field Details
-
WORLD_1_13_CONSUMER_METHOD
-
WORLD_1_13_CONSUMER
protected static final boolean WORLD_1_13_CONSUMER -
WORLD_1_17_CONSUMER_METHOD
-
WORLD_1_17_CONSUMER
protected static boolean WORLD_1_17_CONSUMER -
LANGUAGE_NODE
- See Also:
-
m_age_pattern
-
m_baby
-
m_adult
-
serializer
-
matchedPattern
protected int matchedPattern
-
-
Constructor Details
-
EntityData
public EntityData()
-
-
Method Details
-
onRegistrationStop
public static void onRegistrationStop() -
register
public static <E extends org.bukkit.entity.Entity,T extends EntityData<E>> void register(Class<T> dataClass, String name, Class<E> entityClass, String codeName) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
register
public static <E extends org.bukkit.entity.Entity,T extends EntityData<E>> void register(Class<T> dataClass, String name, Class<E> entityClass, int defaultName, String... codeNames) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
init
public final boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) Description copied from interface:SyntaxElement
Called just after the constructor.- Specified by:
init
in interfaceSyntaxElement
- Parameters:
exprs
- all %expr%s included in the matching pattern in the order they appear in the pattern. If an optional value was left out, it will still be included in this list holding the default value of the desired type, which usually depends on the event.matchedPattern
- The index of the pattern which matchedisDelayed
- Whether this expression is used after a delay or not (i.e. if the event has already passed when this expression will be called)parseResult
- Additional information about the match.- Returns:
- Whether this expression was initialised successfully. An error should be printed prior to returning false to specify the cause.
- See Also:
-
init
protected abstract boolean init(Literal<?>[] exprs, int matchedPattern, SkriptParser.ParseResult parseResult) -
init
- Parameters:
c
- An entity's class, e.g. Playere
- An actual entity, or null to get an entity data for an entity class- Returns:
- Whether initialisation was successful
-
set
-
match
-
getType
-
getSuperType
Returns the super type of this entity data, e.g. 'wolf' for 'angry wolf'.- Returns:
- The supertype of this entity data. Must not be null.
-
toString
-
getName
-
getAgeAdjective
-
toString
-
isPlural
-
isBaby
-
hashCode_i
protected abstract int hashCode_i() -
hashCode
public final int hashCode() -
equals_i
-
equals
-
getInfo
public static ch.njol.skript.entity.EntityData.EntityDataInfo<?> getInfo(Class<? extends EntityData<?>> c) -
getInfo
@Nullable public static @Nullable ch.njol.skript.entity.EntityData.EntityDataInfo<?> getInfo(String codeName) -
parse
Prints errors.- Parameters:
s
- String with optional indefinite article at the beginning- Returns:
- The parsed entity data
-
parseWithoutIndefiniteArticle
Prints errors.- Parameters:
s
-- Returns:
- The parsed entity data
-
canSpawn
public boolean canSpawn(@Nullable @Nullable org.bukkit.World world) Check if this entity type can spawn.Some entity types may be restricted by experimental datapacks.
- Parameters:
world
- World to check if entity can spawn in- Returns:
- True if entity can spawn else false
-
spawn
Spawn this entity data at a location.- Parameters:
location
- TheLocation
to spawn the entity at.- Returns:
- The Entity object that is spawned.
-
spawn
@Nullable @Deprecated public E spawn(org.bukkit.Location location, @Nullable org.bukkit.util.Consumer<E> consumer) Deprecated.Spawn this entity data at a location. The consumer allows for modification to the entity before it actually gets spawned.Bukkit's own
Consumer
is deprecated. Usespawn(Location, Consumer)
- Parameters:
location
- TheLocation
to spawn the entity at.consumer
- AConsumer
to apply the entity changes to.- Returns:
- The Entity object that is spawned.
-
spawn
Spawn this entity data at a location. The consumer allows for modification to the entity before it actually gets spawned.- Parameters:
location
- TheLocation
to spawn the entity at.consumer
- AConsumer
to apply the entity changes to.- Returns:
- The Entity object that is spawned.
-
getAll
-
getAll
public static <E extends org.bukkit.entity.Entity> E[] getAll(EntityData<?>[] types, Class<E> type, @Nullable @Nullable org.bukkit.World[] worlds) - Parameters:
types
-type
-worlds
- worlds or null for all- Returns:
- All entities of this type in the given worlds
-
getAll
public static <E extends org.bukkit.entity.Entity> E[] getAll(EntityData<?>[] types, Class<E> type, org.bukkit.Chunk[] chunks) -
fromClass
-
fromEntity
-
toString
-
toString
-
toString
-
toString
-
isInstance
public final boolean isInstance(@Nullable @Nullable org.bukkit.entity.Entity e) -
isSupertypeOf
-
serialize
Description copied from interface:YggdrasilSerializable.YggdrasilExtendedSerializable
Serialises 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:
serialize
in 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
Description copied from interface:YggdrasilSerializable.YggdrasilExtendedSerializable
Deserializes 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:
deserialize
in 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
-
deserialize
Deprecated. -
spawn
-