Class EntityUtils

java.lang.Object
org.skriptlang.skript.bukkit.entity.EntityUtils

public class EntityUtils extends Object
Utility class for quick Entity methods
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    getAge(org.bukkit.entity.Entity entity)
    Gets the age of an Entity that extends Ageable.
    static boolean
    isAdult(org.bukkit.entity.Entity entity)
    Quick method to check if entity is an adult.
    static boolean
    isAgeable(org.bukkit.entity.Entity entity)
    Deprecated, for removal: This API element is subject to removal in a future version.
    The minimum supported version of MC 1.21.4, all entities covered in this method now extend Ageable.
    static void
    setAdult(org.bukkit.entity.Entity entity)
    Quick method for making an entity an adult.
    static void
    setAge(org.bukkit.entity.Entity entity, int age)
    Sets the age of an Entity that extends Ageable.
    static void
    setBaby(org.bukkit.entity.Entity entity)
    Quick method for making an entity a baby.
    static org.bukkit.entity.EntityType
    toBukkitEntityType(Class<? extends org.bukkit.entity.Entity> entityClass)
    Attempts to get an EntityType from a Class extending Entity.
    static org.bukkit.entity.EntityType
    Get the EntityType that data correlates to.
    static EntityData<?>
    toSkriptEntityData(org.bukkit.entity.EntityType entityType)
    Gets a EntityData from the provided entityType.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EntityUtils

      public EntityUtils()
  • Method Details

    • isAgeable

      @Deprecated(since="2.17", forRemoval=true) public static boolean isAgeable(org.bukkit.entity.Entity entity)
      Deprecated, for removal: This API element is subject to removal in a future version.
      The minimum supported version of MC 1.21.4, all entities covered in this method now extend Ageable.
    • getAge

      public static int getAge(org.bukkit.entity.Entity entity)
      Gets the age of an Entity that extends Ageable.
      Parameters:
      entity - The Entity to grab the age from.
      Returns:
      The age of the Entity if Ageable, otherwise 0.
    • setAge

      public static void setAge(org.bukkit.entity.Entity entity, int age)
      Sets the age of an Entity that extends Ageable. Setting below 0 will make them a baby otherwise adult.
      Parameters:
      entity - The Entity to set the age for.
      age - The age to set to.
    • setBaby

      public static void setBaby(org.bukkit.entity.Entity entity)
      Quick method for making an entity a baby. Ageable entities (such as sheep or pigs) will set their default baby age to -24000.
      Parameters:
      entity - Entity to make baby
    • setAdult

      public static void setAdult(org.bukkit.entity.Entity entity)
      Quick method for making an entity an adult.
      Parameters:
      entity - Entity to make adult
    • isAdult

      public static boolean isAdult(org.bukkit.entity.Entity entity)
      Quick method to check if entity is an adult.
      Parameters:
      entity - Entity to check
      Returns:
      True if entity is an adult
    • toBukkitEntityType

      public static org.bukkit.entity.EntityType toBukkitEntityType(EntityData<?> data)
      Get the EntityType that data correlates to.
      Parameters:
      data - The EntityData to get the EntityType from.
      Returns:
      The correlating EntityType.
    • toBukkitEntityType

      @Nullable public static org.bukkit.entity.EntityType toBukkitEntityType(Class<? extends org.bukkit.entity.Entity> entityClass)
      Attempts to get an EntityType from a Class extending Entity. Ensures at least one EntityType can represent an entity class through Class.isAssignableFrom(Class).
      Parameters:
      entityClass - The Class extending Entity
      Returns:
      The exact or assignable EntityType or null
    • toSkriptEntityData

      public static EntityData<?> toSkriptEntityData(org.bukkit.entity.EntityType entityType)
      Gets a EntityData from the provided entityType.
      Parameters:
      entityType - The EntityType to get the EntityData.
      Returns:
      The EntityData.