Package cn.nukkit

Class Player

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

游戏玩家对象,代表操控的角色

Game player object, representing the controlled character

Author:
MagicDroidX & Box (Nukkit Project)
  • Field Details

    • EMPTY_ARRAY

      @PowerNukkitOnly @Since("1.4.0.0-PN") public static final Player[] EMPTY_ARRAY
      一个承载玩家的空数组静态常量

      A empty array of static constants that host the player

    • 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
      村民交易window id

      Villager trading window id

      See Also:
    • DEFAULT_SPEED

      public static final float DEFAULT_SPEED
      See Also:
    • DEFAULT_FLY_SPEED

      public static final float DEFAULT_FLY_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

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

      public final HashSet<String> achievements
    • usedChunks

      public final Map<Long,Boolean> usedChunks
    • 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
    • speed

      public Vector3 speed
      每tick 当前位置与移动目标位置向量之差

      The difference between the current position and the moving target position vector per tick

    • craftingType

      public int craftingType
    • creationTime

      public long creationTime
    • breakingBlock

      public Block breakingBlock
      正在挖掘的方块

      block being dig

    • breakingBlockFace

      @Since("1.19.60-r1") @PowerNukkitXOnly public BlockFace breakingBlockFace
      正在挖掘的方向

      direction of dig

    • pickedXPOrb

      public int pickedXPOrb
    • fishing

      public EntityFishingHook fishing
    • lastSkinChange

      public long lastSkinChange
    • breakingBlockTime

      @Since("1.19.63-r1") @PowerNukkitXOnly protected long breakingBlockTime
    • blockBreakProgress

      @Since("1.19.63-r1") @PowerNukkitXOnly protected double blockBreakProgress
    • interfaz

      protected final SourceInterface interfaz
    • networkSession

      @Since("1.19.30-r1") @PowerNukkitXOnly protected final NetworkPlayerSession networkSession
    • 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
    • rawSocketAddress

      protected final InetSocketAddress rawSocketAddress
    • loadQueue

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

      protected final Map<UUID,Player> hiddenPlayers
    • chunksPerTick

      protected final int chunksPerTick
    • spawnThreshold

      protected final int spawnThreshold
    • windowCnt

      protected int windowCnt
    • closingWindowId

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

      protected int messageCounter
    • 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
    • randomClientId

      protected long randomClientId
    • forceMovement

      @Deprecated @DeprecationDetails(since="1.19.60-r1", reason="Useless, use teleport directly") protected Vector3 forceMovement
      Deprecated.
    • teleportPosition

      @Deprecated @DeprecationDetails(since="1.19.60-r1", reason="Useless, use teleport directly") protected Vector3 teleportPosition
      Deprecated.
    • connected

      protected boolean connected
    • socketAddress

      protected InetSocketAddress socketAddress
    • removeFormat

      protected boolean removeFormat
      是否移除改玩家聊天中的颜色字符如 §c §1

      Whether to remove the color character in the chat of the changed player as §c §1

    • username

      protected String username
    • iusername

      protected String iusername
    • displayName

      protected String displayName
    • RESOURCE_PACK_CHUNK_SIZE

      protected static final int RESOURCE_PACK_CHUNK_SIZE
      See Also:
    • startAction

      protected int startAction
      这个值代表玩家是否正在使用物品(长按右键),-1时玩家未使用物品,当玩家使用物品时该值为getTick()的值.

      This value represents whether the player is using the item or not (long right click), -1 means the player is not using the item, when the player is using the item this value is the value of getTick().

    • sleeping

      protected Vector3 sleeping
    • clientID

      protected Long clientID
    • chunkLoadCount

      protected int chunkLoadCount
    • nextChunkOrderRun

      protected int nextChunkOrderRun
    • newPosition

      protected Vector3 newPosition
    • chunkRadius

      protected int chunkRadius
    • viewDistance

      protected int viewDistance
    • spawnPosition

      protected Position spawnPosition
    • spawnBlockPosition

      @PowerNukkitOnly @Since("1.4.0.0-PN") @PowerNukkitXDifference(info="change as Position") protected Position spawnBlockPosition
    • inAirTicks

      protected int inAirTicks
      代表玩家悬浮空中所经过的tick数.

      Represents the number of ticks the player has passed through the air.

    • startAirTicks

      protected int startAirTicks
    • adventureSettings

      protected AdventureSettings adventureSettings
    • checkMovement

      protected boolean checkMovement
    • foodData

      protected PlayerFood foodData
    • enableClientCommand

      protected boolean enableClientCommand
    • lastEnderPearl

      protected int lastEnderPearl
      返回上次投掷末影珍珠时的getTick(),这个值用于控制末影珍珠的冷却时间.

      Returns the getTick() from the last time the pearl was cast, which is used to control the cooldown time of the pearl.

    • lastChorusFruitTeleport

      protected int lastChorusFruitTeleport
      返回上次吃紫颂果时的getTick(),这个值用于控制吃紫颂果的冷却时间.

      Returns the getTick() of the last time you ate a chorus fruit, which is used to control the cooldown time for eating chorus fruit.

    • 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.github.benmanes.caffeine.cache.Cache<String,FormWindowDialog> dialogWindows
      我们使用google的cache来存储NPC对话框发送信息 原因是发送过去的对话框客户端有几率不响应,在特定情况下我们无法清除这些对话框,这会导致内存泄漏 5分钟后未响应的对话框会被清除

      We use Google's cache to store NPC dialogs to send messages The reason is that there is a chance that the client will not respond to the dialogs sent, and in certain cases we cannot clear these dialogs, which can lead to memory leaks Unresponsive dialogs will be cleared after 5 minutes

    • dummyBossBars

      protected Map<Long,DummyBossBar> dummyBossBars
    • shouldLogin

      protected boolean shouldLogin
    • lastRightClickTime

      protected double lastRightClickTime
    • lastRightClickPos

      protected Vector3 lastRightClickPos
    • lastInAirTick

      protected int lastInAirTick
    • showingCredits

      @PowerNukkitXDifference(since="1.19.80-r3", info="change to protected") @PowerNukkitOnly @Since("1.4.0.0-PN") protected boolean showingCredits
    • NO_SHIELD_DELAY

      @PowerNukkitXDifference(since="1.19.80-r3", info="change to protected") protected static final int NO_SHIELD_DELAY
      See Also:
    • inventoryOpen

      @PowerNukkitXDifference(since="1.19.80-r3", info="change to protected") protected boolean inventoryOpen
    • lastBlockAction

      @PowerNukkitXDifference(since="1.19.80-r3", info="change to protected") protected PlayerBlockActionData lastBlockAction
    • preLoginEventTask

      protected AsyncTask preLoginEventTask
    • verified

      protected boolean verified
    • loginChainData

      protected LoginChainData loginChainData
    • lastPlayerdLevelUpSoundTime

      @PowerNukkitOnly @Since("1.4.0.0-PN") protected int lastPlayerdLevelUpSoundTime
      玩家升级时播放音乐的时间

      Time to play sound when player upgrades

    • lastAttackEntity

      @PowerNukkitXOnly @Since("1.19.30-r1") protected Entity lastAttackEntity
      玩家最后攻击的实体.

      The entity that the player attacked last.

    • fogStack

      @PowerNukkitXOnly @Since("1.19.50-r3") protected List<PlayerFogPacket.Fog> fogStack
      玩家迷雾设置

      Player Fog Settings

    • lastBeAttackEntity

      @PowerNukkitXOnly @Since("1.19.30-r1") protected Entity lastBeAttackEntity
      最后攻击玩家的实体.

      The entity that the player is attacked last.

    • flySneaking

      protected Boolean flySneaking
  • Constructor Details

  • Method Details

    • onBlockBreakContinue

      @PowerNukkitXDifference(since="1.19.60-r1",info="Auto-break custom blocks if client doesn\'t send the break data-pack.") @PowerNukkitXDifference(since="1.19.80-r3",info="change to protected") protected void onBlockBreakContinue(Vector3 pos, BlockFace face)
    • onBlockBreakStart

      @PowerNukkitXDifference(since="1.19.80-r3", info="change to protected") protected void onBlockBreakStart(Vector3 pos, BlockFace face)
    • onBlockBreakAbort

      @PowerNukkitXDifference(since="1.19.80-r3", info="change to protected") protected void onBlockBreakAbort(Vector3 pos, BlockFace face)
    • onBlockBreakComplete

      @PowerNukkitXDifference(since="1.19.80-r3", info="change to protected") protected void onBlockBreakComplete(BlockVector3 blockPos, BlockFace face)
    • sendNextChunk

      protected void sendNextChunk()
    • initEntity

      protected void initEntity()
      Description copied from class: Entity
      实体初始化顺序,先初始化Entity类字段->Entity构造函数->进入init方法->调用initEntity方法->子类字段初始化->子类构造函数

      用于初始化实体的NBT和实体字段的方法

      Entity initialization order, first initialize the Entity class field->Entity constructor->Enter the init method->Call the init Entity method-> subclass field initialization-> subclass constructor

      The method used to initialize the NBT and entity fields of the entity

      Overrides:
      initEntity in class EntityHuman
    • doFirstSpawn

      protected void doFirstSpawn()
      完成completeLoginSequence后执行
    • orderChunks

      protected boolean orderChunks()
    • checkGroundState

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

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

      protected void checkNearEntities()
    • handleMovement

      protected void handleMovement(Location clientPos)
    • offerMovementTask

      protected void offerMovementTask(Location newPosition)
    • processMovement

      @Deprecated @DeprecationDetails(since="1.19.60-r1", reason="use handleMovement") protected void processMovement(int tickDiff)
      Deprecated.
    • handleLogicInMove

      protected void handleLogicInMove(boolean invalidMotion, double distance)
    • resetClientMovement

      protected void resetClientMovement()
    • revertClientMotion

      protected void revertClientMotion(Location originalPos)
    • processLogin

      protected void processLogin()
      处理LOGIN_PACKET中执行
    • completeLoginSequence

      protected void completeLoginSequence()
      异步登录任务成功完成后执行
    • onPlayerLocallyInitialized

      @PowerNukkitXOnly @Since("1.19.50-r3") protected void onPlayerLocallyInitialized()
      玩家客户端初始化完成后调用
    • isValidRespawnBlock

      @PowerNukkitOnly @Since("1.4.0.0-PN") protected boolean isValidRespawnBlock(Block block)
      判断重生锚是否有效如果重生锚有效则在重生锚上重生或者在床上重生 如果玩家以上2种都没有则在服务器重生点重生

      Determine if the respawn anchor is valid if the respawn anchor is valid then the anchor is respawned at the respawn anchor or reborn in bed If the player has none of the above 2 then respawn at the server respawn point

      Parameters:
      block -
      Returns:
    • respawn

      protected void respawn()
    • checkChunks

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

      protected void sendPlayStatus(int status)
    • sendPlayStatus

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

      protected void forceSendEmptyChunks()
    • removeWindow

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

      protected void addDefaultWindows()
    • getBaseOffset

      protected float getBaseOffset()
      Description copied from class: EntityHuman
      偏移客户端传输玩家位置的y轴误差
      Overrides:
      getBaseOffset in class EntityHuman
      Returns:
      the base offset
    • onBlock

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

      public double getStepHeight()
      Overrides:
      getStepHeight in class Entity
    • getLastAttackEntity

      @PowerNukkitXOnly @Since("1.19.30-r1") public Entity getLastAttackEntity()
      Returns:
      lastAttackEntity
    • getLastBeAttackEntity

      @PowerNukkitXOnly @Since("1.19.30-r1") public Entity getLastBeAttackEntity()
      Returns:
      lastBeAttackEntity
    • getSoulSpeedMultiplier

      public float getSoulSpeedMultiplier()
      返回灵魂急行带来的速度增加倍速

      Return to the speed increase multiplier brought by SOUL_SPEED Enchantment

    • getStartActionTick

      public int getStartActionTick()
      返回startAction的值

      Returns the value of startAction

      Returns:
      int
    • startAction

      public void startAction()
      设置startAction值为getTick()

      Set the startAction value to getTick()

    • stopAction

      public void stopAction()
      设置startAction值为-1

      Set the startAction value to -1

    • getLastEnderPearlThrowingTick

      public int getLastEnderPearlThrowingTick()
      返回lastEnderPearl的值

      Returns the value of lastEnderPearl

      Returns:
      int
    • onThrowEnderPearl

      public void onThrowEnderPearl()
    • getLastChorusFruitTeleport

      public int getLastChorusFruitTeleport()
      返回lastChorusFruitTeleport的值

      Returns the value of lastChorusFruitTeleport

      Returns:
      int
    • getLastInAirTick

      @PowerNukkitXOnly @Since("1.19.63-r1") public int getLastInAirTick()
      返回lastInAirTick的值,代表玩家上次在空中的server tick

      Returns the value of lastInAirTick,represent the last server tick the player was in the air

      Returns:
      int
    • onChorusFruitTeleport

      public void onChorusFruitTeleport()
    • getViewingEnderChest

      public BlockEnderChest getViewingEnderChest()
      返回viewingEnderChest的值,只在玩家打开末影箱时有效.

      Returns the value of viewingEnderChest, which is only valid when the player opens the Ender Chest.

    • setViewingEnderChest

      public void setViewingEnderChest(BlockEnderChest chest)
      设置viewingEnderChest值为chest

      Set the viewingEnderChest value to chest

      Parameters:
      chest - BlockEnderChest
    • getLeaveMessage

      public TranslationContainer getLeaveMessage()
      获取玩家离开的消息
      Returns:
      TranslationContainer
    • 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()
      获得玩家权限设置.

      Get player permission settings.

    • setAdventureSettings

      public void setAdventureSettings(AdventureSettings adventureSettings)
      用于设置玩家权限,对应游戏中的玩家权限设置.

      Used to set player permissions, corresponding to the game's player permissions settings.

      Parameters:
      adventureSettings - 玩家权限设置
      player permissions settings
    • resetInAirTicks

      public void resetInAirTicks()
      设置inAirTicks为0

      Set inAirTicks to 0

    • setAllowFlight

      public void setAllowFlight(boolean value)
    • getAllowFlight

      public boolean getAllowFlight()
    • setAllowModifyWorld

      public void setAllowModifyWorld(boolean value)
      设置允许修改世界(未知原因设置完成之后,玩家不允许挖掘方块,但是可以放置方块)

      Set allow to modify the world (after the unknown reason setting is completed, the player is not allowed to dig the blocks, but can place them)

      Parameters:
      value - 是否允许修改世界
      Whether to allow modification of the world
    • setAllowInteract

      public void setAllowInteract(boolean value)
    • setAllowInteract

      public void setAllowInteract(boolean value, boolean containers)
      设置允许交互世界/容器
      Parameters:
      value - 是否允许交互世界
      containers - 是否允许交互容器
    • setAutoJump

      public void setAutoJump(boolean value)
    • hasAutoJump

      public boolean hasAutoJump()
    • spawnTo

      public void spawnTo(Player player)
      Description copied from class: Entity
      将这个实体在客户端生成,让该玩家可以看到它

      Spawn this entity on the client side so that the player can see it

      Overrides:
      spawnTo in class EntityHuman
      Parameters:
      player - the player
    • getServer

      public Server getServer()
      Description copied from interface: CommandSender
      返回命令发送者所在的服务器.

      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()
      Returns:
      boolean
    • setRemoveFormat

      public void setRemoveFormat(boolean remove)
      设置removeFormat为指定值
      Parameters:
      remove - 是否清楚格式化字符
      Whether remove the formatting character
    • setRemoveFormat

      public void setRemoveFormat()
    • canSee

      public boolean canSee(Player player)
      Parameters:
      player - 玩家
      Returns:
      是否可以看到该玩家
      Whether the player can be seen
    • hidePlayer

      public void hidePlayer(Player player)
      从当前玩家实例的视角中隐藏指定玩家player

      Hide the specified player from the view of the current player instance

      Parameters:
      player - 要隐藏的玩家
      Players who want to hide
    • showPlayer

      public void showPlayer(Player player)
      从当前玩家实例的视角中显示指定玩家player

      Show the specified player from the view of the current player instance

      Parameters:
      player - 要显示的玩家
      Players who want to show
    • canCollideWith

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

      public boolean canCollide()
      Overrides:
      canCollide 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
    • isPlayer

      public boolean isPlayer()
      Specified by:
      isPlayer in interface CommandSender
      Returns:
      发送者是否为玩家
      whether the sender is an player
    • asPlayer

      public Player asPlayer()
      Description copied from interface: CommandSender
      如果发送者是一个玩家,返回执行该命令的玩家.

      return the player who execute the command if the sender is a player.

      Specified by:
      asPlayer in interface CommandSender
      Returns:
      玩家对象
      Player instance
    • isEntity

      public boolean isEntity()
      Description copied from interface: CommandSender
      请使用这个方法来检查发送者是否是一个实体,而不是使用代码"xxx instanceof Entity".
      因为发送者可能不是"Entity"的一个实例,但实际上它是以一个实体的身份执行命令(例如:"ExecutorCommandSender")

      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")

      Specified by:
      isEntity in interface CommandSender
      Returns:
      发送者是否为实体
      whether the sender is an entity
    • asEntity

      public Entity asEntity()
      Description copied from interface: CommandSender
      如果发送者是一个实体,返回执行该命令的实体.

      return the entity who execute the command if the sender is a entity.

      Specified by:
      asEntity in interface CommandSender
      Returns:
      实体对象
      Entity instance
    • removeAchievement

      public void removeAchievement(String achievementId)
    • hasAchievement

      public boolean hasAchievement(String achievementId)
    • isConnected

      public boolean isConnected()
    • getDisplayName

      public String getDisplayName()
      得到该玩家的显示名称

      Get the display name of the player

      Returns:
      displayName
    • setDisplayName

      public void setDisplayName(String displayName)
      只是改变玩家聊天时和在服务器玩家列表中的显示名(不影响命令的玩家参数名,也不影响玩家头顶显示名称)

      Just change the name displayed during player chat and in the server player list (Does not affect the player parameter name of the command, nor does it affect the player header display name)

      Parameters:
      displayName - 显示名称
    • setSkin

      public void setSkin(Skin skin)
      Specified by:
      setSkin in interface IHuman
      Overrides:
      setSkin in class EntityHuman
    • getRawAddress

      public String getRawAddress()
      得到原始地址
      Returns:
      String
    • getRawPort

      public int getRawPort()
      得到原始端口
      Returns:
      int
    • getRawSocketAddress

      public InetSocketAddress getRawSocketAddress()
      得到原始套接字地址
      Returns:
      InetSocketAddress
    • getAddress

      public String getAddress()
      得到地址,如果开启waterdogpe兼容,该地址是被修改为兼容waterdogpe型的,反之则与rawSocketAddress 一样

      If waterdogpe compatibility is enabled, the address is modified to be waterdogpe compatible, otherwise it is the same as rawSocketAddress

      Returns:
      String
    • getPort

      public int getPort()
      See Also:
    • getSocketAddress

      public InetSocketAddress getSocketAddress()
      得到套接字地址,如果开启waterdogpe兼容,该套接字地址是被修改为兼容waterdogpe型的,反正则与rawSocketAddress 一样

      If waterdogpe compatibility is enabled, the address is modified to be waterdogpe compatible, otherwise it is the same as rawSocketAddress

      Returns:
      InetSocketAddress
    • getNextPosition

      public Position getNextPosition()
      获得下一个tick客户端玩家将要移动的位置

      Get the position where the next tick client player will move

      Returns:
      the next position
    • isSleeping

      public boolean isSleeping()
      玩家是否在睡觉

      Whether the player is sleeping

      Returns:
      boolean
    • getInAirTicks

      public int getInAirTicks()
      Returns:
      inAirTicks
    • isUsingItem

      public boolean isUsingItem()
      返回玩家当前是否正在使用某项物品(右击并按住)。

      Returns whether the player is currently using an item (right-click and hold).

      Returns:
      startAction
    • setUsingItem

      public void setUsingItem(boolean value)
      设置玩家当前是否正在使用某项物品 startAction(右击并按住)。

      Set whether the player is currently using an item startAction (right-click and hold).

      Parameters:
      value - 玩家当前是否正在使用某项物品
      whether the player is currently using an item.
    • getButtonText

      public String getButtonText()
      获得移动设备玩家面对载具时出现的交互按钮的语言硬编码。

      Get the language hardcoded for the interaction buttons that appear when mobile device players face the carrier.

    • setButtonText

      public void setButtonText(String text)
      设置移动设备玩家面对载具时出现的交互按钮的语言硬编码。

      Set the language hardcoded for the interaction buttons that appear when mobile device players face the carrier.

    • unloadChunk

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

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

      public boolean isInOverWorld()
      Returns:
      玩家是否在主世界(维度为0)
      Is the player in the world(Dimension equal 0)
    • getSpawn

      public Position getSpawn()
      获取该玩家的可用重生点,

      Get the player's Spawn point

      Returns:
      Position
    • getSpawnBlock

      @PowerNukkitOnly @Since("1.4.0.0-PN") @Deprecated @DeprecationDetails(since="1.19.60-r1", reason="same #getSpawn") public Position getSpawnBlock()
      Deprecated.
      保存玩家重生位置的方块的位置。当未知时可能为空。

      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.
    • 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)
      设置玩家的出生点/复活点。

      Set the player's birth point.

      Parameters:
      pos - 出生点位置
    • 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)
    • updateTrackingPositions

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

      @PowerNukkitOnly @Since("1.4.0.0-PN") public void updateTrackingPositions(boolean delayed)
    • 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.
    • forceDataPacket

      @Since("1.19.30-r1") @PowerNukkitXOnly public void forceDataPacket(DataPacket packet, Runnable callback)
    • getPing

      public int getPing()
      得到该玩家的网络延迟。

      Get the network latency of the player.

      Returns:
      int
    • sleepOn

      public boolean sleepOn(Vector3 pos)
    • stopSleep

      public void stopSleep()
    • awardAchievement

      public boolean awardAchievement(String achievementId)
    • getGamemode

      public int getGamemode()
      得到gamemode。

      Get gamemode.

      Returns:
      int
    • setGamemode

      public boolean setGamemode(int gamemode)
    • setGamemode

      public boolean setGamemode(int gamemode, boolean serverSide)
      AdventureSettings=null
      See Also:
    • setGamemode

      public boolean setGamemode(int gamemode, boolean serverSide, AdventureSettings newSettings)
    • setGamemode

      public boolean setGamemode(int gamemode, boolean serverSide, AdventureSettings newSettings, boolean forceUpdate)
      设置gamemode
      Parameters:
      gamemode - 要设置的玩家游戏模式
      serverSide - 是否只更新服务端侧玩家游戏模式。若为true,则不会向客户端发送游戏模式更新包
      newSettings - 新的AdventureSettings
      forceUpdate - 是否强制更新。若为true,将取消对形参'gamemode'的检查
      Returns:
      gamemode
    • sendSettings

      public void sendSettings()
    • isSurvival

      public boolean isSurvival()
      该玩家是否为生存模式。

      Whether the player is in survival mode?

      Returns:
      boolean
    • isCreative

      public boolean isCreative()
      该玩家是否为创造模式。

      Whether the player is in creative mode?

      Returns:
      boolean
    • isSpectator

      public boolean isSpectator()
      该玩家是否为观察者模式。

      Whether the player is in spectator mode?

      Returns:
      boolean
    • isAdventure

      public boolean isAdventure()
      该玩家是否为冒险模式。

      Whether the player is in adventure mode?

      Returns:
      boolean
    • getDrops

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

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

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

      public void addMovement(double x, double y, double z, double yaw, double pitch, double headYaw)
      Description copied from class: Entity
      增加运动 (仅发送数据包,如果需要请使用Entity.setMotion(cn.nukkit.math.Vector3))

      Add motion (just sending packet will not make the entity actually move, use Entity.setMotion(cn.nukkit.math.Vector3) if needed)

      Overrides:
      addMovement in class EntityHuman
      Parameters:
      x - x
      y - y
      z - z
      yaw - 左右旋转
      pitch - 上下旋转
      headYaw - headYaw
    • setMotion

      public boolean setMotion(Vector3 motion)
      每次调用此方法都会向客户端发送motion包。若多次调用,motion将在客户端叠加

      Overrides:
      setMotion in class Entity
      Parameters:
      motion - 运动向量
      a motion vector
      Returns:
      调用是否成功
    • sendAttributes

      public void sendAttributes()
    • sendFogStack

      @PowerNukkitXOnly @Since("1.19.50-r3") public void sendFogStack()
      将迷雾设定发送到客户端
    • sendCameraPresets

      @PowerNukkitXOnly @Since("1.20.0-r2") public void sendCameraPresets()
    • onUpdate

      @PowerNukkitXDifference(info="Calculate fall distance when wearing elytra", since="1.19.60-r1") public boolean onUpdate(int currentTick)
      Overrides:
      onUpdate in class Entity
    • entityBaseTick

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

      public void checkInteractNearby()
      检查附近可交互的实体(插件一般不使用)

      Check for nearby interactable entities (not generally used by plugins)

    • 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 如果没有找到实体,则为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)
    • handleDataPacket

      @PowerNukkitXDifference(since="1.19.70-r1", info="Use new packet id system.") 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()
      reason=empty string
      See Also:
    • kick

      public boolean kick(String reason, boolean isAdmin)
      See Also:
    • kick

      public boolean kick(String reason)
      See Also:
    • kick

      public boolean kick(PlayerKickEvent.Reason reason)
      See Also:
    • kick

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

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

      public boolean kick(PlayerKickEvent.Reason reason, String reasonString, boolean isAdmin)
      踢出该玩家

      Kick out the player

      Parameters:
      reason - 原因枚举
      Cause Enumeration
      reasonString - 原因字符串
      Reason String
      isAdmin - 是否来自管理员踢出
      Whether from the administrator kicked out
      Returns:
      boolean
    • setViewDistance

      public void setViewDistance(int distance)
      设置玩家的可视距离(范围 0--Server.getViewDistance())

      Set the player's viewing distance (range 0--Server.getViewDistance())

      Parameters:
      distance - 可视距离
    • getViewDistance

      public int getViewDistance()
      得到玩家的可视距离

      Get the player's viewing distance

      Returns:
      int
    • 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.
    • sendCommandOutput

      @PowerNukkitXOnly @Since("1.19.60-r1") public void sendCommandOutput(CommandOutputContainer container)
      Description copied from interface: CommandSender
      Send command output.
      Specified by:
      sendCommandOutput in interface CommandSender
      Parameters:
      container - the container
    • sendRawTextMessage

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") public void sendRawTextMessage(RawText text)
      在玩家聊天栏发送一个JSON文本

      Send a JSON text in the player chat bar

      Parameters:
      text - JSON文本
      Json text
    • sendTranslation

      public void sendTranslation(String message)
      See Also:
    • sendTranslation

      public void sendTranslation(String message, String[] parameters)
      在玩家聊天栏发送一个多语言翻译文本,示例:
      message="Test Message {%0} {%1}" parameters=["Hello","World"]
      实际消息内容"Test Message Hello World"

      Send a multilingual translated text in the player chat bar, example:
      message="Test Message {%0} {%1}" parameters=["Hello", "World"]
      actual message content "Test Message Hello World"

      Parameters:
      message - 消息
      parameters - 参数
    • sendChat

      public void sendChat(String message)
      See Also:
    • sendChat

      public void sendChat(String source, String message)
      在玩家聊天栏发送一个文本

      Send a text in the player chat bar

      Parameters:
      message - 消息
    • sendPopup

      public void sendPopup(String message)
      See Also:
    • sendPopup

      public void sendPopup(String message, String subtitle)
      在玩家物品栏上方发送一个弹出式的文本

      Send a pop-up text above the player's item bar

      Parameters:
      message - 消息
    • sendTip

      public void sendTip(String message)
      在玩家物品栏上方发送一个提示文本

      Send a tip text above the player's item bar

      Parameters:
      message - 消息
    • clearTitle

      public void clearTitle()
      清除掉玩家身上正在显示的标题信息。

      Clears away the title info being displayed on the player.

    • resetTitleSettings

      public void resetTitleSettings()
      为下一个显示的标题重新设置标题动画时间和副标题。

      Resets both title animation times and subtitle for the next shown title.

    • setSubtitle

      public void setSubtitle(String subtitle)
      设置副标题,在主标题下方显示。

      Set subtitle to be displayed below the main title.

      Parameters:
      subtitle - 副标题
    • setRawTextSubTitle

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") public void setRawTextSubTitle(RawText text)
      设置一个JSON文本副标题。

      Set a JSON text subtitle.

      Parameters:
      text - JSON文本
      JSON text
    • setTitleAnimationTimes

      public void setTitleAnimationTimes(int fadein, int duration, int fadeout)
      设置标题动画时间

      Set title animation time

      Parameters:
      fadein - 淡入时间
      duration - 持续时间
      fadeout - 淡出时间
    • setRawTextTitle

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") public void setRawTextTitle(RawText text)
      设置一个JSON文本标题。

      Set a JSON text title.

      Parameters:
      text - JSON文本
      JSON text
    • sendTitle

      public void sendTitle(String title)
      subtitle=null,fadeIn=20,stay=20,fadeOut=5
      See Also:
    • sendTitle

      public void sendTitle(String title, String subtitle)
      fadeIn=20,stay=20,fadeOut=5
      See Also:
    • sendTitle

      public void sendTitle(String title, String subtitle, int fadeIn, int stay, int fadeOut)
      在玩家视角正中央发送一个标题文本。

      Send a title text in the center of the player's view.

      Parameters:
      title - 标题
      subtitle - 副标题
      fadeIn - 淡入时间
      fadeIn time(tick)
      stay - 持续时间
      stay time
      fadeOut - 淡出时间
      fadeOut time
    • sendActionBar

      public void sendActionBar(String title)
      fadein=1,duration=0,fadeout=1
      See Also:
    • sendActionBar

      public void sendActionBar(String title, int fadein, int duration, int fadeout)
      在玩家物品栏上方发送一个ActionBar消息。

      Send a ActionBar text above the player's item bar.

      Parameters:
      title - 消息
      fadein - 淡入时间
      duration - 持续时间
      fadeout - 淡出时间
    • setRawTextActionBar

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") public void setRawTextActionBar(RawText text)
      fadein=1,duration=0,fadeout=1
      See Also:
    • setRawTextActionBar

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") public void setRawTextActionBar(RawText text, int fadein, int duration, int fadeout)
      设置一个JSON ActionBar消息。

      Set a JSON ActionBar text.

      Parameters:
      text - JSON文本
      JSON text
      fadein - 淡入时间
      duration - 持续时间
      fadeout - 淡出时间
    • close

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

      public void close(String message)
      notify=true
      See Also:
    • close

      public void close(String message, String reason)
      notify=true
      See Also:
    • close

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

      public void close(TextContainer message)
      reason="generic",notify=true
      See Also:
    • close

      public void close(TextContainer message, String reason)
      notify=true
      See Also:
    • close

      public void close(TextContainer message, String reason, boolean notify)
      关闭该玩家的连接及其一切活动,和kick()差不多效果,区别在于kick()是基于close实现的。

      Closing the player's connection and all its activities is almost as function as kick(), the difference is that kick() is implemented based on close.

      Parameters:
      message - PlayerQuitEvent事件消息
      PlayerQuitEvent message
      reason - 登出原因
      Reason for logout
      notify - 是否显示登出画面通知
      Whether to display the logout screen notification
    • 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

      @NotNull 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:
    • getLanguageCode

      @PowerNukkitXOnly @Since("1.19.60-r1") public LangCode getLanguageCode()
    • kill

      public void kill()
      Overrides:
      kill in class EntityLiving
    • 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()
      得到该玩家的经验值(并不会显示玩家从的经验值总数,而仅仅显示当前等级所在的经验值,即经验条)。

      Get the experience value of the player (it does not show the total experience value of the player from, but only the experience value where the current level is, i.e. the experience bar).

      Returns:
      int
    • getExperienceLevel

      public int getExperienceLevel()
      得到该玩家的等级。

      Get the level of the player.

      Returns:
      int
    • addExperience

      public void addExperience(int add)
      playLevelUpSound=false
      See Also:
    • addExperience

      @PowerNukkitOnly public void addExperience(int add, boolean playLevelUpSound)
      增加该玩家的经验值

      Increase the experience value of the player

      Parameters:
      add - 经验值的数量
      playLevelUpSound - 有无升级声音
    • calculateRequireExperience

      public static int calculateRequireExperience(int level)
      计算玩家到达某等级所需要的经验值

      Calculates the amount of experience a player needs to reach a certain level

      Parameters:
      level - 等级
      Returns:
      int
    • setExperience

      public void setExperience(int exp)
      level = this.getExperienceLevel(),playLevelUpSound=false
      See Also:
    • setExperience

      public void setExperience(int exp, int level)
      playLevelUpSound=false
      See Also:
    • setExperience

      @PowerNukkitOnly public void setExperience(int exp, int level, boolean playLevelUpSound)
      设置该玩家的经验值和等级

      set the experience value and level of the player

      Parameters:
      playLevelUpSound - 有无升级声音
      exp - 经验值
      level - 等级
    • sendExperience

      public void sendExperience()
      See Also:
    • sendExperience

      public void sendExperience(int exp)
      setExperience的实现部分,用来设置当前等级所对应的经验值,即经验条

      The implementation of setExperience is used to set the experience value corresponding to the current level, i.e. the experience bar

      Parameters:
      exp - 经验值
    • sendExperienceLevel

      public void sendExperienceLevel()
      See Also:
    • sendExperienceLevel

      public void sendExperienceLevel(int level)
      setExperience的实现部分,用来设置当前等级

      The implementation of setExperience is used to set the level

      Parameters:
      level - 等级
    • setAttribute

      public void setAttribute(Attribute attribute)
      以指定Attribute发送UpdateAttributesPacket数据包到该玩家。

      Send UpdateAttributesPacket packets to this player with the specified Attribute.

      Parameters:
      attribute - the attribute
    • setMovementSpeed

      public void setMovementSpeed(float speed)
      send=true
      Overrides:
      setMovementSpeed in class EntityLiving
      Parameters:
      speed - 速度大小
      Speed value
      See Also:
    • setMovementSpeed

      public void setMovementSpeed(float speed, boolean send)
      设置该玩家的移动速度

      Set the movement speed of this player.

      Parameters:
      speed - 速度大小,注意默认移动速度为DEFAULT_SPEED
      Speed value, note that the default movement speed is DEFAULT_SPEED
      send - 是否发送数据包UpdateAttributesPacket到客户端
      Whether to send UpdateAttributesPacket to the client
    • sendMovementSpeed

      @Since("1.4.0.0-PN") public void sendMovementSpeed(float speed)
      发送Attribute.MOVEMENT_SPEED属性到客户端

      Send Attribute.MOVEMENT_SPEED Attribute to Client.

      Parameters:
      speed - 属性值
      the speed value
    • getKiller

      public Entity getKiller()
      获取击杀该玩家的实体

      Get the entity that killed this player

      Returns:
      Entity | null
    • attack

      public boolean attack(EntityDamageEvent source)
      Description copied from class: Entity
      当一个实体被攻击时(即接受一个实体伤害事件 这个事件可以是由其他实体攻击导致,也可能是自然伤害)调用.

      Called when an entity is attacked (i.e. receives an entity damage event. This event can be caused by an attack by another entity, or it can be a natural damage).

      Overrides:
      attack in class EntityHumanType
      Parameters:
      source - 记录伤害源的事件
      Record the event of the source of the attack
      Returns:
      是否攻击成功
      Whether the attack was successful
    • 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值,丢弃物品成功或该物品为空
      bool if the item was dropped or if the item was null
    • dropAndGetItem

      @Since("1.4.0.0-PN") @Nullable public EntityItem dropAndGetItem(@NotNull Item item)
      在玩家面前的地面上扔下一个物品。返回值为该掉落的物品。

      Drops an item on the ground in front of the player. Returns the dropped item.

      Parameters:
      item - 掉落的物品
      to drop
      Returns:
      如果物品被丢弃成功,则返回EntityItem;如果物品为空,则为null
      EntityItem if the item was dropped or null if the item was null
    • sendPosition

      public void sendPosition(Vector3 pos)
      See Also:
    • sendPosition

      public void sendPosition(Vector3 pos, double yaw)
      See Also:
    • sendPosition

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

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

      public void sendPosition(Vector3 pos, double yaw, double pitch, int mode, Player[] targets)
      Parameters:
      pos - the pos of MovePlayerPacket
      yaw - the yaw of MovePlayerPacket
      pitch - the pitch of MovePlayerPacket
      mode - the mode of MovePlayerPacket
      targets - 接受数据包的玩家们
      players of receive the packet
    • teleport

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

      @Deprecated @DeprecationDetails(since="1.19.60-r1", reason="same teleport") public void teleportImmediate(Location location)
      Deprecated.
    • teleportImmediate

      @Deprecated @DeprecationDetails(since="1.19.60-r1", reason="same teleport") public void teleportImmediate(Location location, PlayerTeleportEvent.TeleportCause cause)
      Deprecated.
    • showFormWindow

      public int showFormWindow(FormWindow window)
      Automatic id assignment
      See Also:
    • showFormWindow

      public int showFormWindow(FormWindow window, int id)
      向玩家显示一个新的FormWindow。 你可以通过监听PlayerFormRespondedEvent来了解FormWindow的结果。

      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)
      book=true
      See Also:
    • showDialogWindow

      public void showDialogWindow(FormWindowDialog dialog, boolean book)
      向玩家展示一个NPC对话框.

      Show dialog window to the player.

      Parameters:
      dialog - NPC对话框
      the dialog
      book - 如果为true,将会立即更新该FormWindowDialog.getSceneName()
      If true, the FormWindowDialog.getSceneName() will be updated immediately.
    • addServerSettings

      public int addServerSettings(FormWindow window)
      在游戏设置中显示一个新的设置页面。 你可以通过监听PlayerFormRespondedEvent来了解设置结果。

      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.
      创建并发送一个BossBar给玩家。

      Creates and sends a BossBar to the player

      Parameters:
      text - BossBar信息
      The BossBar message
      length - BossBar百分比
      The BossBar percentage
      Returns:
      bossBarId BossBar的ID,如果你想以后删除或更新BossBar,你应该存储它。
      bossBarId The BossBar ID, you should store it if you want to remove or update the BossBar later
    • createBossBar

      public long createBossBar(DummyBossBar dummyBossBar)
      创建并发送一个BossBar给玩家。

      Creates and sends a BossBar to the player

      Parameters:
      dummyBossBar - DummyBossBar对象(通过DummyBossBar.Builder实例化)。
      DummyBossBar Object (Instantiate it by the Class Builder)
      Returns:
      bossBarId BossBar的ID,如果你想以后删除或更新BossBar,你应该储存它。
      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)
      获取一个DummyBossBar对象

      Get a DummyBossBar object

      Parameters:
      bossBarId - 要查找的BossBar ID
      The BossBar ID
      Returns:
      DummyBossBar对象
      DummyBossBar object
      See Also:
    • getDummyBossBars

      public Map<Long,DummyBossBar> getDummyBossBars()
      获取所有DummyBossBar对象

      Get all DummyBossBar objects

      Returns:
      DummyBossBars Map
    • updateBossBar

      @Deprecated public void updateBossBar(String text, int length, long bossBarId)
      Deprecated.
      更新一个BossBar

      Updates a BossBar

      Parameters:
      text - The new BossBar message
      length - The new BossBar length
      bossBarId - The BossBar ID
    • removeBossBar

      public void removeBossBar(long bossBarId)
      移除一个BossBar

      Removes a BossBar

      Parameters:
      bossBarId - The BossBar ID
    • getWindowId

      public int getWindowId(Inventory inventory)
      获取id从指定Inventory

      Get id from the specified Inventory

      Parameters:
      inventory - the inventory
      Returns:
      the window id
    • getWindowById

      public Inventory getWindowById(int id)
      获取Inventory从指定id

      Get Inventory from the specified id

      Parameters:
      id - 窗口id
      the window id
    • addWindow

      public int addWindow(Inventory inventory)
      forceId=null isPermanent=false alwaysOpen = false
      See Also:
    • addWindow

      public int addWindow(Inventory inventory, Integer forceId)
      isPermanent=false alwaysOpen = false
      See Also:
    • addWindow

      public int addWindow(Inventory inventory, Integer forceId, boolean isPermanent)
      alwaysOpen = false
      See Also:
    • addWindow

      @Since("1.4.0.0-PN") public int addWindow(Inventory inventory, Integer forceId, boolean isPermanent, boolean alwaysOpen)
      添加一个Inventory窗口显示到该玩家
      Parameters:
      inventory - 这个库存窗口
      the inventory
      forceId - 强制指定window id,若和现有window重复将会删除它并替换,为null则自动分配
      Force the window id to be specified, if it is duplicated with an existing window, it will be deleted and replaced,if is null is automatically assigned.
      isPermanent - 如果为true将会把Inventory存放到permanentWindows
      If true it will store the Inventory in permanentWindows
      alwaysOpen - 如果为true即使玩家未spawned也会添加改玩家为指定inventory的viewer
      If true, even if the player is not spawned, it will add the player as viewer to the specified inventory.
      Returns:
      返回窗口id,可以利用id通过windowIndex重新获取该Inventory
      Return the window id, you can use the id to retrieve the Inventory via windowIndex
    • getTopWindow

      public Optional<Inventory> getTopWindow()
    • removeWindow

      public void removeWindow(Inventory inventory)
      移除该玩家身上的指定Inventory

      Remove the specified Inventory from the player

      Parameters:
      inventory - the inventory
    • sendAllInventories

      public void sendAllInventories()
      常用于刷新。

      Commonly used for refreshing.

    • getUIInventory

      public PlayerUIInventory getUIInventory()
      获取该玩家的PlayerUIInventory

      Gets ui inventory of the player.

    • getCursorInventory

      public PlayerCursorInventory getCursorInventory()
      获取该玩家的PlayerCursorInventory

      Gets cursor inventory of the player.

    • getCraftingGrid

      public CraftingGrid getCraftingGrid()
      获取该玩家的CraftingGrid

      Gets crafting grid of the player.

    • setCraftingGrid

      public void setCraftingGrid(CraftingGrid grid)
      设置该玩家的CraftingGrid

      Sets crafting grid.

      Parameters:
      grid - CraftingGrid
    • resetCraftingGridType

      public void resetCraftingGridType()
      Reset crafting grid type.
    • removeAllWindows

      public void removeAllWindows()
      permanent=false
      See Also:
    • removeAllWindows

      public void removeAllWindows(boolean permanent)
      清空windows

      Remove all windows.

      Parameters:
      permanent - 如果为false则会跳过删除permanentWindows里面对应的window
      If false, it will skip deleting the corresponding window in permanentWindows
    • getClosingWindowId

      @Since("1.4.0.0-PN") public int getClosingWindowId()
      获取上一个关闭窗口对应的id

      Get the id corresponding to the last closed window

    • 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()
      Returns:
      该玩家是否开启饮食系统
      Whether the player is on the food system
    • setFoodEnabled

      public void setFoodEnabled(boolean foodEnabled)
      设置该玩家是否开启饮食系统

      Set whether the player is on the food system

      Parameters:
      foodEnabled - 如果为false,则关闭玩家的饮食系统
      If false, turn off the player's food system
    • getFoodData

      public PlayerFood getFoodData()
      获取玩家的PlayerFood

      Get the player's PlayerFood

      Returns:
      the food data
    • switchLevel

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

      public void setCheckMovement(boolean checkMovement)
      设置是否检查该玩家移动

      Set whether to check for this player movement

      Parameters:
      checkMovement - the check movement
    • isCheckingMovement

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

      public Locale getLocale()
    • setLocale

      public void setLocale(Locale locale)
    • setSprinting

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

      public void transfer(InetSocketAddress address)
      传送该玩家到另一个服务器

      Teleport the player to another server

      Parameters:
      address - the address
    • getLoginChainData

      public LoginChainData getLoginChainData()
      获取该玩家的登录链数据

      Get the login chain data of this player

      Returns:
      the login chain data
    • 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()
      玩家是否在挖掘方块

      Whether the player is digging block

      Returns:
      the boolean
    • showXboxProfile

      public void showXboxProfile(String xuid)
      显示一个XBOX账户的资料窗口

      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
    • 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)
    • getNetworkSession

      @Since("1.19.30-r1") @PowerNukkitXOnly public NetworkPlayerSession getNetworkSession()
    • 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)
    • shakeCamera

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") public void shakeCamera(float intensity, float duration, CameraShakePacket.CameraShakeType shakeType, CameraShakePacket.CameraShakeAction shakeAction)
      玩家屏幕振动效果

      Player screen shake effect

      Parameters:
      intensity - the intensity
      duration - the duration
      shakeType - the shake type
      shakeAction - the shake action
    • setItemCoolDown

      @PowerNukkitXOnly @Since("1.19.21-r4") public void setItemCoolDown(int coolDown, String itemCategory)
      设置指定itemCategory物品的冷却显示效果,注意该方法仅为客户端显示效果,冷却逻辑实现仍需自己实现

      Set the cooling display effect of the specified itemCategory items, note that this method is only for client-side display effect, cooling logic implementation still needs to be implemented by itself

      Parameters:
      coolDown - the cool down
      itemCategory - the item category
    • sendToast

      public void sendToast(String title, String content)
      发送一个下弹消息框给玩家

      Send a Toast message box to the player

      Parameters:
      title - the title
      content - the content
    • removeLine

      @PowerNukkitXOnly @Since("1.19.30-r1") public void removeLine(IScoreboardLine line)
      Description copied from interface: IScoreboardViewer
      通知观察者指定计分板上的指定行已删除
      Specified by:
      removeLine in interface IScoreboardViewer
      Parameters:
      line - 目标行
    • updateScore

      @PowerNukkitXOnly @Since("1.19.30-r1") public void updateScore(IScoreboardLine line)
      Description copied from interface: IScoreboardViewer
      向观察者发送指定行的新分数
      Specified by:
      updateScore in interface IScoreboardViewer
      Parameters:
      line - 目标行
    • display

      @PowerNukkitXOnly @Since("1.19.30-r1") public void display(IScoreboard scoreboard, DisplaySlot slot)
      Description copied from interface: IScoreboardViewer
      在指定槽位显示计分板
      Specified by:
      display in interface IScoreboardViewer
      Parameters:
      scoreboard - 目标计分板
      slot - 目标槽位
    • hide

      @PowerNukkitXOnly @Since("1.19.30-r1") public void hide(DisplaySlot slot)
      Description copied from interface: IScoreboardViewer
      清除指定槽位的显示内容
      Specified by:
      hide in interface IScoreboardViewer
      Parameters:
      slot - 目标槽位
    • removeScoreboard

      public void removeScoreboard(IScoreboard scoreboard)
      Description copied from interface: IScoreboardViewer
      通知观察者计分板已删除(若计分板在任意显示槽位中,则会一并清除槽位)
      Specified by:
      removeScoreboard in interface IScoreboardViewer
      Parameters:
      scoreboard - 目标计分板
    • isOpenSignFront

      @PowerNukkitXOnly @Since("1.20.0-r1") public Boolean isOpenSignFront()
    • setOpenSignFront

      @PowerNukkitXOnly @Since("1.20.0-r1") public void setOpenSignFront(Boolean frontSide)
    • openSignEditor

      @PowerNukkitXOnly @Since("1.20.0-r1") public void openSignEditor(Vector3 position, boolean frontSide)
      Opens the player's sign editor GUI for the sign at the given position.
    • setFlySneaking

      @PowerNukkitXOnly @Since("1.20.10-r2") public void setFlySneaking(boolean sneaking)
    • isFlySneaking

      @PowerNukkitXOnly @Since("1.20.10-r2") public boolean isFlySneaking()
    • getFogStack

      public List<PlayerFogPacket.Fog> getFogStack()
      玩家迷雾设置

      Player Fog Settings

    • setFogStack

      public void setFogStack(List<PlayerFogPacket.Fog> fogStack)
      玩家迷雾设置

      Player Fog Settings