Class Player

All Implemented Interfaces:
Audience, Identified, Pointered, Sound.Emitter, HoverEventSource<HoverEvent.ShowEntity>, Localizable, Shape, CommandSender, EventHandler<EntityEvent>, EquipmentHandler, PermissionHandler, Snapshotable, Taggable, TagReadable, TagWritable, Tickable, Schedulable, NamedAndIdentified, Viewable

Those are the major actors of the server

You can easily create your own implementation of this and use it with ConnectionManager.setPlayerProvider(PlayerProvider).

  • Field Details

  • Constructor Details

    • Player

      public Player(@NotNull @NotNull UUID uuid, @NotNull @NotNull String username, @NotNull @NotNull PlayerConnection playerConnection)
  • Method Details

    • setPendingOptions

      @Internal public void setPendingOptions(@NotNull @NotNull Instance pendingInstance, boolean hardcore)
    • UNSAFE_init

      @Internal public CompletableFuture<Void> UNSAFE_init()
      Used when the player is created. Init the player and spawn him.

      WARNING: executed in the main update thread UNSAFE: Only meant to be used when a socket player connects through the server.

    • startConfigurationPhase

      public void startConfigurationPhase()
      Moves the player immediately to the configuration state. The player is automatically moved to configuration upon finishing login, this method can be used to move them back to configuration after entering the play state.

      This will result in them being removed from the current instance, player list, etc.

    • playerConnectionInit

      protected void playerConnectionInit()
      Used to initialize the player connection
    • update

      public void update(long time)
      Description copied from class: Entity
      Called each tick.
      update in class LivingEntity
      time - time of the update in milliseconds
    • kill

      public void kill()
      Description copied from class: LivingEntity
      Kills the entity, trigger the EntityDeathEvent event.
      kill in class LivingEntity
    • respawn

      public void respawn()
      Respawns the player by sending a RespawnPacket to the player and teleporting him to getRespawnPoint(). It also resets fire and health.
    • refreshCommands

      public void refreshCommands()
      Refreshes the command list for this player. This checks the CommandConditions again, and any changes will be visible to the player.
    • isOnGround

      public boolean isOnGround()
      isOnGround in class Entity
    • remove

      public void remove(boolean permanent)
      remove in class Entity
    • updateOldViewer

      public void updateOldViewer(@NotNull @NotNull Player player)
      Description copied from class: Entity
      Called when a viewer must be destroyed. Method can be subject to deadlocking if the target's viewers are also accessed.
      updateOldViewer in class Entity
      player - the player to send the packets to
    • sendPacketToViewersAndSelf

      public void sendPacketToViewersAndSelf(@NotNull @NotNull SendablePacket packet)
      Description copied from interface: Viewable
      Sends a packet to all viewers and the viewable element if it is a player.

      If 'this' isn't a player, then only Viewable.sendPacketToViewers(SendablePacket) is called.

      Specified by:
      sendPacketToViewersAndSelf in interface Viewable
      packet - the packet to send
    • setInstance

      public CompletableFuture<Void> setInstance(@NotNull @NotNull Instance instance, @NotNull @NotNull Pos spawnPosition)
      Changes the player instance and load surrounding chunks if needed.

      Be aware that because chunk operations are expensive, it is possible for this method to be non-blocking when retrieving chunks is required.

      setInstance in class Entity
      instance - the new player instance
      spawnPosition - the new position of the player
      a future called once the player instance changed
    • setInstance

      public CompletableFuture<Void> setInstance(@NotNull @NotNull Instance instance)
      Changes the player instance without changing its position (defaulted to getRespawnPoint() if the player is not in any instance).
      setInstance in class Entity
      instance - the new player instance
      a CompletableFuture called once the entity's instance has been set, this is due to chunks needing to load for players
      See Also:
    • onChunkBatchReceived

      @Internal public void onChunkBatchReceived(float newTargetChunksPerTick)
    • sendChunk

      public void sendChunk(@NotNull @NotNull Chunk chunk)
      Queues the given chunk to be sent to the player.
      chunk - The chunk to send
    • updatePose

      protected void updatePose()
      updatePose in class Entity
    • sendMessage

      public void sendMessage(@NotNull @NotNull Identity source, @NotNull @NotNull Component message, @NotNull @NotNull MessageType type)
      Specified by:
      sendMessage in interface Audience
    • sendPluginMessage

      public void sendPluginMessage(@NotNull @NotNull String channel, byte @NotNull [] data)
      Sends a plugin message to the player.
      channel - the message channel
      data - the message data
    • sendPluginMessage

      public void sendPluginMessage(@NotNull @NotNull String channel, @NotNull @NotNull String message)
      Sends a plugin message to the player.

      Message encoded to UTF-8.

      channel - the message channel
      message - the message
    • playSound

      public void playSound(@NotNull @NotNull Sound sound)
      Specified by:
      playSound in interface Audience
    • playSound

      public void playSound(@NotNull @NotNull Sound sound, @NotNull @NotNull Point point)
    • playSound

      public void playSound(@NotNull @NotNull Sound sound, double x, double y, double z)
      Specified by:
      playSound in interface Audience
    • playSound

      public void playSound(@NotNull @NotNull Sound sound, @NotNull Sound.Emitter emitter)
      Specified by:
      playSound in interface Audience
    • stopSound

      public void stopSound(@NotNull @NotNull SoundStop stop)
      Specified by:
      stopSound in interface Audience
    • playEffect

      public void playEffect(@NotNull @NotNull Effects effect, int x, int y, int z, int data, boolean disableRelativeVolume)
      Plays a given effect at the given position for this player.
      effect - the effect to play
      x - x position of the effect
      y - y position of the effect
      z - z position of the effect
      data - data for the effect
      disableRelativeVolume - disable volume scaling based on distance
    • sendPlayerListHeaderAndFooter

      public void sendPlayerListHeaderAndFooter(@NotNull @NotNull Component header, @NotNull @NotNull Component footer)
      Specified by:
      sendPlayerListHeaderAndFooter in interface Audience
    • sendTitlePart

      public <T> void sendTitlePart(@NotNull @NotNull TitlePart<T> part, @NotNull T value)
      Specified by:
      sendTitlePart in interface Audience
    • sendActionBar

      public void sendActionBar(@NotNull @NotNull Component message)
      Specified by:
      sendActionBar in interface Audience
    • resetTitle

      public void resetTitle()
      Specified by:
      resetTitle in interface Audience
    • clearTitle

      public void clearTitle()
      Specified by:
      clearTitle in interface Audience
    • showBossBar

      public void showBossBar(@NotNull @NotNull BossBar bar)
      Specified by:
      showBossBar in interface Audience
    • hideBossBar

      public void hideBossBar(@NotNull @NotNull BossBar bar)
      Specified by:
      hideBossBar in interface Audience
    • openBook

      public void openBook(@NotNull @NotNull Book book)
      Specified by:
      openBook in interface Audience
    • isImmune

      public boolean isImmune(@NotNull DynamicRegistry.Key<DamageType> type)
      Description copied from class: LivingEntity
      Is this entity immune to the given type of damage?
      isImmune in class LivingEntity
      type - the type of damage
      true if this entity is immune to the given type of damage
    • setHealth

      public void setHealth(float health)
      Description copied from class: LivingEntity
      Changes the entity health, kill it if health is <= 0 and is not dead yet.
      setHealth in class LivingEntity
      health - the new entity health
    • getPlayerMeta

      @NotNull public @NotNull PlayerMeta getPlayerMeta()
      Gets the entity meta for the player.

      Note that this method will throw an exception if the player's entity type has been changed with Entity.switchEntityType(EntityType). It is wise to check Entity.getEntityType() first.

    • getAdditionalHearts

      public float getAdditionalHearts()
      Gets the player additional hearts.

      Note that this function is uncallable if the player has their entity type switched with Entity.switchEntityType(EntityType).

      the player additional hearts
    • setAdditionalHearts

      public void setAdditionalHearts(float additionalHearts)
      Changes the amount of additional hearts shown.

      Note that this function is uncallable if the player has their entity type switched with Entity.switchEntityType(EntityType).

      additionalHearts - the count of additional hearts
    • getFood

      public int getFood()
      Gets the player food.
      the player food
    • setFood

      public void setFood(int food)
      Sets and refresh client food bar.
      food - the new food value
      IllegalArgumentException - if food is not between 0 and 20
    • getFoodSaturation

      public float getFoodSaturation()
    • setFoodSaturation

      public void setFoodSaturation(float foodSaturation)
      Sets and refresh client food saturation.
      foodSaturation - the food saturation
      IllegalArgumentException - if foodSaturation is not between 0 and 20
    • isEating

      public boolean isEating()
      Gets if the player is eating.
      true if the player is eating, false otherwise
    • isUsingItem

      public boolean isUsingItem()
      Gets if the player is using an item.
      true if the player is using an item, false otherwise
    • getItemUseHand

      @Nullable public @Nullable Player.Hand getItemUseHand()
      Gets the hand which the player is using an item from.
      the item use hand, null if none
    • getEyeHeight

      public double getEyeHeight()
      Description copied from class: Entity
      Gets the entity eye height.
      getEyeHeight in class Entity
      the entity eye height
    • getDisplayName

      @Nullable public @Nullable Component getDisplayName()
      Gets the player display name in the tab-list.
      the player display name, null means that getUsername() is displayed
    • setDisplayName

      public void setDisplayName(@Nullable @Nullable Component displayName)
      Changes the player display name in the tab-list.

      Sets to null to show the player username.

      displayName - the display name, null to display the username
    • getSkin

      @Nullable public @Nullable PlayerSkin getSkin()
      Gets the player skin.
      the player skin object, null means that the player has his Entity.getUuid() default skin
    • setSkin

      public void setSkin(@Nullable @Nullable PlayerSkin skin)
      Changes the player skin.

      This does remove the player for all viewers to spawn it again with the correct new skin.

      skin - the player skin, null to reset it to his Entity.getUuid() default skin
      See Also:
    • setDeathLocation

      public void setDeathLocation(@NotNull @NotNull Pos position)
    • setDeathLocation

      public void setDeathLocation(@NotNull @NotNull String dimension, @NotNull @NotNull Pos position)
    • getDeathLocation

      @Nullable public @Nullable WorldPos getDeathLocation()
    • isEnableRespawnScreen

      public boolean isEnableRespawnScreen()
      Gets if the player has the respawn screen enabled or disabled.
      true if the player has the respawn screen, false if he didn't
    • setEnableRespawnScreen

      public void setEnableRespawnScreen(boolean enableRespawnScreen)
      Enables or disable the respawn screen.
      enableRespawnScreen - true to enable the respawn screen, false to disable it
    • getName

      @NotNull public @NotNull Component getName()
      Gets the player's name as a component. This will either return the display name (if set) or a component holding the username.
      Specified by:
      getName in interface NamedAndIdentified
      the name
    • getUsername

      @NotNull public @NotNull String getUsername()
      Gets the player's username.
      the player's username
    • setUsernameField

      public void setUsernameField(@NotNull @NotNull String username)
      Changes the internal player name, used for the AsyncPlayerPreLoginEvent mostly unsafe outside of it.
      username - the new player name
    • dropItem

      public boolean dropItem(@NotNull @NotNull ItemStack item)
      Calls an ItemDropEvent with a specified item.

      Returns false if item is air.

      item - the item to drop
      true if player can drop the item (event not cancelled), false otherwise
    • sendResourcePacks

      public void sendResourcePacks(@NotNull @NotNull ResourcePackRequest request)
      Specified by:
      sendResourcePacks in interface Audience
    • removeResourcePacks

      public void removeResourcePacks(@NotNull @NotNull UUID id, @NotNull @NotNull UUID @NotNull ... others)
      Specified by:
      removeResourcePacks in interface Audience
    • clearResourcePacks

      public void clearResourcePacks()
      Specified by:
      clearResourcePacks in interface Audience
    • getResourcePackFuture

      @Internal @Nullable public @Nullable CompletableFuture<Void> getResourcePackFuture()
      If there are resource packs in-flight, a future is returned which will be completed when all resource packs have been responded to by the client. Otherwise null is returned.
    • onResourcePackStatus

      @Internal public void onResourcePackStatus(@NotNull @NotNull UUID id, @NotNull @NotNull ResourcePackStatus status)
    • facePosition

      public void facePosition(@NotNull @NotNull Player.FacePoint facePoint, @NotNull @NotNull Point targetPosition)
      Rotates the player to face targetPosition.
      facePoint - the point from where the player should aim
      targetPosition - the target position to face
    • facePosition

      public void facePosition(@NotNull @NotNull Player.FacePoint facePoint, Entity entity, Player.FacePoint targetPoint)
      Rotates the player to face entity.
      facePoint - the point from where the player should aim
      entity - the entity to face
      targetPoint - the point to aim at entity position
    • spectate

      public void spectate(@NotNull @NotNull Entity entity)
      Sets the camera at entity eyes.
      entity - the entity to spectate
    • stopSpectating

      public void stopSpectating()
      Resets the camera at the player.
    • getRespawnPoint

      @NotNull public @NotNull Pos getRespawnPoint()
      Used to retrieve the default spawn point.

      Can be altered by the PlayerRespawnEvent.setRespawnPosition(Pos).

      a copy of the default respawn point
    • setRespawnPoint

      public void setRespawnPoint(@NotNull @NotNull Pos respawnPoint)
      Changes the default spawn point.
      respawnPoint - the player respawn point
    • refreshAfterTeleport

      protected void refreshAfterTeleport()
      Called after the player teleportation to refresh his position and send data to his new viewers.
    • refreshHealth

      protected void refreshHealth()
      Sets the player food and health values to their maximum.
    • getExp

      public float getExp()
      Gets the percentage displayed in the experience bar.
      the exp percentage 0-1
    • setExp

      public void setExp(float exp)
      Used to change the percentage experience bar. This cannot change the displayed level, see setLevel(int).
      exp - a percentage between 0 and 1
      IllegalArgumentException - if exp is not between 0 and 1
    • getLevel

      public int getLevel()
      Gets the level of the player displayed in the experience bar.
      the player level
    • setLevel

      public void setLevel(int level)
      Used to change the level of the player This cannot change the displayed percentage bar see setExp(float)
      level - the new level of the player
    • getPortalCooldown

      public int getPortalCooldown()
    • setPortalCooldown

      public void setPortalCooldown(int portalCooldown)
    • getPlayerConnection

      @NotNull public @NotNull PlayerConnection getPlayerConnection()
      Gets the player connection.

      Used to send packets and get stuff related to the connection.

      the player connection
    • sendPacket

      public void sendPacket(@NotNull @NotNull SendablePacket packet)
      packet - the packet to send
    • sendPackets

      public void sendPackets(@NotNull @NotNull SendablePacket... packets)
    • sendPackets

      public void sendPackets(@NotNull @NotNull Collection<SendablePacket> packets)
    • isOnline

      public boolean isOnline()
      Gets if the player is online or not.
      true if the player is online, false otherwise
    • getSettings

      @NotNull public @NotNull Player.PlayerSettings getSettings()
      Gets the player settings.
      the player settings
    • getDimensionType

      public DimensionType getDimensionType()
      Gets the player dimension.
      the player current dimension
    • getInventory

      @NotNull public @NotNull PlayerInventory getInventory()
    • getLatency

      public int getLatency()
      Used to get the player latency, computed by seeing how long it takes the client to answer the KeepAlivePacket packet.
      the player latency
    • getGameMode

      public GameMode getGameMode()
      Gets the player GameMode.
      the player current gamemode
    • setGameMode

      public boolean setGameMode(@NotNull @NotNull GameMode gameMode)
      Changes the player GameMode
      gameMode - the new player GameMode
      true if the gamemode was changed successfully, false otherwise (cancelled by event)
    • sendDimension

      protected void sendDimension(@NotNull DynamicRegistry.Key<DimensionType> dimensionType, @NotNull @NotNull String dimensionName)
      Changes the dimension of the player. Mostly unsafe since it requires sending chunks after.
      dimensionType - the new player dimension
    • kick

      public void kick(@NotNull @NotNull Component component)
      Kicks the player with a reason.
      component - the reason
    • kick

      public void kick(@NotNull @NotNull String message)
      Kicks the player with a reason.
      message - the kick reason
    • setHeldItemSlot

      public void setHeldItemSlot(byte slot)
      Changes the current held slot for the player.
      slot - the slot that the player has to held
      IllegalArgumentException - if slot is not between 0 and 8
    • getHeldSlot

      public byte getHeldSlot()
      Gets the player held slot (0-8).
      the current held slot for the player
    • setBelowNameTag

      public void setBelowNameTag(BelowNameTag belowNameTag)
      Changes the tag below the name.
      belowNameTag - The new below name tag
    • getOpenInventory

      @Nullable public @Nullable Inventory getOpenInventory()
      Gets the player open inventory.
      the currently open inventory, null if there is not (player inventory is not detected)
    • openInventory

      public boolean openInventory(@NotNull @NotNull Inventory inventory)
      Opens the specified Inventory, close the previous inventory if existing.
      inventory - the inventory to open
      true if the inventory has been opened/sent to the player, false otherwise (cancelled by event)
    • closeInventory

      public void closeInventory()
      Closes the current inventory if there is any. It closes the player inventory (when opened) if getOpenInventory() returns null.
    • closeInventory

      @Internal public void closeInventory(boolean fromClient)
    • didCloseInventory

      public boolean didCloseInventory()
      Used internally to determine when sending the close inventory packet should be skipped.
    • UNSAFE_changeDidCloseInventory

      @Internal public void UNSAFE_changeDidCloseInventory(boolean didCloseInventory)
      Used internally to reset the skipClosePacket field, which determines when sending the close inventory packet should be skipped.

      Shouldn't be used externally without proper understanding of its consequence.

      didCloseInventory - the new didCloseInventory field
    • getNextTeleportId

      public int getNextTeleportId()
    • getLastSentTeleportId

      public int getLastSentTeleportId()
    • getLastReceivedTeleportId

      public int getLastReceivedTeleportId()
    • refreshReceivedTeleportId

      public void refreshReceivedTeleportId(int receivedTeleportId)
    • setView

      public void setView(float yaw, float pitch)
      Forces the player's client to look towards the target yaw/pitch
      setView in class Entity
      yaw - the new yaw
      pitch - the new pitch
    • lookAt

      public void lookAt(@NotNull @NotNull Point point)
      Forces the player's client to look towards the specified point

      Note: the player's position is not updated on the server until the client receives this packet

      lookAt in class Entity
      point - the point to look at
    • lookAt

      public void lookAt(@NotNull @NotNull Entity entity)
      Forces the player's client to look towards the specified entity

      Note: the player's position is not updated on the server until the client receives this packet

      lookAt in class Entity
      entity - the entity to look at
    • getPermissionLevel

      public int getPermissionLevel()
      Gets the player permission level.
      the player permission level
    • setPermissionLevel

      public void setPermissionLevel(int permissionLevel)
      Changes the player permission level.
      permissionLevel - the new player permission level
      IllegalArgumentException - if permissionLevel is not between 0 and 4
    • setReducedDebugScreenInformation

      public void setReducedDebugScreenInformation(boolean reduced)
      Sets or remove the reduced debug screen.
      reduced - should the player has the reduced debug screen
    • hasReducedDebugScreenInformation

      public boolean hasReducedDebugScreenInformation()
      Gets if the player has the reduced debug screen.
      true if the player has the reduced debug screen, false otherwise
    • isInvulnerable

      public boolean isInvulnerable()
      The invulnerable field appear in the PlayerAbilitiesPacket packet.
      isInvulnerable in class LivingEntity
      true if the player is invulnerable, false otherwise
    • setInvulnerable

      public void setInvulnerable(boolean invulnerable)
      This do update the invulnerable field in the packet PlayerAbilitiesPacket and prevent the player from receiving damage.
      setInvulnerable in class LivingEntity
      invulnerable - should the player be invulnerable
    • setSneaking

      public void setSneaking(boolean sneaking)
      Description copied from class: Entity
      Makes the entity sneak.

      WARNING: this will not work for the client itself.

      setSneaking in class Entity
      sneaking - true to make the entity sneak
    • isFlying

      public boolean isFlying()
      Gets if the player is currently flying.
      true if the player if flying, false otherwise
    • setFlying

      public void setFlying(boolean flying)
      Sets the player flying.
      flying - should the player fly
    • refreshFlying

      public void refreshFlying(boolean flying)
      Updates the internal flying field.

      Mostly unsafe since there is nothing to backup the value, used internally for creative players.

      flying - the new flying field
      See Also:
    • isAllowFlying

      public boolean isAllowFlying()
      Gets if the player is allowed to fly.
      true if the player if allowed to fly, false otherwise
    • setAllowFlying

      public void setAllowFlying(boolean allowFlying)
      Allows or forbid the player to fly.
      allowFlying - should the player be allowed to fly
    • isInstantBreak

      public boolean isInstantBreak()
    • setInstantBreak

      public void setInstantBreak(boolean instantBreak)
      Changes the player ability "Creative Mode".
      instantBreak - true to allow instant break
      See Also:
    • getFlyingSpeed

      public float getFlyingSpeed()
      Gets the player flying speed.
      the flying speed of the player
    • setFlyingSpeed

      public void setFlyingSpeed(float flyingSpeed)
      Updates the internal field and send a PlayerAbilitiesPacket with the new flying speed.
      flyingSpeed - the new flying speed of the player
    • getFieldViewModifier

      public float getFieldViewModifier()
    • setFieldViewModifier

      public void setFieldViewModifier(float fieldViewModifier)
    • getStatisticValueMap

      @NotNull public @NotNull Map<PlayerStatistic,Integer> getStatisticValueMap()
      This is the map used to send the statistic packet. It is possible to add/remove/change statistic value directly into it.
      the modifiable statistic map
    • getVehicleInformation

      @NotNull public @NotNull PlayerVehicleInformation getVehicleInformation()
      Gets the player vehicle information.
      the player vehicle information
    • refreshAbilities

      protected void refreshAbilities()
      Sends to the player a PlayerAbilitiesPacket with all the updated fields.
    • addPacketToQueue

      public void addPacketToQueue(@NotNull @NotNull ClientPacket packet)
      All packets in the queue are executed in the update(long) method It is used internally to add all received packet from the client. Could be used to "simulate" a received packet, but to use at your own risk.
      packet - the packet to add in the queue
    • interpretPacketQueue

      @Internal @Experimental public void interpretPacketQueue()
    • refreshLatency

      public void refreshLatency(int latency)
      Changes the storage player latency and update its tab value.
      latency - the new player latency
    • refreshOnGround

      public void refreshOnGround(boolean onGround)
    • refreshKeepAlive

      public void refreshKeepAlive(long lastKeepAlive)
      Used to change internally the last sent last keep alive id.

      Warning: could lead to have the player kicked because of a wrong keep alive packet.

      lastKeepAlive - the new lastKeepAlive id
    • didAnswerKeepAlive

      public boolean didAnswerKeepAlive()
    • refreshAnswerKeepAlive

      public void refreshAnswerKeepAlive(boolean answerKeepAlive)
    • refreshHeldSlot

      public void refreshHeldSlot(byte slot)
      Changes the held item for the player viewers Also cancel item usage if isUsingItem() was true.

      Warning: the player will not be noticed by this chance, only his viewers, see instead: setHeldItemSlot(byte).

      slot - the new held slot
    • refreshItemUse

      public void refreshItemUse(@Nullable @Nullable Player.Hand itemUseHand, long itemUseTimeTicks)
    • clearItemUse

      public void clearItemUse()
    • callItemUpdateStateEvent

      @NotNull public @NotNull ItemUpdateStateEvent callItemUpdateStateEvent(@NotNull @NotNull Player.Hand hand)
      Used to call ItemUpdateStateEvent with the proper item It does check which hand to get the item to update.
      the called ItemUpdateStateEvent,
    • refreshVehicleSteer

      public void refreshVehicleSteer(float sideways, float forward, boolean jump, boolean unmount)
    • getLastKeepAlive

      public long getLastKeepAlive()
      Gets the last sent keep alive id.
      the last keep alive id sent to the player
    • asHoverEvent

      @NotNull public @NotNull HoverEvent<HoverEvent.ShowEntity> asHoverEvent(@NotNull @NotNull UnaryOperator<HoverEvent.ShowEntity> op)
      Specified by:
      asHoverEvent in interface HoverEventSource<HoverEvent.ShowEntity>
      asHoverEvent in class Entity
    • getAddPlayerToList

      @NotNull protected @NotNull PlayerInfoUpdatePacket getAddPlayerToList()
      Gets the packet to add the player from the tab-list.
      a PlayerInfoUpdatePacket to add the player
    • getRemovePlayerToList

      @NotNull protected @NotNull PlayerInfoRemovePacket getRemovePlayerToList()
      Gets the packet to remove the player from the tab-list.
      a PlayerInfoRemovePacket to remove the player
    • showPlayer

      protected void showPlayer(@NotNull @NotNull PlayerConnection connection)
      Sends all the related packet to have the player sent to another with related data (create player, spawn position, velocity, metadata, equipments, passengers, team).

      WARNING: this alone does not sync the player, please use Entity.addViewer(Player).

      connection - the connection to show the player to
    • getItemInMainHand

      @NotNull public @NotNull ItemStack getItemInMainHand()
      Description copied from interface: EquipmentHandler
      Gets the ItemStack in main hand.
      Specified by:
      getItemInMainHand in interface EquipmentHandler
      getItemInMainHand in class LivingEntity
      the ItemStack in main hand
    • setItemInMainHand

      public void setItemInMainHand(@NotNull @NotNull ItemStack itemStack)
      Description copied from interface: EquipmentHandler
      Changes the main hand ItemStack.
      Specified by:
      setItemInMainHand in interface EquipmentHandler
      setItemInMainHand in class LivingEntity
      itemStack - the main hand ItemStack
    • getItemInOffHand

      @NotNull public @NotNull ItemStack getItemInOffHand()
      Description copied from interface: EquipmentHandler
      Gets the ItemStack in off hand.
      Specified by:
      getItemInOffHand in interface EquipmentHandler
      getItemInOffHand in class LivingEntity
      the item in off hand
    • setItemInOffHand

      public void setItemInOffHand(@NotNull @NotNull ItemStack itemStack)
      Description copied from interface: EquipmentHandler
      Changes the off hand ItemStack.
      Specified by:
      setItemInOffHand in interface EquipmentHandler
      setItemInOffHand in class LivingEntity
      itemStack - the off hand ItemStack
    • getHelmet

      @NotNull public @NotNull ItemStack getHelmet()
      Description copied from interface: EquipmentHandler
      Gets the helmet.
      Specified by:
      getHelmet in interface EquipmentHandler
      getHelmet in class LivingEntity
      the helmet
    • setHelmet

      public void setHelmet(@NotNull @NotNull ItemStack itemStack)
      Description copied from interface: EquipmentHandler
      Changes the helmet.
      Specified by:
      setHelmet in interface EquipmentHandler
      setHelmet in class LivingEntity
      itemStack - the helmet
    • getChestplate

      @NotNull public @NotNull ItemStack getChestplate()
      Description copied from interface: EquipmentHandler
      Gets the chestplate.
      Specified by:
      getChestplate in interface EquipmentHandler
      getChestplate in class LivingEntity
      the chestplate
    • setChestplate

      public void setChestplate(@NotNull @NotNull ItemStack itemStack)
      Description copied from interface: EquipmentHandler
      Changes the chestplate.
      Specified by:
      setChestplate in interface EquipmentHandler
      setChestplate in class LivingEntity
      itemStack - the chestplate
    • getLeggings

      @NotNull public @NotNull ItemStack getLeggings()
      Description copied from interface: EquipmentHandler
      Gets the leggings.
      Specified by:
      getLeggings in interface EquipmentHandler
      getLeggings in class LivingEntity
      the leggings
    • setLeggings

      public void setLeggings(@NotNull @NotNull ItemStack itemStack)
      Description copied from interface: EquipmentHandler
      Changes the leggings.
      Specified by:
      setLeggings in interface EquipmentHandler
      setLeggings in class LivingEntity
      itemStack - the leggings
    • getBoots

      @NotNull public @NotNull ItemStack getBoots()
      Description copied from interface: EquipmentHandler
      Gets the boots.
      Specified by:
      getBoots in interface EquipmentHandler
      getBoots in class LivingEntity
      the boots
    • setBoots

      public void setBoots(@NotNull @NotNull ItemStack itemStack)
      Description copied from interface: EquipmentHandler
      Changes the boots.
      Specified by:
      setBoots in interface EquipmentHandler
      setBoots in class LivingEntity
      itemStack - the boots
    • getLocale

      public Locale getLocale()
      Description copied from interface: Localizable
      Gets the locale.
      Specified by:
      getLocale in interface Localizable
      the locale, or null if they do not have a locale set
    • updateSnapshot

      @NotNull public @NotNull PlayerSnapshot updateSnapshot(@NotNull @NotNull SnapshotUpdater updater)
      Description copied from interface: Snapshotable
      Updates the currently cached snapshot if required. The updater can be used to retrieve references to other snapshots while avoiding circular dependency. Be careful to do not store updater anywhere as its data will change when building requested references.

      This method is not thread-safe, and targeted at internal use since its execution rely on safe-points (e.g. end of ticks)

      Specified by:
      updateSnapshot in interface Snapshotable
      updateSnapshot in class Entity
      updater - the snapshot updater/context
      the updated snapshot
    • setLocale

      public void setLocale(@Nullable @Nullable Locale locale)
      Sets the player's locale. This will only set the locale of the player as it is stored in the server. This will also be reset if the settings are refreshed.
      Specified by:
      setLocale in interface Localizable
      locale - the new locale
    • identity

      @NotNull public @NotNull Identity identity()
      Specified by:
      identity in interface Identified
    • pointers

      @NotNull public @NotNull Pointers pointers()
      Specified by:
      pointers in interface Pointered
    • isPlayer

      public boolean isPlayer()
      Description copied from interface: CommandSender
      Gets if the sender is a Player.

      Consider using instanceof instead.

      Specified by:
      isPlayer in interface CommandSender
      true if 'this' is a player, false otherwise
    • asPlayer

      public Player asPlayer()
      Description copied from interface: CommandSender
      Casts this object to a Player. No checks are performed, ClassCastException can very much happen.
      Specified by:
      asPlayer in interface CommandSender
      See Also:
    • sendChunkUpdates

      protected void sendChunkUpdates(Chunk newChunk)
    • teleport

      @NotNull public @NotNull CompletableFuture<Void> teleport(@NotNull @NotNull Pos position, long @Nullable [] chunks, int flags)
      Description copied from class: Entity
      Teleports the entity only if the chunk at position is loaded or if Instance.hasEnabledAutoChunkLoad() returns true.
      teleport in class Entity
      position - the teleport position
      chunks - the chunk indexes to load before teleporting the entity, indexes are from ChunkUtils.getChunkIndex(int, int), can be null or empty to only load the chunk at position
      flags - flags used to teleport the entity relatively rather than absolutely use RelativeFlags to see available flags
      See Also: