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, FishData, 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
  • Field Details

    • WORLD_1_13_CONSUMER_METHOD

      protected static @Nullable Method WORLD_1_13_CONSUMER_METHOD
    • WORLD_1_13_CONSUMER

      protected static final boolean WORLD_1_13_CONSUMER
    • WORLD_1_17_CONSUMER_METHOD

      protected static @Nullable Method WORLD_1_17_CONSUMER_METHOD
    • WORLD_1_17_CONSUMER

      protected static boolean WORLD_1_17_CONSUMER
    • LANGUAGE_NODE

      public static final String LANGUAGE_NODE
      See Also:
    • m_age_pattern

      public static final Message m_age_pattern
    • m_baby

      public static final Adjective m_baby
    • m_adult

      public static final Adjective m_adult
    • serializer

      public static Serializer<EntityData> 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 interface SyntaxElement
      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 matched
      isDelayed - 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

      protected abstract boolean init(@Nullable Class<? extends E> c, @Nullable E e)
      Parameters:
      c - An entity's class, e.g. Player
      e - An actual entity, or null to get an entity data for an entity class
      Returns:
      Whether initialisation was successful
    • set

      public abstract void set(E entity)
    • match

      protected abstract boolean match(E entity)
    • getType

      public abstract Class<? extends E> getType()
    • getSuperType

      public abstract EntityData 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

      public final String toString()
      Overrides:
      toString in class Object
    • getName

      protected Noun getName()
    • getAgeAdjective

      protected @Nullable Adjective getAgeAdjective()
    • toString

      public String toString(int flags)
    • isPlural

      public Kleenean isPlural()
    • isBaby

      public Kleenean isBaby()
    • hashCode_i

      protected abstract int hashCode_i()
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • equals_i

      protected abstract boolean equals_i(EntityData<?> obj)
    • equals

      public final boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object
    • getInfo

      public static ch.njol.skript.entity.EntityData.EntityDataInfo<?> getInfo(Class<? extends EntityData<?>> c)
    • getInfo

      public static @Nullable ch.njol.skript.entity.EntityData.EntityDataInfo<?> getInfo(String codeName)
    • parse

      public static @Nullable EntityData<?> parse(String s)
      Prints errors.
      Parameters:
      s - String with optional indefinite article at the beginning
      Returns:
      The parsed entity data
    • parseWithoutIndefiniteArticle

      public static @Nullable EntityData<?> parseWithoutIndefiniteArticle(String s)
      Prints errors.
      Parameters:
      s -
      Returns:
      The parsed entity data
    • spawn

      public final @Nullable E spawn(org.bukkit.Location location)
      Spawn this entity data at a location.
      Parameters:
      location - The Location to spawn the entity at.
      Returns:
      The Entity object that is spawned.
    • spawn

      @Deprecated public @Nullable 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 modiciation to the entity before it actually gets spawned.

      Bukkit's own Consumer is deprecated. Use spawn(Location, Consumer)

      Parameters:
      location - The Location to spawn the entity at.
      consumer - A Consumer to apply the entity changes to.
      Returns:
      The Entity object that is spawned.
    • spawn

      public @Nullable E spawn(org.bukkit.Location location, @Nullable Consumer<E> consumer)
      Spawn this entity data at a location. The consumer allows for modiciation to the entity before it actually gets spawned.
      Parameters:
      location - The Location to spawn the entity at.
      consumer - A Consumer to apply the entity changes to.
      Returns:
      The Entity object that is spawned.
    • getAll

      public E[] getAll(org.bukkit.World... worlds)
    • getAll

      public static <E extends org.bukkit.entity.Entity> E[] getAll(EntityData<?>[] types, Class<E> type, @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

      public static <E extends org.bukkit.entity.Entity> EntityData<? super E> fromClass(Class<E> c)
    • fromEntity

      public static <E extends org.bukkit.entity.Entity> EntityData<? super E> fromEntity(E e)
    • toString

      public static String toString(org.bukkit.entity.Entity e)
    • toString

      public static String toString(Class<? extends org.bukkit.entity.Entity> c)
    • toString

      public static String toString(org.bukkit.entity.Entity e, int flags)
    • toString

      public static String toString(Class<? extends org.bukkit.entity.Entity> c, int flags)
    • isInstance

      public final boolean isInstance(@Nullable org.bukkit.entity.Entity e)
    • isSupertypeOf

      public abstract boolean isSupertypeOf(EntityData<?> e)
    • serialize

      public Fields serialize() throws NotSerializableException
      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 interface YggdrasilSerializable.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 serialisable
    • deserialize

      public void deserialize(Fields fields) throws StreamCorruptedException, NotSerializableException
      Description copied from interface: YggdrasilSerializable.YggdrasilExtendedSerializable
      Deserialises 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 interface YggdrasilSerializable.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 by YggdrasilSerializable.YggdrasilExtendedSerializable.serialize() or Yggrdasil's default serialisation.
      NotSerializableException
    • deserialize

      @Deprecated protected boolean deserialize(String s)
      Deprecated.
    • spawn

      protected static <E extends org.bukkit.entity.Entity> @Nullable E spawn(org.bukkit.Location location, Class<E> type, Consumer<E> consumer)