Package be.seeseemelk.mockbukkit.entity
Class EntityMock
java.lang.Object
org.bukkit.command.CommandSender.Spigot
org.bukkit.entity.Entity.Spigot
be.seeseemelk.mockbukkit.entity.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
Mock implementation of an
Entity
.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.bukkit.entity.Entity
Entity.Spigot
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
EntityMock
(@NotNull ServerMock server, @NotNull UUID uuid) Constructs a new EntityMock on the providedServerMock
with a specifiedUUID
. -
Method Summary
Modifier and TypeMethodDescription@NotNull PermissionAttachment
addAttachment
(@NotNull Plugin plugin) addAttachment
(@NotNull Plugin plugin, int ticks) @NotNull PermissionAttachment
addAttachment
(@NotNull Plugin plugin, @NotNull String name, boolean value) addAttachment
(@NotNull Plugin plugin, @NotNull String name, boolean value, int ticks) boolean
addPassenger
(@NotNull Entity passenger) boolean
addScoreboardTag
(@NotNull String tag) @NotNull net.kyori.adventure.text.event.HoverEvent<net.kyori.adventure.text.event.HoverEvent.ShowEntity>
void
assertLocation
(@NotNull Location expectedLocation, double maximumDistance) Assert that the actual location of the player is within a certain distance to a given location.void
Assert that the player hasn't teleported.void
assertTeleported
(@NotNull Location expectedLocation, double maximumDistance) Assert that the player teleported to a certain location within a certain distance to a given location.void
Clears the teleported flag.boolean
collidesAt
(@NotNull Location location) @Nullable net.kyori.adventure.text.Component
void
customName
(@Nullable net.kyori.adventure.text.Component customName) boolean
eject()
final boolean
boolean
@NotNull BoundingBox
@NotNull Chunk
getChunk()
@NotNull Set<PermissionAttachmentInfo>
int
@NotNull CreatureSpawnEvent.SpawnReason
protected EntityState
Get the current state of this entity@NotNull BlockFace
float
int
int
double
@Nullable EntityDamageEvent
@NotNull Location
getLocation
(@Nullable Location loc) int
int
@NotNull List<MetadataValue>
getMetadata
(@NotNull String metadataKey) @NotNull String
getName()
getNearbyEntities
(double x, double y, double z) @Nullable Location
Deprecated.@NotNull PersistentDataContainer
@NotNull PistonMoveReaction
int
@NotNull Pose
getPose()
@NotNull EntityScheduler
@NotNull String
Gets the scoreboard entry for this entity.@NotNull ServerMock
@NotNull SpawnCategory
protected EntitySubType
Get the current subtype of the entity@NotNull Sound
@NotNull Sound
@NotNull Sound
Get the cause of the last teleport.int
Gets a list of transitive passengers on this vehicle (passengers of passengers).@NotNull EntityType
getType()
@NotNull UUID
@Nullable Entity
@NotNull Vector
double
getWidth()
@NotNull WorldMock
getWorld()
boolean
final int
hashCode()
boolean
hasMetadata
(@NotNull String metadataKey) boolean
Check if the entity has passengers.boolean
hasPermission
(@NotNull String name) boolean
hasPermission
(@NotNull Permission perm) boolean
Checks if the player has been teleported since the last assert orclearTeleported()
.boolean
boolean
isDead()
boolean
isEmpty()
boolean
boolean
isFrozen()
boolean
boolean
boolean
isInLava()
boolean
boolean
isInRain()
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
isOp()
boolean
isPermissionSet
(@NotNull String name) boolean
isPermissionSet
(@NotNull Permission perm) boolean
boolean
isSilent()
boolean
boolean
boolean
boolean
isValid()
boolean
boolean
boolean
void
lockFreezeTicks
(boolean locked) @NotNull net.kyori.adventure.text.Component
name()
@Nullable net.kyori.adventure.text.Component
Returns the next message that was sent to the target.void
playEffect
(@NotNull EntityEffect type) void
void
remove()
void
removeAttachment
(@NotNull PermissionAttachment attachment) void
removeMetadata
(@NotNull String metadataKey, @NotNull Plugin owningPlugin) boolean
removePassenger
(@NotNull Entity passenger) boolean
removeScoreboardTag
(@NotNull String tag) void
sendMessage
(@NotNull String message) void
sendMessage
(@NotNull net.kyori.adventure.identity.Identity source, @NotNull net.kyori.adventure.text.Component message, @NotNull net.kyori.adventure.audience.MessageType type) void
sendMessage
(@Nullable UUID sender, @NotNull String message) void
sendMessage
(String... messages) void
sendMessage
(UUID sender, String @NotNull ... messages) void
setCustomName
(@Nullable String name) void
setCustomNameVisible
(boolean flag) void
setFallDistance
(float distance) void
setFireTicks
(int ticks) void
setFreezeTicks
(int ticks) void
setGlowing
(boolean flag) void
setGravity
(boolean gravity) void
setInvulnerable
(boolean flag) void
setLastDamageCause
(@Nullable EntityDamageEvent event) void
setLocation
(@NotNull Location location) Sets the location of the entity.void
setMetadata
(@NotNull String metadataKey, @NotNull MetadataValue newMetadataValue) void
Sets the name of this entity.void
setOp
(boolean isOperator) boolean
setPassenger
(@NotNull Entity passenger) Deprecated.void
setPersistent
(boolean persistent) void
setPortalCooldown
(int cooldown) void
setRotation
(float yaw, float pitch) void
setSilent
(boolean silent) void
setSneaking
(boolean sneak) void
setTicksLived
(int value) void
setVelocity
(@NotNull Vector velocity) void
setVisibleByDefault
(boolean visible) void
setVisualFire
(boolean fire) boolean
boolean
spawnAt
(@NotNull Location location, @NotNull CreatureSpawnEvent.SpawnReason reason) @NotNull Entity.Spigot
spigot()
@NotNull net.kyori.adventure.text.Component
boolean
boolean
teleport
(@NotNull Entity destination, @NotNull PlayerTeleportEvent.TeleportCause cause) boolean
boolean
teleport
(@NotNull Location location, @NotNull PlayerTeleportEvent.TeleportCause cause) boolean
teleport
(@NotNull Location location, @NotNull PlayerTeleportEvent.TeleportCause cause, TeleportFlag @NotNull ... flags) protected void
teleportWithoutEvent
(@NotNull Location location, @NotNull PlayerTeleportEvent.TeleportCause cause) Handles teleporting an entity without firing an event.boolean
wouldCollideUsing
(@NotNull BoundingBox boundingBox) Methods inherited from class org.bukkit.command.CommandSender.Spigot
sendMessage, sendMessage, sendMessage, sendMessage
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.kyori.adventure.audience.Audience
clearTitle, deleteMessage, deleteMessage, filterAudience, forEachAudience, hideBossBar, openBook, openBook, playSound, playSound, playSound, resetTitle, sendActionBar, sendActionBar, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeader, sendPlayerListHeaderAndFooter, sendPlayerListHeaderAndFooter, sendTitlePart, showBossBar, showTitle, stopSound, stopSound
Methods inherited from interface org.bukkit.command.CommandSender
sendMessage, sendMessage, sendPlainMessage, sendRichMessage
Methods inherited from interface org.bukkit.entity.Entity
asHoverEvent, teleport, teleportAsync, teleportAsync
Methods inherited from interface be.seeseemelk.mockbukkit.command.MessageTarget
assertNoMoreSaid, assertSaid, assertSaid, nextMessage
Methods inherited from interface org.bukkit.permissions.Permissible
permissionValue, permissionValue
Methods inherited from interface net.kyori.adventure.pointer.Pointered
get, getOrDefault, getOrDefaultFrom, pointers
-
Field Details
-
server
-
-
Constructor Details
-
EntityMock
Constructs a new EntityMock on the providedServerMock
with a specifiedUUID
.- Parameters:
server
- The server to create the entity on.uuid
- The UUID of the entity.
-
-
Method Details
-
hashCode
public final int hashCode() -
equals
-
assertLocation
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
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 orclearTeleported()
.- Returns:
true
if the player has been teleported,false
if he hasn't been teleported.
-
clearTeleported
public void clearTeleported()Clears the teleported flag. -
getTeleportCause
Get the cause of the last teleport.- Returns:
- The cause of the last teleport.
-
getUniqueId
- Specified by:
getUniqueId
in interfaceEntity
-
getLocation
- Specified by:
getLocation
in interfaceEntity
-
getTrackedPlayers
- Specified by:
getTrackedPlayers
in interfaceEntity
-
getLocation
- Specified by:
getLocation
in interfaceEntity
-
setLocation
Sets the location of the entity. Note that this will not fire a teleport event.- Parameters:
location
- The new location of the entity.
-
getWorld
-
setMetadata
public void setMetadata(@NotNull @NotNull String metadataKey, @NotNull @NotNull MetadataValue newMetadataValue) - Specified by:
setMetadata
in interfaceMetadatable
-
getMetadata
- Specified by:
getMetadata
in interfaceMetadatable
-
hasMetadata
- Specified by:
hasMetadata
in interfaceMetadatable
-
removeMetadata
public void removeMetadata(@NotNull @NotNull String metadataKey, @NotNull @NotNull Plugin owningPlugin) - Specified by:
removeMetadata
in interfaceMetadatable
-
getPersistentDataContainer
- Specified by:
getPersistentDataContainer
in interfacePersistentDataHolder
-
teleport
-
teleport
public boolean teleport(@NotNull @NotNull Location location, @NotNull @NotNull PlayerTeleportEvent.TeleportCause cause) -
teleport
public boolean teleport(@NotNull @NotNull Location location, @NotNull @NotNull PlayerTeleportEvent.TeleportCause cause, TeleportFlag @NotNull ... flags) -
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
-
teleport
public boolean teleport(@NotNull @NotNull Entity destination, @NotNull @NotNull PlayerTeleportEvent.TeleportCause cause) -
isOp
public boolean isOp()- Specified by:
isOp
in interfaceServerOperator
-
setOp
public void setOp(boolean isOperator) - Specified by:
setOp
in interfaceServerOperator
-
getName
- Specified by:
getName
in interfaceCommandSender
-
getScoreboardEntry
Gets the scoreboard entry for this entity.- Returns:
- The scoreboard entry.
-
setName
Sets the name of this entity.- Parameters:
name
- The new name of the entity.
-
sendMessage
- Specified by:
sendMessage
in interfaceCommandSender
-
sendMessage
- Specified by:
sendMessage
in interfaceCommandSender
-
sendMessage
- Specified by:
sendMessage
in interfaceCommandSender
-
sendMessage
- Specified by:
sendMessage
in interfaceCommandSender
-
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 interfacenet.kyori.adventure.audience.Audience
- Specified by:
sendMessage
in interfaceCommandSender
-
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 interfaceMessageTarget
- Returns:
- The next message sent to the target.
-
isPermissionSet
- Specified by:
isPermissionSet
in interfacePermissible
-
isPermissionSet
- Specified by:
isPermissionSet
in interfacePermissible
-
hasPermission
- Specified by:
hasPermission
in interfacePermissible
-
hasPermission
- Specified by:
hasPermission
in interfacePermissible
-
addAttachment
@NotNull public @NotNull PermissionAttachment addAttachment(@NotNull @NotNull Plugin plugin, @NotNull @NotNull String name, boolean value) - Specified by:
addAttachment
in interfacePermissible
-
addAttachment
- Specified by:
addAttachment
in interfacePermissible
-
addAttachment
public PermissionAttachment addAttachment(@NotNull @NotNull Plugin plugin, @NotNull @NotNull String name, boolean value, int ticks) - Specified by:
addAttachment
in interfacePermissible
-
addAttachment
- Specified by:
addAttachment
in interfacePermissible
-
removeAttachment
- Specified by:
removeAttachment
in interfacePermissible
-
recalculatePermissions
public void recalculatePermissions()- Specified by:
recalculatePermissions
in interfacePermissible
-
getEffectivePermissions
- Specified by:
getEffectivePermissions
in interfacePermissible
-
customName
@Nullable public @Nullable net.kyori.adventure.text.Component customName()- Specified by:
customName
in interfaceNameable
-
customName
public void customName(@Nullable @Nullable net.kyori.adventure.text.Component customName) - Specified by:
customName
in interfaceNameable
-
getCustomName
- Specified by:
getCustomName
in interfaceNameable
-
setCustomName
- Specified by:
setCustomName
in interfaceNameable
-
setVelocity
- Specified by:
setVelocity
in interfaceEntity
-
getVelocity
- Specified by:
getVelocity
in interfaceEntity
-
getHeight
public double getHeight() -
getWidth
public double getWidth() -
getEntityState
Get the current state of this entity- Returns:
- The current state of this entity
-
getSubType
Get the current subtype of the entity- Returns:
- The current subtype of the entity
-
isOnGround
public boolean isOnGround()- Specified by:
isOnGround
in interfaceEntity
-
getNearbyEntities
- Specified by:
getNearbyEntities
in interfaceEntity
-
getEntityId
public int getEntityId()- Specified by:
getEntityId
in interfaceEntity
-
getFireTicks
public int getFireTicks()- Specified by:
getFireTicks
in interfaceEntity
-
getMaxFireTicks
public int getMaxFireTicks()- Specified by:
getMaxFireTicks
in interfaceEntity
-
setFireTicks
public void setFireTicks(int ticks) - Specified by:
setFireTicks
in interfaceEntity
-
setVisualFire
public void setVisualFire(boolean fire) - Specified by:
setVisualFire
in interfaceEntity
-
isVisualFire
public boolean isVisualFire()- Specified by:
isVisualFire
in interfaceEntity
-
setFreezeTicks
public void setFreezeTicks(int ticks) - Specified by:
setFreezeTicks
in interfaceEntity
-
isFrozen
public boolean isFrozen() -
isFreezeTickingLocked
public boolean isFreezeTickingLocked()- Specified by:
isFreezeTickingLocked
in interfaceEntity
-
lockFreezeTicks
public void lockFreezeTicks(boolean locked) - Specified by:
lockFreezeTicks
in interfaceEntity
-
getFreezeTicks
public int getFreezeTicks()- Specified by:
getFreezeTicks
in interfaceEntity
-
getMaxFreezeTicks
public int getMaxFreezeTicks()- Specified by:
getMaxFreezeTicks
in interfaceEntity
-
remove
public void remove() -
isDead
public boolean isDead() -
isValid
public boolean isValid() -
getServer
- Specified by:
getServer
in interfaceCommandSender
- Specified by:
getServer
in interfaceEntity
-
getPassenger
Deprecated.- Specified by:
getPassenger
in interfaceEntity
-
setPassenger
Deprecated.- Specified by:
setPassenger
in interfaceEntity
-
getPassengers
- Specified by:
getPassengers
in interfaceEntity
-
getTransitivePassengers
Gets a list of transitive passengers on this vehicle (passengers of passengers).- Returns:
- An immutable list of passengers.
-
addPassenger
- Specified by:
addPassenger
in interfaceEntity
-
removePassenger
- Specified by:
removePassenger
in interfaceEntity
-
isEmpty
public boolean isEmpty() -
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() -
getFallDistance
public float getFallDistance()- Specified by:
getFallDistance
in interfaceEntity
-
setFallDistance
public void setFallDistance(float distance) - Specified by:
setFallDistance
in interfaceEntity
-
setLastDamageCause
- Specified by:
setLastDamageCause
in interfaceEntity
-
getLastDamageCause
- Specified by:
getLastDamageCause
in interfaceEntity
-
getTicksLived
public int getTicksLived()- Specified by:
getTicksLived
in interfaceEntity
-
setTicksLived
public void setTicksLived(int value) - Specified by:
setTicksLived
in interfaceEntity
-
playEffect
- Specified by:
playEffect
in interfaceEntity
-
getType
-
getSwimSound
- Specified by:
getSwimSound
in interfaceEntity
-
getSwimSplashSound
- Specified by:
getSwimSplashSound
in interfaceEntity
-
getSwimHighSpeedSplashSound
- Specified by:
getSwimHighSpeedSplashSound
in interfaceEntity
-
isInsideVehicle
public boolean isInsideVehicle()- Specified by:
isInsideVehicle
in interfaceEntity
-
leaveVehicle
public boolean leaveVehicle()- Specified by:
leaveVehicle
in interfaceEntity
-
getVehicle
- Specified by:
getVehicle
in interfaceEntity
-
setCustomNameVisible
public void setCustomNameVisible(boolean flag) - Specified by:
setCustomNameVisible
in interfaceEntity
-
isCustomNameVisible
public boolean isCustomNameVisible()- Specified by:
isCustomNameVisible
in interfaceEntity
-
setGlowing
public void setGlowing(boolean flag) - Specified by:
setGlowing
in interfaceEntity
-
isGlowing
public boolean isGlowing() -
setInvulnerable
public void setInvulnerable(boolean flag) - Specified by:
setInvulnerable
in interfaceEntity
-
isInvulnerable
public boolean isInvulnerable()- Specified by:
isInvulnerable
in interfaceEntity
-
isSilent
public boolean isSilent() -
setSilent
public void setSilent(boolean silent) -
hasGravity
public boolean hasGravity()- Specified by:
hasGravity
in interfaceEntity
-
setGravity
public void setGravity(boolean gravity) - Specified by:
setGravity
in interfaceEntity
-
getPortalCooldown
public int getPortalCooldown()- Specified by:
getPortalCooldown
in interfaceEntity
-
setPortalCooldown
public void setPortalCooldown(int cooldown) - Specified by:
setPortalCooldown
in interfaceEntity
-
getScoreboardTags
- Specified by:
getScoreboardTags
in interfaceEntity
-
addScoreboardTag
- Specified by:
addScoreboardTag
in interfaceEntity
-
removeScoreboardTag
- Specified by:
removeScoreboardTag
in interfaceEntity
-
getPistonMoveReaction
- Specified by:
getPistonMoveReaction
in interfaceEntity
-
setRotation
public void setRotation(float yaw, float pitch) - Specified by:
setRotation
in interfaceEntity
-
getBoundingBox
- Specified by:
getBoundingBox
in interfaceEntity
-
isPersistent
public boolean isPersistent()- Specified by:
isPersistent
in interfaceEntity
-
setPersistent
public void setPersistent(boolean persistent) - Specified by:
setPersistent
in interfaceEntity
-
getFacing
-
getPose
-
isInWater
public boolean isInWater() -
getSpawnCategory
- Specified by:
getSpawnCategory
in interfaceEntity
-
spigot
- Specified by:
spigot
in interfaceCommandSender
- Specified by:
spigot
in interfaceEntity
-
name
@NotNull public @NotNull net.kyori.adventure.text.Component name()- Specified by:
name
in interfaceCommandSender
-
teamDisplayName
@NotNull public @NotNull net.kyori.adventure.text.Component teamDisplayName()- Specified by:
teamDisplayName
in interfaceEntity
-
asHoverEvent
@NotNull public @NotNull net.kyori.adventure.text.event.HoverEvent<net.kyori.adventure.text.event.HoverEvent.ShowEntity> asHoverEvent()- Specified by:
asHoverEvent
in interfacenet.kyori.adventure.text.event.HoverEventSource<net.kyori.adventure.text.event.HoverEvent.ShowEntity>
-
getOrigin
-
fromMobSpawner
public boolean fromMobSpawner()- Specified by:
fromMobSpawner
in interfaceEntity
-
getChunk
-
getEntitySpawnReason
- Specified by:
getEntitySpawnReason
in interfaceEntity
-
isUnderWater
public boolean isUnderWater()- Specified by:
isUnderWater
in interfaceEntity
-
isInRain
public boolean isInRain() -
isInBubbleColumn
public boolean isInBubbleColumn()- Specified by:
isInBubbleColumn
in interfaceEntity
-
isInWaterOrRain
public boolean isInWaterOrRain()- Specified by:
isInWaterOrRain
in interfaceEntity
-
isInWaterOrBubbleColumn
public boolean isInWaterOrBubbleColumn()- Specified by:
isInWaterOrBubbleColumn
in interfaceEntity
-
isInWaterOrRainOrBubbleColumn
public boolean isInWaterOrRainOrBubbleColumn()- Specified by:
isInWaterOrRainOrBubbleColumn
in interfaceEntity
-
isInLava
public boolean isInLava() -
isTicking
public boolean isTicking() -
spawnAt
-
spawnAt
public boolean spawnAt(@NotNull @NotNull Location location, @NotNull CreatureSpawnEvent.SpawnReason reason) -
isInPowderedSnow
public boolean isInPowderedSnow()- Specified by:
isInPowderedSnow
in interfaceEntity
-
collidesAt
- Specified by:
collidesAt
in interfaceEntity
-
wouldCollideUsing
- Specified by:
wouldCollideUsing
in interfaceEntity
-
getScheduler
- Specified by:
getScheduler
in interfaceEntity
-
isSneaking
public boolean isSneaking()- Specified by:
isSneaking
in interfaceEntity
-
setSneaking
public void setSneaking(boolean sneak) - Specified by:
setSneaking
in interfaceEntity
-
setVisibleByDefault
public void setVisibleByDefault(boolean visible) - Specified by:
setVisibleByDefault
in interfaceEntity
-
isVisibleByDefault
public boolean isVisibleByDefault()- Specified by:
isVisibleByDefault
in interfaceEntity
-