Class EntityMock

All Implemented Interfaces:
MessageTarget, net.kyori.adventure.audience.Audience, net.kyori.adventure.pointer.Pointered, net.kyori.adventure.sound.Sound.Emitter, net.kyori.adventure.text.event.HoverEventSource<net.kyori.adventure.text.event.HoverEvent.ShowEntity>, CommandSender, Entity, Metadatable, Nameable, Permissible, ServerOperator, PersistentDataHolder
Direct Known Subclasses:
AbstractProjectileMock, ExperienceOrbMock, HangingMock, ItemEntityMock, LivingEntityMock, SimpleEntityMock, VehicleMock

public abstract class EntityMock extends Entity.Spigot implements Entity, MessageTarget
Mock implementation of an Entity.
See Also:
  • Field Details

    • server

      @NotNull protected final @NotNull ServerMock server
  • Constructor Details

    • EntityMock

      protected EntityMock(@NotNull @NotNull ServerMock server, @NotNull @NotNull UUID uuid)
      Constructs a new EntityMock on the provided ServerMock with a specified UUID.
      Parameters:
      server - The server to create the entity on.
      uuid - The UUID of the entity.
  • Method Details

    • hashCode

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

      public final boolean equals(Object obj)
      Overrides:
      equals in class Object
    • assertLocation

      public void assertLocation(@NotNull @NotNull Location expectedLocation, double maximumDistance)
      Assert that the actual location of the player is within a certain distance to a given location.
      Parameters:
      expectedLocation - The location the player should be at.
      maximumDistance - The distance the player may maximumly be separated from the expected location.
    • assertTeleported

      public void assertTeleported(@NotNull @NotNull Location expectedLocation, double maximumDistance)
      Assert that the player teleported to a certain location within a certain distance to a given location. Also clears the teleported flag.
      Parameters:
      expectedLocation - The location the player should be at.
      maximumDistance - The distance the player may maximumly be separated from the expected location.
    • assertNotTeleported

      public void assertNotTeleported()
      Assert that the player hasn't teleported. Also clears the teleported flag.
    • hasTeleported

      public boolean hasTeleported()
      Checks if the player has been teleported since the last assert or clearTeleported().
      Returns:
      true if the player has been teleported, false if he hasn't been teleported.
    • clearTeleported

      public void clearTeleported()
      Clears the teleported flag.
    • getTeleportCause

      public PlayerTeleportEvent.TeleportCause getTeleportCause()
      Get the cause of the last teleport.
      Returns:
      The cause of the last teleport.
    • getUniqueId

      @NotNull public @NotNull UUID getUniqueId()
      Specified by:
      getUniqueId in interface Entity
    • getLocation

      @NotNull public @NotNull Location getLocation()
      Specified by:
      getLocation in interface Entity
    • getTrackedPlayers

      @NotNull public @NotNull Set<Player> getTrackedPlayers()
      Specified by:
      getTrackedPlayers in interface Entity
    • getLocation

      public Location getLocation(@Nullable @Nullable Location loc)
      Specified by:
      getLocation in interface Entity
    • setLocation

      public void setLocation(@NotNull @NotNull Location location)
      Sets the location of the entity. Note that this will not fire a teleport event.
      Parameters:
      location - The new location of the entity.
    • getWorld

      @NotNull public @NotNull WorldMock getWorld()
      Specified by:
      getWorld in interface Entity
    • setMetadata

      public void setMetadata(@NotNull @NotNull String metadataKey, @NotNull @NotNull MetadataValue newMetadataValue)
      Specified by:
      setMetadata in interface Metadatable
    • getMetadata

      @NotNull public @NotNull List<MetadataValue> getMetadata(@NotNull @NotNull String metadataKey)
      Specified by:
      getMetadata in interface Metadatable
    • hasMetadata

      public boolean hasMetadata(@NotNull @NotNull String metadataKey)
      Specified by:
      hasMetadata in interface Metadatable
    • removeMetadata

      public void removeMetadata(@NotNull @NotNull String metadataKey, @NotNull @NotNull Plugin owningPlugin)
      Specified by:
      removeMetadata in interface Metadatable
    • getPersistentDataContainer

      @NotNull public @NotNull PersistentDataContainer getPersistentDataContainer()
      Specified by:
      getPersistentDataContainer in interface PersistentDataHolder
    • teleport

      public boolean teleport(@NotNull @NotNull Location location)
      Specified by:
      teleport in interface Entity
    • teleport

      public boolean teleport(@NotNull @NotNull Location location, @NotNull @NotNull PlayerTeleportEvent.TeleportCause cause)
      Specified by:
      teleport in interface Entity
    • teleport

      public boolean teleport(@NotNull @NotNull Location location, @NotNull @NotNull PlayerTeleportEvent.TeleportCause cause, TeleportFlag @NotNull ... flags)
      Specified by:
      teleport in interface Entity
    • teleportWithoutEvent

      protected void teleportWithoutEvent(@NotNull @NotNull Location location, @NotNull @NotNull PlayerTeleportEvent.TeleportCause cause)
      Handles teleporting an entity without firing an event. This will set the entity to the new location, mark teleport as true, and set the teleport cause.
      Parameters:
      location - The location to teleport to.
      cause - The teleport cause.
    • teleport

      public boolean teleport(@NotNull @NotNull Entity destination)
      Specified by:
      teleport in interface Entity
    • teleport

      public boolean teleport(@NotNull @NotNull Entity destination, @NotNull @NotNull PlayerTeleportEvent.TeleportCause cause)
      Specified by:
      teleport in interface Entity
    • isOp

      public boolean isOp()
      Specified by:
      isOp in interface ServerOperator
    • setOp

      public void setOp(boolean isOperator)
      Specified by:
      setOp in interface ServerOperator
    • getName

      @NotNull public @NotNull String getName()
      Specified by:
      getName in interface CommandSender
    • getScoreboardEntry

      @NotNull public @NotNull String getScoreboardEntry()
      Gets the scoreboard entry for this entity.
      Returns:
      The scoreboard entry.
    • setName

      public void setName(@NotNull @NotNull String name)
      Sets the name of this entity.
      Parameters:
      name - The new name of the entity.
    • sendMessage

      public void sendMessage(@NotNull @NotNull String message)
      Specified by:
      sendMessage in interface CommandSender
    • sendMessage

      public void sendMessage(String... messages)
      Specified by:
      sendMessage in interface CommandSender
    • sendMessage

      public void sendMessage(@Nullable @Nullable UUID sender, @NotNull @NotNull String message)
      Specified by:
      sendMessage in interface CommandSender
    • sendMessage

      public void sendMessage(UUID sender, String @NotNull ... messages)
      Specified by:
      sendMessage in interface CommandSender
    • sendMessage

      public void sendMessage(@NotNull @NotNull net.kyori.adventure.identity.Identity source, @NotNull @NotNull net.kyori.adventure.text.Component message, @NotNull @NotNull net.kyori.adventure.audience.MessageType type)
      Specified by:
      sendMessage in interface net.kyori.adventure.audience.Audience
      Specified by:
      sendMessage in interface CommandSender
    • nextComponentMessage

      @Nullable public @Nullable net.kyori.adventure.text.Component nextComponentMessage()
      Description copied from interface: MessageTarget
      Returns the next message that was sent to the target.
      Specified by:
      nextComponentMessage in interface MessageTarget
      Returns:
      The next message sent to the target.
    • isPermissionSet

      public boolean isPermissionSet(@NotNull @NotNull String name)
      Specified by:
      isPermissionSet in interface Permissible
    • isPermissionSet

      public boolean isPermissionSet(@NotNull @NotNull Permission perm)
      Specified by:
      isPermissionSet in interface Permissible
    • hasPermission

      public boolean hasPermission(@NotNull @NotNull String name)
      Specified by:
      hasPermission in interface Permissible
    • hasPermission

      public boolean hasPermission(@NotNull @NotNull Permission perm)
      Specified by:
      hasPermission in interface Permissible
    • addAttachment

      @NotNull public @NotNull PermissionAttachment addAttachment(@NotNull @NotNull Plugin plugin, @NotNull @NotNull String name, boolean value)
      Specified by:
      addAttachment in interface Permissible
    • addAttachment

      @NotNull public @NotNull PermissionAttachment addAttachment(@NotNull @NotNull Plugin plugin)
      Specified by:
      addAttachment in interface Permissible
    • addAttachment

      public PermissionAttachment addAttachment(@NotNull @NotNull Plugin plugin, @NotNull @NotNull String name, boolean value, int ticks)
      Specified by:
      addAttachment in interface Permissible
    • addAttachment

      public PermissionAttachment addAttachment(@NotNull @NotNull Plugin plugin, int ticks)
      Specified by:
      addAttachment in interface Permissible
    • removeAttachment

      public void removeAttachment(@NotNull @NotNull PermissionAttachment attachment)
      Specified by:
      removeAttachment in interface Permissible
    • recalculatePermissions

      public void recalculatePermissions()
      Specified by:
      recalculatePermissions in interface Permissible
    • getEffectivePermissions

      @NotNull public @NotNull Set<PermissionAttachmentInfo> getEffectivePermissions()
      Specified by:
      getEffectivePermissions in interface Permissible
    • customName

      @Nullable public @Nullable net.kyori.adventure.text.Component customName()
      Specified by:
      customName in interface Nameable
    • customName

      public void customName(@Nullable @Nullable net.kyori.adventure.text.Component customName)
      Specified by:
      customName in interface Nameable
    • getCustomName

      public String getCustomName()
      Specified by:
      getCustomName in interface Nameable
    • setCustomName

      public void setCustomName(@Nullable @Nullable String name)
      Specified by:
      setCustomName in interface Nameable
    • setVelocity

      public void setVelocity(@NotNull @NotNull Vector velocity)
      Specified by:
      setVelocity in interface Entity
    • getVelocity

      @NotNull public @NotNull Vector getVelocity()
      Specified by:
      getVelocity in interface Entity
    • getHeight

      public double getHeight()
      Specified by:
      getHeight in interface Entity
    • getWidth

      public double getWidth()
      Specified by:
      getWidth in interface Entity
    • getEntityState

      protected EntityState getEntityState()
      Get the current state of this entity
      Returns:
      The current state of this entity
    • getSubType

      protected EntitySubType getSubType()
      Get the current subtype of the entity
      Returns:
      The current subtype of the entity
    • isOnGround

      public boolean isOnGround()
      Specified by:
      isOnGround in interface Entity
    • getNearbyEntities

      @NotNull public @NotNull List<Entity> getNearbyEntities(double x, double y, double z)
      Specified by:
      getNearbyEntities in interface Entity
    • getEntityId

      public int getEntityId()
      Specified by:
      getEntityId in interface Entity
    • getFireTicks

      public int getFireTicks()
      Specified by:
      getFireTicks in interface Entity
    • getMaxFireTicks

      public int getMaxFireTicks()
      Specified by:
      getMaxFireTicks in interface Entity
    • setFireTicks

      public void setFireTicks(int ticks)
      Specified by:
      setFireTicks in interface Entity
    • setVisualFire

      public void setVisualFire(boolean fire)
      Specified by:
      setVisualFire in interface Entity
    • isVisualFire

      public boolean isVisualFire()
      Specified by:
      isVisualFire in interface Entity
    • setFreezeTicks

      public void setFreezeTicks(int ticks)
      Specified by:
      setFreezeTicks in interface Entity
    • isFrozen

      public boolean isFrozen()
      Specified by:
      isFrozen in interface Entity
    • isFreezeTickingLocked

      public boolean isFreezeTickingLocked()
      Specified by:
      isFreezeTickingLocked in interface Entity
    • lockFreezeTicks

      public void lockFreezeTicks(boolean locked)
      Specified by:
      lockFreezeTicks in interface Entity
    • getFreezeTicks

      public int getFreezeTicks()
      Specified by:
      getFreezeTicks in interface Entity
    • getMaxFreezeTicks

      public int getMaxFreezeTicks()
      Specified by:
      getMaxFreezeTicks in interface Entity
    • remove

      public void remove()
      Specified by:
      remove in interface Entity
    • isDead

      public boolean isDead()
      Specified by:
      isDead in interface Entity
    • isValid

      public boolean isValid()
      Specified by:
      isValid in interface Entity
    • getServer

      @NotNull public @NotNull ServerMock getServer()
      Specified by:
      getServer in interface CommandSender
      Specified by:
      getServer in interface Entity
    • getPassenger

      @Deprecated public Entity getPassenger()
      Deprecated.
      Specified by:
      getPassenger in interface Entity
    • setPassenger

      @Deprecated public boolean setPassenger(@NotNull @NotNull Entity passenger)
      Deprecated.
      Specified by:
      setPassenger in interface Entity
    • getPassengers

      @NotNull public @NotNull List<Entity> getPassengers()
      Specified by:
      getPassengers in interface Entity
    • getTransitivePassengers

      @NotNull public @NotNull List<Entity> getTransitivePassengers()
      Gets a list of transitive passengers on this vehicle (passengers of passengers).
      Returns:
      An immutable list of passengers.
    • addPassenger

      public boolean addPassenger(@NotNull @NotNull Entity passenger)
      Specified by:
      addPassenger in interface Entity
    • removePassenger

      public boolean removePassenger(@NotNull @NotNull Entity passenger)
      Specified by:
      removePassenger in interface Entity
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Entity
    • hasPassengers

      public boolean hasPassengers()
      Check if the entity has passengers.

      Convenience method for isEmpty().

      Returns:
      true if there is at least one passenger.
    • eject

      public boolean eject()
      Specified by:
      eject in interface Entity
    • getFallDistance

      public float getFallDistance()
      Specified by:
      getFallDistance in interface Entity
    • setFallDistance

      public void setFallDistance(float distance)
      Specified by:
      setFallDistance in interface Entity
    • setLastDamageCause

      public void setLastDamageCause(@Nullable @Nullable EntityDamageEvent event)
      Specified by:
      setLastDamageCause in interface Entity
    • getLastDamageCause

      @Nullable public @Nullable EntityDamageEvent getLastDamageCause()
      Specified by:
      getLastDamageCause in interface Entity
    • getTicksLived

      public int getTicksLived()
      Specified by:
      getTicksLived in interface Entity
    • setTicksLived

      public void setTicksLived(int value)
      Specified by:
      setTicksLived in interface Entity
    • playEffect

      public void playEffect(@NotNull @NotNull EntityEffect type)
      Specified by:
      playEffect in interface Entity
    • getType

      @NotNull public @NotNull EntityType getType()
      Specified by:
      getType in interface Entity
    • getSwimSound

      @NotNull public @NotNull Sound getSwimSound()
      Specified by:
      getSwimSound in interface Entity
    • getSwimSplashSound

      @NotNull public @NotNull Sound getSwimSplashSound()
      Specified by:
      getSwimSplashSound in interface Entity
    • getSwimHighSpeedSplashSound

      @NotNull public @NotNull Sound getSwimHighSpeedSplashSound()
      Specified by:
      getSwimHighSpeedSplashSound in interface Entity
    • isInsideVehicle

      public boolean isInsideVehicle()
      Specified by:
      isInsideVehicle in interface Entity
    • leaveVehicle

      public boolean leaveVehicle()
      Specified by:
      leaveVehicle in interface Entity
    • getVehicle

      @Nullable public @Nullable Entity getVehicle()
      Specified by:
      getVehicle in interface Entity
    • setCustomNameVisible

      public void setCustomNameVisible(boolean flag)
      Specified by:
      setCustomNameVisible in interface Entity
    • isCustomNameVisible

      public boolean isCustomNameVisible()
      Specified by:
      isCustomNameVisible in interface Entity
    • setGlowing

      public void setGlowing(boolean flag)
      Specified by:
      setGlowing in interface Entity
    • isGlowing

      public boolean isGlowing()
      Specified by:
      isGlowing in interface Entity
    • setInvulnerable

      public void setInvulnerable(boolean flag)
      Specified by:
      setInvulnerable in interface Entity
    • isInvulnerable

      public boolean isInvulnerable()
      Specified by:
      isInvulnerable in interface Entity
    • isSilent

      public boolean isSilent()
      Specified by:
      isSilent in interface Entity
    • setSilent

      public void setSilent(boolean silent)
      Specified by:
      setSilent in interface Entity
    • hasGravity

      public boolean hasGravity()
      Specified by:
      hasGravity in interface Entity
    • setGravity

      public void setGravity(boolean gravity)
      Specified by:
      setGravity in interface Entity
    • getPortalCooldown

      public int getPortalCooldown()
      Specified by:
      getPortalCooldown in interface Entity
    • setPortalCooldown

      public void setPortalCooldown(int cooldown)
      Specified by:
      setPortalCooldown in interface Entity
    • getScoreboardTags

      @NotNull public @NotNull Set<String> getScoreboardTags()
      Specified by:
      getScoreboardTags in interface Entity
    • addScoreboardTag

      public boolean addScoreboardTag(@NotNull @NotNull String tag)
      Specified by:
      addScoreboardTag in interface Entity
    • removeScoreboardTag

      public boolean removeScoreboardTag(@NotNull @NotNull String tag)
      Specified by:
      removeScoreboardTag in interface Entity
    • getPistonMoveReaction

      @NotNull public @NotNull PistonMoveReaction getPistonMoveReaction()
      Specified by:
      getPistonMoveReaction in interface Entity
    • setRotation

      public void setRotation(float yaw, float pitch)
      Specified by:
      setRotation in interface Entity
    • getBoundingBox

      @NotNull public @NotNull BoundingBox getBoundingBox()
      Specified by:
      getBoundingBox in interface Entity
    • isPersistent

      public boolean isPersistent()
      Specified by:
      isPersistent in interface Entity
    • setPersistent

      public void setPersistent(boolean persistent)
      Specified by:
      setPersistent in interface Entity
    • getFacing

      @NotNull public @NotNull BlockFace getFacing()
      Specified by:
      getFacing in interface Entity
    • getPose

      @NotNull public @NotNull Pose getPose()
      Specified by:
      getPose in interface Entity
    • isInWater

      public boolean isInWater()
      Specified by:
      isInWater in interface Entity
    • getSpawnCategory

      @NotNull public @NotNull SpawnCategory getSpawnCategory()
      Specified by:
      getSpawnCategory in interface Entity
    • spigot

      public @NotNull Entity.Spigot spigot()
      Specified by:
      spigot in interface CommandSender
      Specified by:
      spigot in interface Entity
    • name

      @NotNull public @NotNull net.kyori.adventure.text.Component name()
      Specified by:
      name in interface CommandSender
    • teamDisplayName

      @NotNull public @NotNull net.kyori.adventure.text.Component teamDisplayName()
      Specified by:
      teamDisplayName in interface Entity
    • asHoverEvent

      @NotNull public @NotNull net.kyori.adventure.text.event.HoverEvent<net.kyori.adventure.text.event.HoverEvent.ShowEntity> asHoverEvent()
      Specified by:
      asHoverEvent in interface net.kyori.adventure.text.event.HoverEventSource<net.kyori.adventure.text.event.HoverEvent.ShowEntity>
    • getOrigin

      @Nullable public @Nullable Location getOrigin()
      Specified by:
      getOrigin in interface Entity
    • fromMobSpawner

      public boolean fromMobSpawner()
      Specified by:
      fromMobSpawner in interface Entity
    • getChunk

      @NotNull public @NotNull Chunk getChunk()
      Specified by:
      getChunk in interface Entity
    • getEntitySpawnReason

      public @NotNull CreatureSpawnEvent.SpawnReason getEntitySpawnReason()
      Specified by:
      getEntitySpawnReason in interface Entity
    • isUnderWater

      public boolean isUnderWater()
      Specified by:
      isUnderWater in interface Entity
    • isInRain

      public boolean isInRain()
      Specified by:
      isInRain in interface Entity
    • isInBubbleColumn

      public boolean isInBubbleColumn()
      Specified by:
      isInBubbleColumn in interface Entity
    • isInWaterOrRain

      public boolean isInWaterOrRain()
      Specified by:
      isInWaterOrRain in interface Entity
    • isInWaterOrBubbleColumn

      public boolean isInWaterOrBubbleColumn()
      Specified by:
      isInWaterOrBubbleColumn in interface Entity
    • isInWaterOrRainOrBubbleColumn

      public boolean isInWaterOrRainOrBubbleColumn()
      Specified by:
      isInWaterOrRainOrBubbleColumn in interface Entity
    • isInLava

      public boolean isInLava()
      Specified by:
      isInLava in interface Entity
    • isTicking

      public boolean isTicking()
      Specified by:
      isTicking in interface Entity
    • spawnAt

      public boolean spawnAt(@NotNull @NotNull Location location)
      Specified by:
      spawnAt in interface Entity
    • spawnAt

      public boolean spawnAt(@NotNull @NotNull Location location, @NotNull CreatureSpawnEvent.SpawnReason reason)
      Specified by:
      spawnAt in interface Entity
    • isInPowderedSnow

      public boolean isInPowderedSnow()
      Specified by:
      isInPowderedSnow in interface Entity
    • collidesAt

      public boolean collidesAt(@NotNull @NotNull Location location)
      Specified by:
      collidesAt in interface Entity
    • wouldCollideUsing

      public boolean wouldCollideUsing(@NotNull @NotNull BoundingBox boundingBox)
      Specified by:
      wouldCollideUsing in interface Entity
    • getScheduler

      @NotNull public @NotNull EntityScheduler getScheduler()
      Specified by:
      getScheduler in interface Entity
    • isSneaking

      public boolean isSneaking()
      Specified by:
      isSneaking in interface Entity
    • setSneaking

      public void setSneaking(boolean sneak)
      Specified by:
      setSneaking in interface Entity
    • setVisibleByDefault

      public void setVisibleByDefault(boolean visible)
      Specified by:
      setVisibleByDefault in interface Entity
    • isVisibleByDefault

      public boolean isVisibleByDefault()
      Specified by:
      isVisibleByDefault in interface Entity