Package dev.lone.itemsadder.api
Class CustomEntity
java.lang.Object
dev.lone.itemsadder.api.CustomEntity
- Direct Known Subclasses:
CustomPlayer
Class representing a custom entity in ItemsAdder
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddPassenger(org.bukkit.entity.LivingEntity passenger) Adds a passenger to this entity to the first available mount slotvoidaddViewer(org.bukkit.entity.Player player) static @Nullable CustomEntitybyAlreadySpawned(org.bukkit.entity.Entity entity) Gets a CustomEntity instance through a Bukkit Entity.static @Nullable CustomEntitySpawns a CustomEntity and returns the created CustomEntity instance, or null if Namespace and ID are invalid.static @Nullable CustomEntitySpawns a CustomEntity and returns the created CustomEntity instance, or null if Namespace and ID are invalid.static @Nullable CustomEntityconvert(String namespacedId, org.bukkit.entity.LivingEntity bukkitEntity, boolean frustumCulling, boolean noHitbox, boolean canBaseEntityBeDestroyed, boolean hideBaseEntity) Spawns a CustomEntity and returns the created CustomEntity instance, or null if Namespace and ID are invalid.static @Nullable CustomEntityconvert(String namespacedId, org.bukkit.entity.LivingEntity bukkitEntity, List<org.bukkit.entity.Player> viewers, boolean frustumCulling) Spawns a CustomEntity and returns the created CustomEntity instance, or null if Namespace and ID are invalid.voiddestroy()Completely removes this entity from the worldGet all custom entity model animations for this custom entitygetAnimationsNames(String entityNamespacedId) Get all custom entity model animations registered by its namegetBone(int index) @Nullable CustomEntity.BonegetBones()org.bukkit.entity.EntityGets the Bukkit Entity associated with this CustomEntity.booleangetId()Gets the ID of this CustomEntity.org.bukkit.LocationList<org.bukkit.inventory.ItemStack>getLoot()List<org.bukkit.inventory.ItemStack>getLoot(@Nullable org.bukkit.inventory.ItemStack tool) static List<org.bukkit.inventory.ItemStack>getLoot(org.bukkit.entity.LivingEntity bukkitEntity, @Nullable org.bukkit.inventory.ItemStack tool) @Nullable CustomEntity.MountBonegetMountBoneByPassenger(org.bukkit.entity.LivingEntity passenger) Gets theCustomEntity.MountBonecurrently ridden by the specified passenger if soGets the Namespace for this CustomEntity.Gets the Namespace and ID in the formatnamespace:idfor this CustomEntity.Returns a list of all the registered entities identifiers in the formatnamespace:idSet<org.bukkit.entity.LivingEntity>org.bukkit.entity.EntityTypegetType()Gets the Bukkit EntityType associated with this CustomEntity.booleanhasAnimation(String name) Check if this custom entity model has an animation registeredstatic booleanhasAnimation(String entityNamespacedId, String animationName) Check if a custom entity model has an animation registered by its namebooleanCheck if this entity has any mount bone and can be mounted by playersbooleanbooleanhasPassenger(org.bukkit.entity.LivingEntity passenger) static booleanisCustomEntity(UUID uuid) static booleanisCustomEntity(org.bukkit.entity.Entity entity) static booleanisInRegistry(String namespacedId) Returns true if the registry contains an entity with the specified namespaced id in the formatnamespace:idbooleanisPlayingAnimation(String name) booleanplayAnimation(String name) Plays an animationbooleanplayAnimation(String name, @Nullable Runnable callback) Plays an animation and executes an action after it's finishedvoidplayDamageEffect(boolean fire) Plays red color animation and sets entity on fire if neededstatic voidremovePassenger(org.bukkit.entity.LivingEntity passenger) Ejects this player only if it's on a custom entity.voidremoveViewer(org.bukkit.entity.Player player) voidrespawn(org.bukkit.entity.Player player) Sends respawn packets to the specified playervoidsetColorAllBones(int color) Changes color of every bone of this custom entity.voidsetEnchantedAllBones(boolean enchanted) Set enchant effect to every bone of this custom entity.voidsetFrustumCulling(boolean cull) booleansetPassenger(org.bukkit.entity.LivingEntity passenger, int ordinal) Sets the passenger of the specifiedCustomEntity.MountBonestatic @Nullable CustomEntitySpawns a CustomEntity and returns the created CustomEntity instance, or null if Namespace and ID are invalid.static @Nullable CustomEntitySpawns a CustomEntity and returns the created CustomEntity instance, or null if Namespace and ID are invalid.static @Nullable CustomEntityspawn(String namespacedId, org.bukkit.Location location, boolean frustumCulling, boolean noBase, boolean noHitbox) Spawns a CustomEntity and returns the created CustomEntity instance, or null if Namespace and ID are invalid.static @Nullable CustomEntityspawn(String namespacedId, org.bukkit.Location location, List<org.bukkit.entity.Player> viewers, boolean frustumCulling, boolean noBase, boolean noHitbox, @Nullable org.bukkit.util.Consumer<org.bukkit.entity.LivingEntity> function) Spawns a CustomEntity and returns the created CustomEntity instance, or null if Namespace and ID are invalid.static @Nullable CustomEntityspawn(String namespacedId, org.bukkit.Location location, List<org.bukkit.entity.Player> viewers, boolean frustumCulling, @Nullable org.bukkit.util.Consumer<org.bukkit.entity.LivingEntity> function) Spawns a CustomEntity and returns the created CustomEntity instance, or null if Namespace and ID are invalid.voidStops the currently playing animationvoidteleport(org.bukkit.Location location)
-
Constructor Details
-
CustomEntity
public CustomEntity()
-
-
Method Details
-
getNamespacedIdsInRegistry
Returns a list of all the registered entities identifiers in the formatnamespace:id- Returns:
- a list of Namespaces and IDs in the format
namespace:id
-
isInRegistry
Returns true if the registry contains an entity with the specified namespaced id in the formatnamespace:id- Parameters:
namespacedId- Namespace and ID in the formatnamespace:id- Returns:
- true if it contains the namespaced id, otherwise false
-
spawn
@Nullable public static @Nullable CustomEntity spawn(String namespacedId, org.bukkit.Location location) Spawns a CustomEntity and returns the created CustomEntity instance, or null if Namespace and ID are invalid.- Parameters:
namespacedId- Namespace and ID in the formatnamespace:idto get the CustomEntity from.location- the Location to spawn the CustomEntity at.- Returns:
- Possibly-null CustomEntity instance.
-
spawn
@Nullable public static @Nullable CustomEntity spawn(String namespacedId, org.bukkit.Location location, boolean frustumCulling) Spawns a CustomEntity and returns the created CustomEntity instance, or null if Namespace and ID are invalid.- Parameters:
namespacedId- Namespace and ID in the formatnamespace:idto get the CustomEntity from.location- the Location to spawn the CustomEntity at.frustumCulling- if this entity needs to be frozen if not visible by the player.- Returns:
- Possibly-null CustomEntity instance.
-
spawn
@Nullable public static @Nullable CustomEntity spawn(String namespacedId, org.bukkit.Location location, List<org.bukkit.entity.Player> viewers, boolean frustumCulling, @Nullable @Nullable org.bukkit.util.Consumer<org.bukkit.entity.LivingEntity> function) Spawns a CustomEntity and returns the created CustomEntity instance, or null if Namespace and ID are invalid.- Parameters:
namespacedId- Namespace and ID in the formatnamespace:idto get the CustomEntity from.location- the Location to spawn the CustomEntity at.viewers- the list of players which can see this entity.frustumCulling- if this entity needs to be frozen if not visible by the player.function- a function which is executed when the base entity is going to be spawned, executed at the same time of the Spigot API function: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/RegionAccessor.html#spawn%28org.bukkit.Location%2Cjava.lang.Class%2Cboolean%2Corg.bukkit.util.Consumer%29=- Returns:
- Possibly-null CustomEntity instance.
-
spawn
@Nullable public static @Nullable CustomEntity spawn(String namespacedId, org.bukkit.Location location, boolean frustumCulling, boolean noBase, boolean noHitbox) Spawns a CustomEntity and returns the created CustomEntity instance, or null if Namespace and ID are invalid.- Parameters:
namespacedId- Namespace and ID in the formatnamespace:idto get the CustomEntity from.location- the Location to spawn the CustomEntity at.frustumCulling- if this entity needs to be frozen if not visible by the player.noBase- specify if this custom entity doesn't have a Bukkit real entity as base.noHitbox- specify if this custom entity bones have the armorstands hitboxes or not.- Returns:
- Possibly-null CustomEntity instance.
-
spawn
@Nullable public static @Nullable CustomEntity spawn(String namespacedId, org.bukkit.Location location, List<org.bukkit.entity.Player> viewers, boolean frustumCulling, boolean noBase, boolean noHitbox, @Nullable @Nullable org.bukkit.util.Consumer<org.bukkit.entity.LivingEntity> function) Spawns a CustomEntity and returns the created CustomEntity instance, or null if Namespace and ID are invalid.- Parameters:
namespacedId- Namespace and ID in the formatnamespace:idto get the CustomEntity from.location- the Location to spawn the CustomEntity at.viewers- the list of players which can see this entity.frustumCulling- if this entity needs to be frozen if not visible by the player.noBase- specify if this custom entity doesn't have a Bukkit real entity as base.noHitbox- specify if this custom entity bones have the armorstands hitboxes or not.function- a function which is executed when the base entity is going to be spawned, executed at the same time of the Spigot API function: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/RegionAccessor.html#spawn%28org.bukkit.Location%2Cjava.lang.Class%2Cboolean%2Corg.bukkit.util.Consumer%29=- Returns:
- Possibly-null CustomEntity instance.
-
convert
@Nullable public static @Nullable CustomEntity convert(String namespacedId, org.bukkit.entity.LivingEntity bukkitEntity) Spawns a CustomEntity and returns the created CustomEntity instance, or null if Namespace and ID are invalid.- Parameters:
namespacedId- Namespace and ID in the formatnamespace:idto get the CustomEntity from.bukkitEntity- the Bukkit entity you want to convert.- Returns:
- Possibly-null CustomEntity instance.
-
convert
@Nullable public static @Nullable CustomEntity convert(String namespacedId, org.bukkit.entity.LivingEntity bukkitEntity, boolean frustumCulling) Spawns a CustomEntity and returns the created CustomEntity instance, or null if Namespace and ID are invalid.- Parameters:
namespacedId- Namespace and ID in the formatnamespace:idto get the CustomEntity from.bukkitEntity- the Bukkit entity you want to convert.frustumCulling- if this entity needs to be frozen if not visible by the player.- Returns:
- Possibly-null CustomEntity instance.
-
convert
@Nullable public static @Nullable CustomEntity convert(String namespacedId, org.bukkit.entity.LivingEntity bukkitEntity, boolean frustumCulling, boolean noHitbox, boolean canBaseEntityBeDestroyed, boolean hideBaseEntity) Spawns a CustomEntity and returns the created CustomEntity instance, or null if Namespace and ID are invalid.- Parameters:
namespacedId- Namespace and ID in the formatnamespace:idto get the CustomEntity from.bukkitEntity- the Bukkit entity you want to convert.frustumCulling- if this entity needs to be frozen if not visible by the player.noHitbox- specify if this custom entity bones have the armorstands hitboxes or not.canBaseEntityBeDestroyed- if the base Bukkit entity can be destroyed if the custom entities dies/is removed.hideBaseEntity- if the base Bukkit entity must be hidden on the client or not.- Returns:
- Possibly-null CustomEntity instance.
-
convert
@Nullable public static @Nullable CustomEntity convert(String namespacedId, org.bukkit.entity.LivingEntity bukkitEntity, List<org.bukkit.entity.Player> viewers, boolean frustumCulling) Spawns a CustomEntity and returns the created CustomEntity instance, or null if Namespace and ID are invalid.- Parameters:
namespacedId- Namespace and ID in the formatnamespace:idto get the CustomEntity from.bukkitEntity- the Bukkit entity you want to convert.viewers- the list of players which can see this entity.frustumCulling- if this entity needs to be frozen if not visible by the player.- Returns:
- Possibly-null CustomEntity instance.
-
byAlreadySpawned
Gets a CustomEntity instance through a Bukkit Entity.
This returns null if the provided Entity doesn't belong to a CustomEntity.- Parameters:
entity- The Bukkit Entity to get the CustomEntity from.- Returns:
- Possibly-null CustomEntity instance.
-
isCustomEntity
public static boolean isCustomEntity(org.bukkit.entity.Entity entity) -
isCustomEntity
-
getEntity
public org.bukkit.entity.Entity getEntity()Gets the Bukkit Entity associated with this CustomEntity.- Returns:
- The Bukkit Entity associated with the CustomEntity.
-
getType
public org.bukkit.entity.EntityType getType()Gets the Bukkit EntityType associated with this CustomEntity.- Returns:
- The Bukkit EntityType associated with the CustomEntity.
-
getLocation
public org.bukkit.Location getLocation() -
teleport
public void teleport(org.bukkit.Location location) -
getNamespacedID
Gets the Namespace and ID in the formatnamespace:idfor this CustomEntity.- Returns:
- String representing the namespace and ID of the CustomEntity.
-
getNamespace
Gets the Namespace for this CustomEntity.- Returns:
- String representing the namespace of the CustomEntity.
-
getId
Gets the ID of this CustomEntity.- Returns:
- String representing the ID of the CustomEntity.
-
respawn
public void respawn(org.bukkit.entity.Player player) Sends respawn packets to the specified player- Parameters:
player- the player to send packets to
-
addViewer
public void addViewer(org.bukkit.entity.Player player) -
removeViewer
public void removeViewer(org.bukkit.entity.Player player) -
setFrustumCulling
public void setFrustumCulling(boolean cull) -
getFrustumCulling
public boolean getFrustumCulling() -
playAnimation
Plays an animation and executes an action after it's finished- Parameters:
name- the animation namecallback- the action to be executed after the animation is finished- Returns:
- true if the animation was played, otherwise false
-
playAnimation
Plays an animation- Parameters:
name- the animation name- Returns:
- true if the animation was played, otherwise false
-
stopAnimation
public void stopAnimation()Stops the currently playing animation -
isPlayingAnimation
-
hasAnimation
Check if a custom entity model has an animation registered by its name- Parameters:
entityNamespacedId- the custom entity identifier in the formatnamespace:idanimationName- the animation name- Returns:
- true if the animation exists, otherwise false
-
hasAnimation
Check if this custom entity model has an animation registered- Parameters:
name- the animation name- Returns:
- true if the animation exists, otherwise false
-
getAnimationsNames
Get all custom entity model animations registered by its name- Parameters:
entityNamespacedId- the custom entity identifier in the formatnamespace:id- Returns:
- a list of the animations registered for a custom entity
-
getAnimationsNames
Get all custom entity model animations for this custom entity- Returns:
- a list of the animations registered for a custom entity
-
destroy
public void destroy()Completely removes this entity from the world -
playDamageEffect
public void playDamageEffect(boolean fire) Plays red color animation and sets entity on fire if needed- Parameters:
fire- if the fire animation must be played or not
-
setColorAllBones
public void setColorAllBones(int color) Changes color of every bone of this custom entity.- Parameters:
color- the color, can be obtained with tools like this: https://minecraftcommand.science/armor-color
-
setEnchantedAllBones
public void setEnchantedAllBones(boolean enchanted) Set enchant effect to every bone of this custom entity.- Parameters:
enchanted- true if enchanted, otherwise false.
-
hasMountBones
public boolean hasMountBones()Check if this entity has any mount bone and can be mounted by players- Returns:
- true if it can be mounted, otherwise false
-
addPassenger
public boolean addPassenger(org.bukkit.entity.LivingEntity passenger) Adds a passenger to this entity to the first available mount slot- Parameters:
passenger- the player to mount- Returns:
- true if successful, otherwise false
-
removePassenger
public static void removePassenger(org.bukkit.entity.LivingEntity passenger) Ejects this player only if it's on a custom entity.- Parameters:
passenger- the player to eject
-
getPassengers
-
hasPassenger
public boolean hasPassenger(org.bukkit.entity.LivingEntity passenger) - Parameters:
passenger- passengerEntityto check- Returns:
trueif this passenger rides the customEntity, otherwisefalse
-
hasPassenger
public boolean hasPassenger()- Returns:
trueif there is at least one passenger, otherwisefalse
-
setPassenger
public boolean setPassenger(org.bukkit.entity.LivingEntity passenger, int ordinal) throws IllegalArgumentException, IndexOutOfBoundsException Sets the passenger of the specifiedCustomEntity.MountBone- Parameters:
passenger- passenger to setordinal- index of theCustomEntity.MountBone- Returns:
trueif the passenger was successfully set- Throws:
IllegalArgumentException- if there is noCustomEntity.MountBonewith such indexIndexOutOfBoundsException
-
getBones
- Returns:
- all bones of the current
CustomEntity
-
getMountBones
- Returns:
- all mount bones of the current
CustomEntity
-
getBone
- Parameters:
index- bone index within theCustomEntity- Returns:
CustomEntity.Boneat the specified index- Throws:
IndexOutOfBoundsException- if there is no bone with such index
-
getBone
- Parameters:
name- bone name- Returns:
CustomEntity.Boneat the specified name. Returns null if not found.
-
getMountBoneByPassenger
@Nullable public @Nullable CustomEntity.MountBone getMountBoneByPassenger(org.bukkit.entity.LivingEntity passenger) Gets theCustomEntity.MountBonecurrently ridden by the specified passenger if so- Parameters:
passenger- passenger to check- Returns:
- Optional of the
CustomEntity.MountBone. Not empty if there is such passenger
-
getLoot
-
getLoot
public List<org.bukkit.inventory.ItemStack> getLoot(@Nullable @Nullable org.bukkit.inventory.ItemStack tool) -
getLoot
public static List<org.bukkit.inventory.ItemStack> getLoot(org.bukkit.entity.LivingEntity bukkitEntity, @Nullable @Nullable org.bukkit.inventory.ItemStack tool)
-