Package ch.njol.skript.bukkitutil
Class EntityUtils
java.lang.Object
ch.njol.skript.bukkitutil.EntityUtils
Utility class for quick
Entity methods-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intgetAge(org.bukkit.entity.Entity entity) Get the age of an ageable entity.static booleanisAdult(org.bukkit.entity.Entity entity) Quick method to check if entity is an adult.static booleanisAgeable(org.bukkit.entity.Entity entity) Check if an entity is ageable.static voidsetAdult(org.bukkit.entity.Entity entity) Quick method for making an entity an adult.static voidsetAge(org.bukkit.entity.Entity entity, int age) Set the age of an entity.static voidsetBaby(org.bukkit.entity.Entity entity) Quick method for making an entity a baby.static voidteleport(org.bukkit.entity.Entity entity, org.bukkit.Location location) Deprecated, for removal: This API element is subject to removal in a future version.this method is only used by EffTeleport, and with the recent additions of TeleportFlag, this method should be moved within that effect.static org.bukkit.entity.EntityTypetoBukkitEntityType(EntityData<?> e) Convert from Skript's EntityData to Bukkit's EntityTypestatic @Nullable org.bukkit.entity.EntityTypetoBukkitEntityType(Class<? extends org.bukkit.entity.Entity> entityClass) static EntityData<?> toSkriptEntityData(org.bukkit.entity.EntityType e) Convert from Bukkit's EntityType to Skript's EntityData
-
Constructor Details
-
EntityUtils
public EntityUtils()
-
-
Method Details
-
isAgeable
public static boolean isAgeable(org.bukkit.entity.Entity entity) Check if an entity is ageable. Some entities, such as zombies, do not have an age but can be a baby/adult.- Parameters:
entity- Entity to check- Returns:
- True if entity is ageable
-
getAge
public static int getAge(org.bukkit.entity.Entity entity) Get the age of an ageable entity. Entities such as zombies do not have an age, this will return -1 if baby, 0 if adult.- Parameters:
entity- Entity to grab age for- Returns:
- Age of entity (if zombie/piglin/zoglin -1 = baby, 0 = adult) (if not ageable, will return 0)
-
setAge
public static void setAge(org.bukkit.entity.Entity entity, int age) Set the age of an entity. Entities such as zombies do not have an age, setting below 0 will make them a baby otherwise adult.- Parameters:
entity- Entity to set age forage- Age to set
-
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
Convert from Skript's EntityData to Bukkit's EntityType- Parameters:
e- Skript's EntityData- Returns:
- Bukkit's EntityType
-
toBukkitEntityType
@Nullable public static @Nullable org.bukkit.entity.EntityType toBukkitEntityType(Class<? extends org.bukkit.entity.Entity> entityClass) Attempts to get anEntityTypefrom aClassextendingEntity. Ensures at least oneEntityTypecan represent an entity class throughClass.isAssignableFrom(Class).- Parameters:
entityClass- TheClassextendingEntity- Returns:
- The exact or assignable
EntityTypeornull
-
toSkriptEntityData
Convert from Bukkit's EntityType to Skript's EntityData- Parameters:
e- Bukkit's EntityType- Returns:
- Skript's EntityData
-
teleport
@Deprecated(since="2.10.0", forRemoval=true) public static void teleport(org.bukkit.entity.Entity entity, org.bukkit.Location location) Deprecated, for removal: This API element is subject to removal in a future version.this method is only used by EffTeleport, and with the recent additions of TeleportFlag, this method should be moved within that effect.Teleports the given entity to the given location. Teleports to the given location in the entity's world if the location's world is null.
-