Package cn.nukkit

Class Player

All Implemented Interfaces:
CommandSender, EntityDamageable, EntityNameable, InventoryHolder, IPlayer, ChunkLoader, Metadatable, Permissible, ServerOperator, Cloneable

public class Player extends EntityHuman implements CommandSender, InventoryHolder, ChunkLoader, IPlayer
Author:
MagicDroidX & Box (Nukkit Project)
  • Field Details

    • EMPTY_ARRAY

      @PowerNukkitOnly @Since("1.4.0.0-PN") public static final Player[] EMPTY_ARRAY
    • SURVIVAL

      public static final int SURVIVAL
      See Also:
    • CREATIVE

      public static final int CREATIVE
      See Also:
    • ADVENTURE

      public static final int ADVENTURE
      See Also:
    • SPECTATOR

      public static final int SPECTATOR
      See Also:
    • VIEW

      public static final int VIEW
      See Also:
    • SURVIVAL_SLOTS

      public static final int SURVIVAL_SLOTS
      See Also:
    • CREATIVE_SLOTS

      public static final int CREATIVE_SLOTS
      See Also:
    • CRAFTING_SMALL

      public static final int CRAFTING_SMALL
      See Also:
    • CRAFTING_BIG

      public static final int CRAFTING_BIG
      See Also:
    • CRAFTING_ANVIL

      public static final int CRAFTING_ANVIL
      See Also:
    • CRAFTING_ENCHANT

      public static final int CRAFTING_ENCHANT
      See Also:
    • CRAFTING_BEACON

      public static final int CRAFTING_BEACON
      See Also:
    • CRAFTING_GRINDSTONE

      @PowerNukkitOnly public static final int CRAFTING_GRINDSTONE
      See Also:
    • CRAFTING_STONECUTTER

      @PowerNukkitOnly public static final int CRAFTING_STONECUTTER
      See Also:
    • CRAFTING_CARTOGRAPHY

      @PowerNukkitOnly public static final int CRAFTING_CARTOGRAPHY
      See Also:
    • CRAFTING_SMITHING

      @PowerNukkitOnly public static final int CRAFTING_SMITHING
      See Also:
    • TRADE_WINDOW_ID

      @PowerNukkitXOnly @Since("1.19.21-r1") public static final int TRADE_WINDOW_ID
      See Also:
    • DEFAULT_SPEED

      public static final float DEFAULT_SPEED
      See Also:
    • MAXIMUM_SPEED

      public static final float MAXIMUM_SPEED
      See Also:
    • PERMISSION_CUSTOM

      public static final int PERMISSION_CUSTOM
      See Also:
    • PERMISSION_OPERATOR

      public static final int PERMISSION_OPERATOR
      See Also:
    • PERMISSION_MEMBER

      public static final int PERMISSION_MEMBER
      See Also:
    • PERMISSION_VISITOR

      public static final int PERMISSION_VISITOR
      See Also:
    • ANVIL_WINDOW_ID

      public static final int ANVIL_WINDOW_ID
      See Also:
    • ENCHANT_WINDOW_ID

      public static final int ENCHANT_WINDOW_ID
      See Also:
    • BEACON_WINDOW_ID

      public static final int BEACON_WINDOW_ID
      See Also:
    • GRINDSTONE_WINDOW_ID

      @PowerNukkitOnly public static final int GRINDSTONE_WINDOW_ID
    • SMITHING_WINDOW_ID

      @Since("1.4.0.0-PN") @PowerNukkitOnly public static final int SMITHING_WINDOW_ID
    • RESOURCE_PACK_CHUNK_SIZE

      @Since("FUTURE") protected static final int RESOURCE_PACK_CHUNK_SIZE
      See Also:
    • interfaz

      protected final SourceInterface interfaz
    • playedBefore

      public boolean playedBefore
    • spawned

      public boolean spawned
    • loggedIn

      public boolean loggedIn
    • locallyInitialized

      @Since("1.4.0.0-PN") public boolean locallyInitialized
    • gamemode

      public int gamemode
    • lastBreak

      public long lastBreak
    • windowCnt

      protected int windowCnt
    • windows

      protected final com.google.common.collect.BiMap<Inventory,Integer> windows
    • windowIndex

      protected final com.google.common.collect.BiMap<Integer,Inventory> windowIndex
    • permanentWindows

      protected final Set<Integer> permanentWindows
    • closingWindowId

      @Since("1.4.0.0-PN") protected int closingWindowId
    • messageCounter

      protected int messageCounter
    • speed

      public Vector3 speed
    • achievements

      public final HashSet<String> achievements
    • craftingType

      public int craftingType
    • playerUIInventory

      protected PlayerUIInventory playerUIInventory
    • craftingGrid

      protected CraftingGrid craftingGrid
    • craftingTransaction

      protected CraftingTransaction craftingTransaction
    • enchantTransaction

      @Since("1.3.1.0-PN") protected EnchantTransaction enchantTransaction
    • repairItemTransaction

      @Since("1.4.0.0-PN") protected RepairItemTransaction repairItemTransaction
    • grindstoneTransaction

      @Since("1.4.0.0-PN") @PowerNukkitOnly protected GrindstoneTransaction grindstoneTransaction
    • smithingTransaction

      @Since("1.4.0.0-PN") @PowerNukkitOnly protected SmithingTransaction smithingTransaction
    • tradingTransaction

      @PowerNukkitXOnly @Since("1.19.21-r1") protected TradingTransaction tradingTransaction
    • creationTime

      public long creationTime
    • randomClientId

      protected long randomClientId
    • forceMovement

      protected Vector3 forceMovement
    • teleportPosition

      protected Vector3 teleportPosition
    • connected

      protected boolean connected
    • socketAddress

      protected final InetSocketAddress socketAddress
    • removeFormat

      protected boolean removeFormat
    • username

      protected String username
    • iusername

      protected String iusername
    • displayName

      protected String displayName
    • startAction

      protected int startAction
    • sleeping

      protected Vector3 sleeping
    • clientID

      protected Long clientID
    • stepHeight

      protected float stepHeight
    • usedChunks

      public final Map<Long,Boolean> usedChunks
    • chunkLoadCount

      protected int chunkLoadCount
    • loadQueue

      protected final it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap<Boolean> loadQueue
    • nextChunkOrderRun

      protected int nextChunkOrderRun
    • hiddenPlayers

      protected final Map<UUID,Player> hiddenPlayers
    • newPosition

      protected Vector3 newPosition
    • chunkRadius

      protected int chunkRadius
    • viewDistance

      protected int viewDistance
    • chunksPerTick

      protected final int chunksPerTick
    • spawnThreshold

      protected final int spawnThreshold
    • spawnPosition

      protected Position spawnPosition
    • spawnBlockPosition

      @PowerNukkitOnly @Since("1.4.0.0-PN") protected Vector3 spawnBlockPosition
    • inAirTicks

      protected int inAirTicks
    • startAirTicks

      protected int startAirTicks
    • adventureSettings

      protected AdventureSettings adventureSettings
    • checkMovement

      protected boolean checkMovement
    • foodData

      protected PlayerFood foodData
    • enableClientCommand

      protected boolean enableClientCommand
    • lastEnderPearl

      protected int lastEnderPearl
    • lastChorusFruitTeleport

      protected int lastChorusFruitTeleport
    • breakingBlock

      public Block breakingBlock
    • pickedXPOrb

      public int pickedXPOrb
    • formWindowCount

      protected int formWindowCount
    • formWindows

      protected Map<Integer,FormWindow> formWindows
    • serverSettings

      protected Map<Integer,FormWindow> serverSettings
    • dialogWindows

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") protected com.google.common.cache.Cache<String,FormWindowDialog> dialogWindows
      我们使用google的cache来存储NPC对话框发送信息 原因是发送过去的对话框客户端有几率不响应,在特定情况下我们无法清除这些对话框,这会导致内存泄漏 5分钟后未响应的对话框会被清除
    • dummyBossBars

      protected Map<Long,DummyBossBar> dummyBossBars
    • shouldLogin

      protected boolean shouldLogin
    • fishing

      public EntityFishingHook fishing
    • lastSkinChange

      public long lastSkinChange
    • lastRightClickTime

      protected double lastRightClickTime
    • lastRightClickPos

      protected Vector3 lastRightClickPos
    • lastPlayerdLevelUpSoundTime

      @PowerNukkitOnly @Since("1.4.0.0-PN") protected int lastPlayerdLevelUpSoundTime
  • Constructor Details

  • Method Details

    • getSoulSpeedMultiplier

      public float getSoulSpeedMultiplier()
    • getStartActionTick

      public int getStartActionTick()
    • startAction

      public void startAction()
    • stopAction

      public void stopAction()
    • getLastEnderPearlThrowingTick

      public int getLastEnderPearlThrowingTick()
    • onThrowEnderPearl

      public void onThrowEnderPearl()
    • getLastChorusFruitTeleport

      public int getLastChorusFruitTeleport()
    • onChorusFruitTeleport

      public void onChorusFruitTeleport()
    • getViewingEnderChest

      public BlockEnderChest getViewingEnderChest()
    • setViewingEnderChest

      public void setViewingEnderChest(BlockEnderChest chest)
    • getLeaveMessage

      public TranslationContainer getLeaveMessage()
    • getClientSecret

      public String getClientSecret()
    • getClientId

      @Deprecated public Long getClientId()
      Deprecated.
      This might disappear in the future. Please use getUniqueId() instead (IP + clientId + name combo, in the future it'll change to real UUID for online auth)
      Returns:
      random client id
    • isBanned

      public boolean isBanned()
      Description copied from interface: IPlayer
      返回这个玩家是否被封禁(ban)。
      Returns if this player is banned.
      Specified by:
      isBanned in interface IPlayer
      Returns:
      这个玩家的名称。
      The name of this player.
      See Also:
    • setBanned

      public void setBanned(boolean value)
      Description copied from interface: IPlayer
      设置这个玩家是否被封禁(ban)。
      Sets this player to be banned or to be pardoned.
      Specified by:
      setBanned in interface IPlayer
      Parameters:
      value - 如果为true,封禁这个玩家。如果为false,解封这个玩家。
      true for ban and false for pardon.
      See Also:
    • isWhitelisted

      public boolean isWhitelisted()
      Description copied from interface: IPlayer
      返回这个玩家是否已加入白名单。
      Returns if this player is pardoned by whitelist.
      Specified by:
      isWhitelisted in interface IPlayer
      Returns:
      这个玩家是否已加入白名单。
      If this player is pardoned by whitelist.
      See Also:
    • setWhitelisted

      public void setWhitelisted(boolean value)
      Description copied from interface: IPlayer
      把这个玩家加入白名单,或者取消这个玩家的白名单。
      Adds this player to the white list, or removes it from the whitelist.
      Specified by:
      setWhitelisted in interface IPlayer
      Parameters:
      value - 如果为true,把玩家加入白名单。如果为false,取消这个玩家的白名单。
      true for add and false for remove.
      See Also:
    • getPlayer

      public Player getPlayer()
      Description copied from interface: IPlayer
      得到这个接口的Player对象。
      Returns a Player object for this interface.
      Specified by:
      getPlayer in interface IPlayer
      Returns:
      这个接口的 Player对象。
      a Player object for this interface.
      See Also:
    • getFirstPlayed

      public Long getFirstPlayed()
      Description copied from interface: IPlayer
      得到这个玩家第一次游戏的时间。
      Returns the time this player first played in this server.
      Specified by:
      getFirstPlayed in interface IPlayer
      Returns:
      Unix时间(以秒为单位。
      Unix time in seconds.
    • getLastPlayed

      public Long getLastPlayed()
      Description copied from interface: IPlayer
      得到这个玩家上次加入游戏的时间。
      Returns the time this player last joined in this server.
      Specified by:
      getLastPlayed in interface IPlayer
      Returns:
      Unix时间(以秒为单位。
      Unix time in seconds.
    • hasPlayedBefore

      public boolean hasPlayedBefore()
      Description copied from interface: IPlayer
      返回这个玩家以前是否来过服务器。
      Returns if this player has played in this server before.

      如果想得到这个玩家是不是第一次玩,可以使用:
      If you want to know if this player is the first time playing in this server, you can use:

      if(!player.hasPlayerBefore()) {...}
      Specified by:
      hasPlayedBefore in interface IPlayer
      Returns:
      这个玩家以前是不是玩过游戏。
      If this player has played in this server before.
    • getAdventureSettings

      public AdventureSettings getAdventureSettings()
    • setAdventureSettings

      public void setAdventureSettings(AdventureSettings adventureSettings)
    • resetInAirTicks

      public void resetInAirTicks()
    • setAllowFlight

      @Deprecated public void setAllowFlight(boolean value)
      Deprecated.
    • getAllowFlight

      @Deprecated public boolean getAllowFlight()
      Deprecated.
    • setAllowModifyWorld

      public void setAllowModifyWorld(boolean value)
    • setAllowInteract

      public void setAllowInteract(boolean value)
    • setAllowInteract

      public void setAllowInteract(boolean value, boolean containers)
    • setAutoJump

      @Deprecated public void setAutoJump(boolean value)
      Deprecated.
    • hasAutoJump

      @Deprecated public boolean hasAutoJump()
      Deprecated.
    • spawnTo

      public void spawnTo(Player player)
      Overrides:
      spawnTo in class EntityHuman
    • getServer

      public Server getServer()
      Description copied from interface: CommandSender
      EntitySelector 返回命令发送者所在的服务器。
      Returns the server of the command sender.
      Specified by:
      getServer in interface CommandSender
      Specified by:
      getServer in interface IPlayer
      Overrides:
      getServer in class Entity
      Returns:
      命令发送者所在的服务器。
      the server of the command sender.
    • getRemoveFormat

      public boolean getRemoveFormat()
    • setRemoveFormat

      public void setRemoveFormat()
    • setRemoveFormat

      public void setRemoveFormat(boolean remove)
    • canSee

      public boolean canSee(Player player)
    • hidePlayer

      public void hidePlayer(Player player)
    • showPlayer

      public void showPlayer(Player player)
    • canCollideWith

      public boolean canCollideWith(Entity entity)
      Overrides:
      canCollideWith in class Entity
    • resetFallDistance

      public void resetFallDistance()
      Overrides:
      resetFallDistance in class Entity
    • isOnline

      public boolean isOnline()
      Description copied from interface: IPlayer
      返回这个玩家是否在线。
      Returns if this player is online.
      Specified by:
      isOnline in interface IPlayer
      Returns:
      这个玩家是否在线。
      If this player is online.
    • isOp

      public boolean isOp()
      Description copied from interface: ServerOperator
      返回这个对象是不是服务器管理员。
      Returns if this object is an operator.
      Specified by:
      isOp in interface ServerOperator
      Returns:
      这个对象是不是服务器管理员。
      if this object is an operator.
    • setOp

      public void setOp(boolean value)
      Description copied from interface: ServerOperator
      把这个对象设置成服务器管理员。
      Sets this object to be an operator or not to be.
      Specified by:
      setOp in interface ServerOperator
      Parameters:
      value - true为授予管理员,false为取消管理员。
      true for giving this operator or false for cancelling.
    • isPermissionSet

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

      public boolean isPermissionSet(Permission permission)
      Specified by:
      isPermissionSet in interface Permissible
    • hasPermission

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

      public boolean hasPermission(Permission permission)
      Specified by:
      hasPermission in interface Permissible
    • addAttachment

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

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

      public PermissionAttachment addAttachment(Plugin plugin, String name, Boolean value)
      Specified by:
      addAttachment in interface Permissible
    • removeAttachment

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

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

      public boolean isEnableClientCommand()
    • setEnableClientCommand

      public void setEnableClientCommand(boolean enable)
    • sendCommandData

      public void sendCommandData()
    • getEffectivePermissions

      public Map<String,PermissionAttachmentInfo> getEffectivePermissions()
      Specified by:
      getEffectivePermissions in interface Permissible
    • initEntity

      protected void initEntity()
      Overrides:
      initEntity in class EntityHuman
    • isPlayer

      public boolean isPlayer()
      Specified by:
      isPlayer in interface CommandSender
    • asPlayer

      public Player asPlayer()
      Specified by:
      asPlayer in interface CommandSender
    • isEntity

      public boolean isEntity()
      Specified by:
      isEntity in interface CommandSender
      Returns:
      whether the sender is an entity
      please use this method to check whether the sender is an entity instead of using code "xxx instanceof Entity"
      because the sender may not an instance of "Entity" but in fact it is executing commands identity as an entity(eg: "ExecutorCommandSender")
    • asEntity

      public Entity asEntity()
      Specified by:
      asEntity in interface CommandSender
    • removeAchievement

      public void removeAchievement(String achievementId)
    • hasAchievement

      public boolean hasAchievement(String achievementId)
    • isConnected

      public boolean isConnected()
    • getDisplayName

      public String getDisplayName()
    • setDisplayName

      public void setDisplayName(String displayName)
    • setSkin

      public void setSkin(Skin skin)
      Overrides:
      setSkin in class EntityHuman
    • getAddress

      public String getAddress()
    • getPort

      public int getPort()
    • getSocketAddress

      public InetSocketAddress getSocketAddress()
    • getNextPosition

      public Position getNextPosition()
    • isSleeping

      public boolean isSleeping()
    • getInAirTicks

      public int getInAirTicks()
    • isUsingItem

      public boolean isUsingItem()
      Returns whether the player is currently using an item (right-click and hold).
      Returns:
      bool
    • setUsingItem

      public void setUsingItem(boolean value)
    • getButtonText

      public String getButtonText()
    • setButtonText

      public void setButtonText(String text)
    • unloadChunk

      public void unloadChunk(int x, int z)
    • unloadChunk

      public void unloadChunk(int x, int z, Level level)
    • isInOverWorld

      public boolean isInOverWorld()
    • getSpawn

      public Position getSpawn()
    • getSpawnBlock

      @PowerNukkitOnly @Since("1.4.0.0-PN") @Nullable public Vector3 getSpawnBlock()
      The block that holds the player respawn position. May be null when unknown.
      Returns:
      The position of a bed, respawn anchor, or null when unknown.
    • setSpawnBlock

      @PowerNukkitOnly @Since("1.4.0.0-PN") public void setSpawnBlock(@Nullable Vector3 spawnBlock)
      Sets the position of the block that holds the player respawn position. May be null when unknown.
      Parameters:
      spawnBlock - The position of a bed or respawn anchor
    • sendChunk

      public void sendChunk(int x, int z, DataPacket packet)
    • sendChunk

      public void sendChunk(int x, int z, int subChunkCount, byte[] payload)
    • sendNextChunk

      protected void sendNextChunk()
    • doFirstSpawn

      protected void doFirstSpawn()
    • updateTrackingPositions

      @PowerNukkitOnly @Since("1.4.0.0-PN") public void updateTrackingPositions()
    • updateTrackingPositions

      @PowerNukkitOnly @Since("1.4.0.0-PN") public void updateTrackingPositions(boolean delayed)
    • orderChunks

      protected boolean orderChunks()
    • batchDataPacket

      @DeprecationDetails(by="Cloudburst Nukkit", since="1.4.0.0-PN", replaceWith="dataPacket(DataPacket)", reason="Batching packet is now handled near the RakNet layer") @Deprecated public boolean batchDataPacket(DataPacket packet)
      Deprecated.
    • dataPacket

      public boolean dataPacket(DataPacket packet)
      0 is true -1 is false other is identifer
      Parameters:
      packet - packet to send
      Returns:
      packet successfully sent
    • dataPacket

      @DeprecationDetails(by="Cloudburst Nukkit", since="2019-05-08", replaceWith="dataPacket(DataPacket)", reason="ACKs are handled by the RakNet layer only") @PowerNukkitDifference(since="1.4.0.0-PN", info="Cloudburst changed the return values from 0/-1 to 1/0, breaking backward compatibility for no reason, we reversed that.") @Deprecated public int dataPacket(DataPacket packet, boolean needACK)
      Deprecated.
    • directDataPacket

      @Deprecated @DeprecationDetails(by="Cloudburst Nukkit", since="1.4.0.0-PN", replaceWith="dataPacket(DataPacket)", reason="Direct packets are no longer allowed") public boolean directDataPacket(DataPacket packet)
      Deprecated.
      0 is true -1 is false other is identifer
      Parameters:
      packet - packet to send
      Returns:
      packet successfully sent
    • directDataPacket

      @DeprecationDetails(by="Cloudburst Nukkit", since="2019-05-08", replaceWith="dataPacket(DataPacket)", reason="ACK are handled by the RakNet layer and direct packets are no longer allowed") @PowerNukkitDifference(since="1.4.0.0-PN", info="Cloudburst changed the return values from 0/-1 to 1/0, breaking backward compatibility for no reason, we reversed that.") @Deprecated public int directDataPacket(DataPacket packet, boolean needACK)
      Deprecated.
    • getPing

      public int getPing()
    • sleepOn

      public boolean sleepOn(Vector3 pos)
    • setSpawn

      @PowerNukkitDifference(info="pos can be null now and if it is null,the player\'s spawn will use the level\'s default spawn") public void setSpawn(@Nullable Vector3 pos)
    • stopSleep

      public void stopSleep()
    • awardAchievement

      public boolean awardAchievement(String achievementId)
    • getGamemode

      public int getGamemode()
    • setGamemode

      public boolean setGamemode(int gamemode)
    • setGamemode

      public boolean setGamemode(int gamemode, boolean clientSide)
    • setGamemode

      public boolean setGamemode(int gamemode, boolean clientSide, AdventureSettings newSettings)
    • sendSettings

      @Deprecated public void sendSettings()
      Deprecated.
    • isSurvival

      public boolean isSurvival()
    • isCreative

      public boolean isCreative()
    • isSpectator

      public boolean isSpectator()
    • isAdventure

      public boolean isAdventure()
    • getDrops

      public Item[] getDrops()
      Overrides:
      getDrops in class EntityHumanType
    • fastMove

      public boolean fastMove(double dx, double dy, double dz)
      Overrides:
      fastMove in class Entity
    • checkGroundState

      protected void checkGroundState(double movX, double movY, double movZ, double dx, double dy, double dz)
      Overrides:
      checkGroundState in class Entity
    • reCalcOffsetBoundingBox

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") public AxisAlignedBB reCalcOffsetBoundingBox()
    • checkBlockCollision

      protected void checkBlockCollision()
      Overrides:
      checkBlockCollision in class Entity
    • checkNearEntities

      protected void checkNearEntities()
    • processMovement

      protected void processMovement(int tickDiff)
    • addMovement

      public void addMovement(double x, double y, double z, double yaw, double pitch, double headYaw)
      Overrides:
      addMovement in class EntityHuman
    • setMotion

      public boolean setMotion(Vector3 motion)
      Overrides:
      setMotion in class Entity
    • sendAttributes

      public void sendAttributes()
    • onUpdate

      public boolean onUpdate(int currentTick)
      Overrides:
      onUpdate in class Entity
    • entityBaseTick

      public boolean entityBaseTick(int tickDiff)
      Overrides:
      entityBaseTick in class EntityLiving
    • checkInteractNearby

      public void checkInteractNearby()
    • getEntityPlayerLookingAt

      public EntityInteractable getEntityPlayerLookingAt(int maxDistance)
      Returns the Entity the player is looking at currently
      Parameters:
      maxDistance - the maximum distance to check for entities
      Returns:
      Entity|null either NULL if no entity is found or an instance of the entity
    • checkNetwork

      public void checkNetwork()
    • canInteract

      public boolean canInteract(Vector3 pos, double maxDistance)
    • canInteract

      public boolean canInteract(Vector3 pos, double maxDistance, double maxDiff)
    • processLogin

      protected void processLogin()
    • completeLoginSequence

      protected void completeLoginSequence()
    • handleDataPacket

      public void handleDataPacket(DataPacket packet)
    • chat

      public boolean chat(String message)
      Sends a chat message as this player. If the message begins with a / (forward-slash) it will be treated as a command.
      Parameters:
      message - message to send
      Returns:
      successful
    • kick

      public boolean kick()
    • kick

      public boolean kick(String reason, boolean isAdmin)
    • kick

      public boolean kick(String reason)
    • kick

      public boolean kick(PlayerKickEvent.Reason reason)
    • kick

      public boolean kick(PlayerKickEvent.Reason reason, String reasonString)
    • kick

      public boolean kick(PlayerKickEvent.Reason reason, boolean isAdmin)
    • kick

      public boolean kick(PlayerKickEvent.Reason reason, String reasonString, boolean isAdmin)
    • setViewDistance

      public void setViewDistance(int distance)
    • getViewDistance

      public int getViewDistance()
    • sendMessage

      public void sendMessage(String message)
      Description copied from interface: CommandSender
      给命令发送者返回信息。
      Sends a message to the command sender.
      Specified by:
      sendMessage in interface CommandSender
      Parameters:
      message - 要发送的信息。
      Message to send.
      See Also:
    • sendMessage

      public void sendMessage(TextContainer message)
      Description copied from interface: CommandSender
      给命令发送者返回信息。
      Sends a message to the command sender.
      Specified by:
      sendMessage in interface CommandSender
      Parameters:
      message - 要发送的信息。
      Message to send.
    • sendRawTextMessage

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") public void sendRawTextMessage(RawText text)
    • sendTranslation

      public void sendTranslation(String message)
    • sendTranslation

      public void sendTranslation(String message, String[] parameters)
    • sendChat

      public void sendChat(String message)
    • sendChat

      public void sendChat(String source, String message)
    • sendPopup

      public void sendPopup(String message)
    • sendPopup

      public void sendPopup(String message, String subtitle)
    • sendTip

      public void sendTip(String message)
    • clearTitle

      public void clearTitle()
    • resetTitleSettings

      public void resetTitleSettings()
      Resets both title animation times and subtitle for the next shown title
    • setSubtitle

      public void setSubtitle(String subtitle)
    • setRawTextSubTitle

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") public void setRawTextSubTitle(RawText text)
    • setTitleAnimationTimes

      public void setTitleAnimationTimes(int fadein, int duration, int fadeout)
    • setRawTextTitle

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") public void setRawTextTitle(RawText text)
    • sendTitle

      public void sendTitle(String title)
    • sendTitle

      public void sendTitle(String title, String subtitle)
    • sendTitle

      public void sendTitle(String title, String subtitle, int fadeIn, int stay, int fadeOut)
    • sendActionBar

      public void sendActionBar(String title)
    • sendActionBar

      public void sendActionBar(String title, int fadein, int duration, int fadeout)
    • setRawTextActionBar

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") public void setRawTextActionBar(RawText text)
    • setRawTextActionBar

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") public void setRawTextActionBar(RawText text, int fadein, int duration, int fadeout)
    • close

      public void close()
      Overrides:
      close in class EntityHuman
    • close

      public void close(String message)
    • close

      public void close(String message, String reason)
    • close

      public void close(String message, String reason, boolean notify)
    • close

      public void close(TextContainer message)
    • close

      public void close(TextContainer message, String reason)
    • close

      public void close(TextContainer message, String reason, boolean notify)
    • save

      public void save()
    • saveNBT

      public void saveNBT()
      Overrides:
      saveNBT in class EntityHuman
    • save

      public void save(boolean async)
    • getOriginalName

      @PowerNukkitOnly @Since("1.5.1.0-PN") public String getOriginalName()
      Description copied from class: Entity
      The name that English name of the type of this entity.
      Overrides:
      getOriginalName in class EntityHuman
    • getName

      public String getName()
      Description copied from class: Entity
      The current name used by this entity in the name tag, or the static name if the entity don't have nametag.
      Specified by:
      getName in interface CommandSender
      Specified by:
      getName in interface IPlayer
      Overrides:
      getName in class EntityHuman
      Returns:
      命令发送者的名称。
      the name of the command sender.
      See Also:
    • kill

      public void kill()
      Overrides:
      kill in class EntityLiving
    • isValidRespawnBlock

      @PowerNukkitOnly @Since("1.4.0.0-PN") protected boolean isValidRespawnBlock(Block block)
    • respawn

      @PowerNukkitDifference(info="will force using the spawnposition if the value spawnBlock is null,to fix the bug of command /spawnpoint", since="1.6.0.0-PNX") protected void respawn()
    • setHealth

      public void setHealth(float health)
      Overrides:
      setHealth in class EntityLiving
    • setMaxHealth

      public void setMaxHealth(int maxHealth)
      Overrides:
      setMaxHealth in class Entity
    • getExperience

      public int getExperience()
    • getExperienceLevel

      public int getExperienceLevel()
    • addExperience

      public void addExperience(int add)
    • addExperience

      @PowerNukkitOnly public void addExperience(int add, boolean playLevelUpSound)
    • calculateRequireExperience

      public static int calculateRequireExperience(int level)
    • setExperience

      public void setExperience(int exp)
    • setExperience

      public void setExperience(int exp, int level)
    • setExperience

      @PowerNukkitOnly public void setExperience(int exp, int level, boolean playLevelUpSound)
    • sendExperience

      public void sendExperience()
    • sendExperience

      public void sendExperience(int exp)
    • sendExperienceLevel

      public void sendExperienceLevel()
    • sendExperienceLevel

      public void sendExperienceLevel(int level)
    • setAttribute

      public void setAttribute(Attribute attribute)
    • setMovementSpeed

      public void setMovementSpeed(float speed)
      Overrides:
      setMovementSpeed in class EntityLiving
    • setMovementSpeed

      public void setMovementSpeed(float speed, boolean send)
    • sendMovementSpeed

      @Since("1.4.0.0-PN") public void sendMovementSpeed(float speed)
    • getKiller

      public Entity getKiller()
    • attack

      public boolean attack(EntityDamageEvent source)
      Overrides:
      attack in class EntityHumanType
    • dropItem

      public boolean dropItem(Item item)
      Drops an item on the ground in front of the player. Returns if the item drop was successful.
      Parameters:
      item - to drop
      Returns:
      bool if the item was dropped or if the item was null
    • dropAndGetItem

      @Since("1.4.0.0-PN") @Nullable public EntityItem dropAndGetItem(@Nonnull Item item)
      Drops an item on the ground in front of the player. Returns the dropped item.
      Parameters:
      item - to drop
      Returns:
      EntityItem if the item was dropped or null if the item was null
    • sendPosition

      public void sendPosition(Vector3 pos)
    • sendPosition

      public void sendPosition(Vector3 pos, double yaw)
    • sendPosition

      public void sendPosition(Vector3 pos, double yaw, double pitch)
    • sendPosition

      public void sendPosition(Vector3 pos, double yaw, double pitch, int mode)
    • sendPosition

      public void sendPosition(Vector3 pos, double yaw, double pitch, int mode, Player[] targets)
    • checkChunks

      protected void checkChunks()
      Overrides:
      checkChunks in class Entity
    • checkTeleportPosition

      protected boolean checkTeleportPosition()
    • sendPlayStatus

      protected void sendPlayStatus(int status)
    • sendPlayStatus

      protected void sendPlayStatus(int status, boolean immediate)
    • teleport

      public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause)
      Overrides:
      teleport in class Entity
    • forceSendEmptyChunks

      protected void forceSendEmptyChunks()
    • teleportImmediate

      public void teleportImmediate(Location location)
    • teleportImmediate

      public void teleportImmediate(Location location, PlayerTeleportEvent.TeleportCause cause)
    • showFormWindow

      public int showFormWindow(FormWindow window)
      Shows a new FormWindow to the player You can find out FormWindow result by listening to PlayerFormRespondedEvent
      Parameters:
      window - to show
      Returns:
      form id to use in PlayerFormRespondedEvent
    • showFormWindow

      public int showFormWindow(FormWindow window, int id)
      Shows a new FormWindow to the player You can find out FormWindow result by listening to PlayerFormRespondedEvent
      Parameters:
      window - to show
      id - form id
      Returns:
      form id to use in PlayerFormRespondedEvent
    • showDialogWindow

      public void showDialogWindow(FormWindowDialog dialog)
    • showDialogWindow

      public void showDialogWindow(FormWindowDialog dialog, boolean book)
    • addServerSettings

      public int addServerSettings(FormWindow window)
      Shows a new setting page in game settings You can find out settings result by listening to PlayerFormRespondedEvent
      Parameters:
      window - to show on settings page
      Returns:
      form id to use in PlayerFormRespondedEvent
    • createBossBar

      @Deprecated public long createBossBar(String text, int length)
      Deprecated.
      Creates and sends a BossBar to the player
      Parameters:
      text - The BossBar message
      length - The BossBar percentage
      Returns:
      bossBarId The BossBar ID, you should store it if you want to remove or update the BossBar later
    • createBossBar

      public long createBossBar(DummyBossBar dummyBossBar)
      Creates and sends a BossBar to the player
      Parameters:
      dummyBossBar - DummyBossBar Object (Instantiate it by the Class Builder)
      Returns:
      bossBarId The BossBar ID, you should store it if you want to remove or update the BossBar later
      See Also:
    • getDummyBossBar

      public DummyBossBar getDummyBossBar(long bossBarId)
      Get a DummyBossBar object
      Parameters:
      bossBarId - The BossBar ID
      Returns:
      DummyBossBar object
      See Also:
    • getDummyBossBars

      public Map<Long,DummyBossBar> getDummyBossBars()
      Get all DummyBossBar objects
      Returns:
      DummyBossBars Map
    • updateBossBar

      @Deprecated public void updateBossBar(String text, int length, long bossBarId)
      Deprecated.
      Updates a BossBar
      Parameters:
      text - The new BossBar message
      length - The new BossBar length
      bossBarId - The BossBar ID
    • removeBossBar

      public void removeBossBar(long bossBarId)
      Removes a BossBar
      Parameters:
      bossBarId - The BossBar ID
    • getWindowId

      public int getWindowId(Inventory inventory)
    • getWindowById

      public Inventory getWindowById(int id)
    • addWindow

      public int addWindow(Inventory inventory)
    • addWindow

      public int addWindow(Inventory inventory, Integer forceId)
    • addWindow

      public int addWindow(Inventory inventory, Integer forceId, boolean isPermanent)
    • addWindow

      @Since("1.4.0.0-PN") public int addWindow(Inventory inventory, Integer forceId, boolean isPermanent, boolean alwaysOpen)
    • getTopWindow

      public Optional<Inventory> getTopWindow()
    • removeWindow

      public void removeWindow(Inventory inventory)
    • removeWindow

      @Since("1.4.0.0-PN") protected void removeWindow(Inventory inventory, boolean isResponse)
    • sendAllInventories

      public void sendAllInventories()
    • addDefaultWindows

      protected void addDefaultWindows()
    • getUIInventory

      public PlayerUIInventory getUIInventory()
    • getCursorInventory

      public PlayerCursorInventory getCursorInventory()
    • getCraftingGrid

      public CraftingGrid getCraftingGrid()
    • setCraftingGrid

      public void setCraftingGrid(CraftingGrid grid)
    • resetCraftingGridType

      public void resetCraftingGridType()
    • removeAllWindows

      public void removeAllWindows()
    • removeAllWindows

      public void removeAllWindows(boolean permanent)
    • getClosingWindowId

      @Since("1.4.0.0-PN") public int getClosingWindowId()
    • setMetadata

      public void setMetadata(String metadataKey, MetadataValue newMetadataValue)
      Specified by:
      setMetadata in interface Metadatable
      Overrides:
      setMetadata in class Entity
    • getMetadata

      public List<MetadataValue> getMetadata(String metadataKey)
      Specified by:
      getMetadata in interface Metadatable
      Overrides:
      getMetadata in class Entity
    • hasMetadata

      public boolean hasMetadata(String metadataKey)
      Specified by:
      hasMetadata in interface Metadatable
      Overrides:
      hasMetadata in class Entity
    • removeMetadata

      public void removeMetadata(String metadataKey, Plugin owningPlugin)
      Specified by:
      removeMetadata in interface Metadatable
      Overrides:
      removeMetadata in class Entity
    • onChunkChanged

      public void onChunkChanged(FullChunk chunk)
      Specified by:
      onChunkChanged in interface ChunkLoader
    • onChunkLoaded

      public void onChunkLoaded(FullChunk chunk)
      Specified by:
      onChunkLoaded in interface ChunkLoader
    • onChunkPopulated

      public void onChunkPopulated(FullChunk chunk)
      Specified by:
      onChunkPopulated in interface ChunkLoader
    • onChunkUnloaded

      public void onChunkUnloaded(FullChunk chunk)
      Specified by:
      onChunkUnloaded in interface ChunkLoader
    • onBlockChanged

      public void onBlockChanged(Vector3 block)
      Specified by:
      onBlockChanged in interface ChunkLoader
    • getLoaderId

      public int getLoaderId()
      Specified by:
      getLoaderId in interface ChunkLoader
    • isLoaderActive

      public boolean isLoaderActive()
      Specified by:
      isLoaderActive in interface ChunkLoader
    • getChunkCacheFromData

      public static BatchPacket getChunkCacheFromData(int chunkX, int chunkZ, int subChunkCount, byte[] payload)
    • isFoodEnabled

      public boolean isFoodEnabled()
    • setFoodEnabled

      public void setFoodEnabled(boolean foodEnabled)
    • getFoodData

      public PlayerFood getFoodData()
    • switchLevel

      public boolean switchLevel(Level level)
      Overrides:
      switchLevel in class Entity
    • setCheckMovement

      public void setCheckMovement(boolean checkMovement)
    • isCheckingMovement

      public boolean isCheckingMovement()
      Since:
      1.2.1.0-PN
    • setLocale

      public void setLocale(Locale locale)
    • getLocale

      public Locale getLocale()
    • setSprinting

      public void setSprinting(boolean value)
      Overrides:
      setSprinting in class Entity
    • transfer

      public void transfer(InetSocketAddress address)
    • getLoginChainData

      public LoginChainData getLoginChainData()
    • pickupEntity

      public boolean pickupEntity(Entity entity, boolean near)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Entity
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Entity
    • isBreakingBlock

      public boolean isBreakingBlock()
    • showXboxProfile

      public void showXboxProfile(String xuid)
      Show a window of a XBOX account's profile
      Parameters:
      xuid - XUID
    • startFishing

      public void startFishing(Item fishingRod)
      Start fishing
      Parameters:
      fishingRod - fishing rod item
    • stopFishing

      public void stopFishing(boolean click)
      Stop fishing
      Parameters:
      click - clicked or forced
    • doesTriggerPressurePlate

      public boolean doesTriggerPressurePlate()
      Description copied from class: Entity
      Whether the entity can active pressure plates. Used for EntityBats only.
      Overrides:
      doesTriggerPressurePlate in class Entity
      Returns:
      triggers pressure plate
    • onBlock

      @PowerNukkitOnly protected void onBlock(Entity entity, boolean animate)
      Overrides:
      onBlock in class EntityHuman
    • getNoShieldTicks

      @PowerNukkitOnly @Since("1.4.0.0-PN") public int getNoShieldTicks()
    • setNoShieldTicks

      @PowerNukkitOnly @Since("1.4.0.0-PN") public void setNoShieldTicks(int noShieldTicks)
    • toString

      public String toString()
      Overrides:
      toString in class Location
    • giveItem

      @PowerNukkitOnly @Since("1.4.0.0-PN") public void giveItem(Item... items)
      Adds the items to the main player inventory and drops on the floor any excess.
      Parameters:
      items - The items to give to the player.
    • getTimeSinceRest

      @Since("1.4.0.0-PN") public int getTimeSinceRest()
    • setTimeSinceRest

      @Since("1.4.0.0-PN") public void setTimeSinceRest(int timeSinceRest)
    • sendPopupJukebox

      @PowerNukkitOnly @Since("1.4.0.0-PN") public void sendPopupJukebox(String message)
    • sendSystem

      @PowerNukkitOnly @Since("1.4.0.0-PN") public void sendSystem(String message)
    • sendWhisper

      @PowerNukkitOnly @Since("1.4.0.0-PN") public void sendWhisper(String message)
    • sendWhisper

      @PowerNukkitOnly @Since("1.4.0.0-PN") public void sendWhisper(String source, String message)
    • sendAnnouncement

      @PowerNukkitOnly @Since("1.4.0.0-PN") public void sendAnnouncement(String message)
    • sendAnnouncement

      @PowerNukkitOnly @Since("1.4.0.0-PN") public void sendAnnouncement(String source, String message)
    • completeUsingItem

      @PowerNukkitOnly @Since("1.5.1.0-PN") public void completeUsingItem(int itemId, int action)
    • isShowingCredits

      @PowerNukkitOnly @Since("1.4.0.0-PN") public boolean isShowingCredits()
    • setShowingCredits

      @PowerNukkitOnly @Since("1.4.0.0-PN") public void setShowingCredits(boolean showingCredits)
    • showCredits

      @PowerNukkitOnly @Since("1.4.0.0-PN") public void showCredits()
    • hasSeenCredits

      @PowerNukkitOnly @Since("1.4.0.0-PN") public boolean hasSeenCredits()
    • setHasSeenCredits

      @PowerNukkitOnly @Since("1.4.0.0-PN") public void setHasSeenCredits(boolean hasSeenCredits)
    • dataPacketImmediately

      @PowerNukkitOnly @Since("1.4.0.0-PN") public boolean dataPacketImmediately(DataPacket packet)
    • dataResourcePacket

      @PowerNukkitOnly @Since("1.5.2.0-PN") public boolean dataResourcePacket(DataPacket packet)
    • sendScoreboard

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") public void sendScoreboard(Scoreboard scoreboard, DisplaySlot slot)
    • clearScoreboardSlot

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") public void clearScoreboardSlot(DisplaySlot slot)
    • shakeCamera

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") public void shakeCamera(float intensity, float duration, CameraShakePacket.CameraShakeType shakeType, CameraShakePacket.CameraShakeAction shakeAction)
    • sendToast

      public void sendToast(String title, String content)