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 Summary
Modifier and TypeFieldDescriptionstatic final int
protected AdventureSettings
static final int
static final int
protected double
正在挖掘的方块正在挖掘的方向protected long
protected boolean
protected int
protected int
protected final int
protected Long
protected int
protected boolean
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
protected CraftingGrid
protected CraftingTransaction
int
long
static final int
static final int
static final float
static final float
protected com.github.benmanes.caffeine.cache.Cache<String,
FormWindowDialog> 我们使用google的cache来存储NPC对话框发送信息 原因是发送过去的对话框客户端有几率不响应,在特定情况下我们无法清除这些对话框,这会导致内存泄漏 5分钟后未响应的对话框会被清除protected String
protected Map<Long,
DummyBossBar> static final Player[]
一个承载玩家的空数组静态常量protected boolean
static final int
protected EnchantTransaction
protected Boolean
protected List<PlayerFogPacket.Fog>
玩家迷雾设置protected PlayerFood
protected Vector3
Deprecated.protected int
protected Map<Integer,
FormWindow> int
static final int
protected GrindstoneTransaction
protected int
代表玩家悬浮空中所经过的tick数.protected final SourceInterface
protected boolean
protected String
protected Entity
玩家最后攻击的实体.protected Entity
最后攻击玩家的实体.protected PlayerBlockActionData
long
protected int
返回上次吃紫颂果时的getTick()
,这个值用于控制吃紫颂果的冷却时间.protected int
返回上次投掷末影珍珠时的getTick()
,这个值用于控制末影珍珠的冷却时间.protected int
protected int
玩家升级时播放音乐的时间protected Vector3
protected double
long
protected final it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap<Boolean>
boolean
boolean
protected LoginChainData
static final float
protected int
protected final NetworkPlayerSession
protected Vector3
protected int
protected static final int
static final int
static final int
static final int
static final int
int
boolean
protected PlayerUIInventory
protected AsyncTask
protected long
protected final InetSocketAddress
protected boolean
是否移除改玩家聊天中的颜色字符如 §c §1protected RepairItemTransaction
protected static final int
protected Map<Integer,
FormWindow> protected boolean
protected boolean
protected Vector3
static final int
protected SmithingTransaction
protected InetSocketAddress
protected Position
boolean
protected Position
protected final int
static final int
每tick 当前位置与移动目标位置向量之差protected int
这个值代表玩家是否正在使用物品(长按右键),-1时玩家未使用物品,当玩家使用物品时该值为getTick()
的值.protected int
static final int
static final int
protected Vector3
Deprecated.static final int
村民交易window idprotected TradingTransaction
protected String
protected boolean
static final int
protected int
protected int
Fields inherited from class cn.nukkit.entity.EntityHuman
rawUUID, skin, uuid
Fields inherited from class cn.nukkit.entity.EntityHumanType
enderChestInventory, inventory, offhandInventory
Fields inherited from class cn.nukkit.entity.EntityLiving
attackTime, invisible, movementSpeed, turtleTicks
Fields inherited from class cn.nukkit.entity.Entity
absorption, age, blocksAround, boundingBox, chunk, closed, collisionBlocks, DATA_AERIAL_ATTACK, DATA_AGENT, DATA_AIR, DATA_ALWAYS_SHOW_NAMETAG, DATA_AMBIENT_SOUND_EVENT_NAME, DATA_AMBIENT_SOUND_INTERVAL, DATA_AMBIENT_SOUND_INTERVAL_RANGE, DATA_AREA_EFFECT_CLOUD_PARTICLE_ID, DATA_AREA_EFFECT_CLOUD_RADIUS, DATA_AREA_EFFECT_CLOUD_WAITING, DATA_ARMOR_STAND_POSE_INDEX, DATA_AUX_POWER, DATA_BALLOON_ATTACHED_ENTITY, DATA_BASE_RUNTIME_ID, DATA_BLOCK_TARGET, DATA_BOUNDING_BOX_HEIGHT, DATA_BOUNDING_BOX_WIDTH, DATA_BUBBLE_TIME, DATA_BUOYANCY_DATA, DATA_CAN_RIDE_TARGET, DATA_CHANGE_ON_PICKUP, DATA_CHANGE_RATE, DATA_CHARGE_AMOUNT, DATA_CLIENT_EVENT, DATA_COLLISION_BOX, DATA_COLOR, DATA_COLOR_2, DATA_COLOUR, DATA_COMMAND_BLOCK_COMMAND, DATA_COMMAND_BLOCK_EXECUTE_ON_FIRST_TICK, DATA_COMMAND_BLOCK_LAST_OUTPUT, DATA_COMMAND_BLOCK_TICK_DELAY, DATA_COMMAND_BLOCK_TRACK_OUTPUT, DATA_CONTAINER_BASE_SIZE, DATA_CONTAINER_EXTRA_SLOTS_PER_STRENGTH, DATA_CONTAINER_TYPE, DATA_CONTROLLING_RIDER_SEAT_NUMBER, DATA_DISPLAY_ITEM, DATA_DISPLAY_OFFSET, DATA_DURATION, DATA_EATING_COUNTER, DATA_ENDER_CRYSTAL_TIME_OFFSET, DATA_ENDERMAN_HELD_RUNTIME_ID, DATA_ENTITY_AGE, DATA_EXPERIENCE_VALUE, DATA_FALL_DAMAGE_MULTIPLIER, DATA_FIREBALL_POWER_X, DATA_FIREBALL_POWER_Y, DATA_FIREBALL_POWER_Z, DATA_FISH_ANGLE, DATA_FISH_X, DATA_FISH_Z, DATA_FLAG_ACTION, DATA_FLAG_ADMIRING, DATA_FLAG_ALWAYS_SHOW_NAMETAG, DATA_FLAG_ANGRY, DATA_FLAG_BABY, DATA_FLAG_BLOCKED_USING_DAMAGED_SHIELD, DATA_FLAG_BLOCKED_USING_SHIELD, DATA_FLAG_BLOCKING, DATA_FLAG_BREAKING_OBSTRUCTION, DATA_FLAG_BREATHING, DATA_FLAG_BRIBED, DATA_FLAG_CAN_CLIMB, DATA_FLAG_CAN_DASH, DATA_FLAG_CAN_FLY, DATA_FLAG_CAN_POWER_JUMP, DATA_FLAG_CAN_SHOW_NAMETAG, DATA_FLAG_CELEBRATING, DATA_FLAG_CELEBRATING_SPECIAL, DATA_FLAG_CHARGE_ATTACK, DATA_FLAG_CHARGED, DATA_FLAG_CHESTED, DATA_FLAG_CONTAINER_PRIVATE, DATA_FLAG_CONVERTING, DATA_FLAG_CRAWLING, DATA_FLAG_CRITICAL, DATA_FLAG_CROAKING, DATA_FLAG_DANCING, DATA_FLAG_DELAYED_ATTACK, DATA_FLAG_DIGGING, DATA_FLAG_DOOR_BREAKER, DATA_FLAG_DOOR_OPENER, DATA_FLAG_EAT_MOB, DATA_FLAG_EATING, DATA_FLAG_ELDER, DATA_FLAG_EMERGING, DATA_FLAG_EMOTING, DATA_FLAG_ENCHANTED, DATA_FLAG_ENTITY_GROW_UP, DATA_FLAG_EVOKER_SPELL, DATA_FLAG_FACING_TARGET_TO_RANGE_ATTACK, DATA_FLAG_FALL_THROUGH_SCAFFOLDING, DATA_FLAG_FEELING_HAPPY, DATA_FLAG_FIRE_IMMUNE, DATA_FLAG_GLIDING, DATA_FLAG_GRAVITY, DATA_FLAG_HAS_COLLISION, DATA_FLAG_HAS_DASH_COOLDOWN, DATA_FLAG_HIDDEN_WHEN_INVISIBLE, DATA_FLAG_IDLING, DATA_FLAG_IGNITED, DATA_FLAG_IMMOBILE, DATA_FLAG_IN_ASCENDABLE_BLOCK, DATA_FLAG_IN_SCAFFOLDING, DATA_FLAG_INLOVE, DATA_FLAG_INTERESTED, DATA_FLAG_INVISIBLE, DATA_FLAG_IS_AVOIDING_BLOCKS, DATA_FLAG_IS_AVOIDING_MOBS, DATA_FLAG_IS_ILLAGER_CAPTAIN, DATA_FLAG_IS_IN_UI, DATA_FLAG_IS_TRANSFORMING, DATA_FLAG_JUMP_GOAL_JUMP, DATA_FLAG_LAYING_DOWN, DATA_FLAG_LAYING_EGG, DATA_FLAG_LEASHED, DATA_FLAG_LINGER, DATA_FLAG_MOVING, DATA_FLAG_NO_AI, DATA_FLAG_ONFIRE, DATA_FLAG_ORPHANED, DATA_FLAG_OVER_DESCENDABLE_BLOCK, DATA_FLAG_OVER_SCAFFOLDING, DATA_FLAG_PLAYING_DEAD, DATA_FLAG_POWERED, DATA_FLAG_PREGNANT, DATA_FLAG_PUSH_TOWARDS_CLOSEST_SPACE, DATA_FLAG_RAM_ATTACK, DATA_FLAG_REARING, DATA_FLAG_RESTING, DATA_FLAG_RIDER_CAN_PICK, DATA_FLAG_RIDING, DATA_FLAG_RISING, DATA_FLAG_ROARING, DATA_FLAG_ROLLING, DATA_FLAG_SADDLED, DATA_FLAG_SCARED, DATA_FLAG_SCENTING, DATA_FLAG_SEARCHING, DATA_FLAG_SHEARED, DATA_FLAG_SHOW_TRIDENT_ROPE, DATA_FLAG_SHOWBASE, DATA_FLAG_SILENT, DATA_FLAG_SITTING, DATA_FLAG_SLEEPING, DATA_FLAG_SNEAKING, DATA_FLAG_SNEEZING, DATA_FLAG_SNIFFING, DATA_FLAG_SONIC_BOOM, DATA_FLAG_SPIN_ATTACK, DATA_FLAG_SPRINTING, DATA_FLAG_STACKABLE, DATA_FLAG_STALKING, DATA_FLAG_STUNNED, DATA_FLAG_SWIMMER, DATA_FLAG_SWIMMING, DATA_FLAG_TAMED, DATA_FLAG_TEMPTED, DATA_FLAG_TRADE_INTEREST, DATA_FLAG_TRANSITION_BLOCKING, DATA_FLAG_TRANSITION_SETTING, DATA_FLAG_TRANSITION_SITTING, DATA_FLAG_TRUSTING, DATA_FLAG_VIBRATING, DATA_FLAG_WALKER, DATA_FLAG_WALLCLIMBING, DATA_FLAG_WASD_CONTROLLED, DATA_FLAGS, DATA_FLAGS_EXTENDED, DATA_FREEZING_EFFECT_STRENGTH, DATA_FUSE_LENGTH, DATA_GOAT_HORN_COUNT, DATA_HAS_COMMAND_BLOCK, DATA_HAS_DISPLAY, DATA_HAS_NPC_COMPONENT, DATA_HEALTH, DATA_HEARTBEAT_INTERVAL_TICKS, DATA_HEARTBEAT_SOUND_EVENT, DATA_HIGH_TIER_CURED_DISCOUNT, DATA_HITBOX, DATA_HURT_DIRECTION, DATA_HURT_TIME, DATA_INTERACT_TEXT, DATA_INTERACTIVE_TAG, DATA_IS_BUOYANT, DATA_JUMP_DURATION, DATA_LAYING_AMOUNT, DATA_LAYING_AMOUNT_PREVIOUS, DATA_LEAD_HOLDER_EID, DATA_LIMITED_LIFE, DATA_LOW_TIER_CURED_DISCOUNT, DATA_MARK_VARIANT, DATA_MAX_AIR, DATA_MAX_STRENGTH, DATA_MAX_TRADE_TIER, DATA_MOVEMENT_SOUND_DISTANCE_OFFSET, DATA_NAME_AUTHOR, DATA_NAME_RAW_TEXT, DATA_NAMETAG, DATA_NEARBY_CURED_DISCOUNT, DATA_NEARBY_CURED_DISCOUNT_TIMESTAMP, DATA_NPC_ACTIONS, DATA_NPC_SKIN_DATA, DATA_OLD_SWELL, DATA_OWNER_EID, DATA_PADDLE_TIME_LEFT, DATA_PADDLE_TIME_RIGHT, DATA_PICKUP_COUNT, DATA_PLAYER_BED_POSITION, DATA_PLAYER_BUTTON_TEXT, DATA_PLAYER_FLAG_DEAD, DATA_PLAYER_FLAG_SLEEP, DATA_PLAYER_FLAGS, DATA_PLAYER_HAS_DIED, DATA_PLAYER_INDEX, DATA_PLAYER_LAST_DEATH_DIMENSION, DATA_PLAYER_LAST_DEATH_POS, DATA_POTION_AMBIENT, DATA_POTION_AUX_VALUE, DATA_POTION_COLOR, DATA_PUFFERFISH_SIZE, DATA_RIDER_MAX_ROTATION, DATA_RIDER_MIN_ROTATION, DATA_RIDER_ROTATION_LOCKED, DATA_RIDER_ROTATION_OFFSET, DATA_RIDER_SEAT_POSITION, DATA_SCALE, DATA_SCORE_TAG, DATA_SHULKER_ATTACH_FACE, DATA_SHULKER_ATTACH_POS, DATA_SHULKER_ATTACHED, DATA_SHULKER_PEEK_ID, DATA_SITTING_AMOUNT, DATA_SITTING_AMOUNT_PREVIOUS, DATA_SKIN_ID, DATA_SPAWN_TIME, DATA_SPAWNING_FRAMES, DATA_SPELL_CASTING_COLOR, DATA_STRENGTH, DATA_SWELL, DATA_SWELL_DIR, DATA_TARGET_EID, DATA_TRADE_EXPERIENCE, DATA_TRADE_TIER, DATA_TRADING_CAREER, DATA_TRADING_PLAYER_EID, DATA_TYPE_BYTE, DATA_TYPE_FLOAT, DATA_TYPE_INT, DATA_TYPE_LONG, DATA_TYPE_NBT, DATA_TYPE_POS, DATA_TYPE_SHORT, DATA_TYPE_STRING, DATA_TYPE_VECTOR3F, DATA_USING_ITEM, DATA_VARIANT, DATA_WITHER_INVULNERABLE_TICKS, DATA_WITHER_TARGET_1, DATA_WITHER_TARGET_2, DATA_WITHER_TARGET_3, dataProperties, deadTicks, effects, entityCollisionReduction, entityCount, entityUniqueId, fallDistance, fireProof, fireTicks, firstMove, freezingTicks, hasSpawned, headYawDelta, health, highestPosition, id, inBlock, inEndPortal, inPortalTicks, invulnerable, isCollided, isCollidedHorizontally, isCollidedVertically, isPlayer, isStatic, justCreated, keepMovement, lastDamageCause, lastHeadYaw, lastMotionX, lastMotionY, lastMotionZ, lastPitch, lastUpdate, lastX, lastY, lastYaw, lastZ, maxFireTicks, motionChanged, motionX, motionY, motionZ, namedTag, NETWORK_ID, noClip, noDamageTicks, offsetBoundingBox, onGround, passengers, pitchDelta, positionChanged, riding, saveWithChunk, scale, server, temporalVector, ticksLived, yawDelta, ySize
-
Constructor Summary
ConstructorDescriptionPlayer
(SourceInterface interfaz, Long clientID, String ip, int port) 单元测试用的构造函数Player
(SourceInterface interfaz, Long clientID, InetSocketAddress socketAddress) -
Method Summary
Modifier and TypeMethodDescriptionaddAttachment
(Plugin plugin) addAttachment
(Plugin plugin, String name) addAttachment
(Plugin plugin, String name, Boolean value) protected void
void
addExperience
(int add) playLevelUpSound=falsevoid
addExperience
(int add, boolean playLevelUpSound) 增加该玩家的经验值void
addMovement
(double x, double y, double z, double yaw, double pitch, double headYaw) 增加运动 (仅发送数据包,如果需要请使用Entity.setMotion(cn.nukkit.math.Vector3)
)int
addServerSettings
(FormWindow window) 在游戏设置中显示一个新的设置页面。 你可以通过监听PlayerFormRespondedEvent来了解设置结果。int
forceId=null isPermanent=false alwaysOpen = false
int
isPermanent=false alwaysOpen = false
int
alwaysOpen = falseint
添加一个Inventory
窗口显示到该玩家asEntity()
如果发送者是一个实体,返回执行该命令的实体.asPlayer()
如果发送者是一个玩家,返回执行该命令的玩家.boolean
attack
(EntityDamageEvent source) 当一个实体被攻击时(即接受一个实体伤害事件 这个事件可以是由其他实体攻击导致,也可能是自然伤害)调用.boolean
awardAchievement
(String achievementId) boolean
batchDataPacket
(DataPacket packet) Deprecated.static int
calculateRequireExperience
(int level) 计算玩家到达某等级所需要的经验值boolean
boolean
canCollideWith
(Entity entity) boolean
canInteract
(Vector3 pos, double maxDistance) boolean
canInteract
(Vector3 pos, double maxDistance, double maxDiff) boolean
boolean
以该玩家的身份发送一条聊天信息。如果消息以/(正斜杠)开头,它将被视为一个命令。protected void
protected void
protected void
checkGroundState
(double movX, double movY, double movZ, double dx, double dy, double dz) void
检查附近可交互的实体(插件一般不使用)protected void
void
void
清除掉玩家身上正在显示的标题信息。void
close()
void
close
(TextContainer message) reason="generic",notify=true
void
close
(TextContainer message, String reason) notify=truevoid
close
(TextContainer message, String reason, boolean notify) void
notify=true
void
notify=true
void
protected void
异步登录任务成功完成后执行void
completeUsingItem
(int itemId, int action) long
createBossBar
(DummyBossBar dummyBossBar) 创建并发送一个BossBar给玩家。long
createBossBar
(String text, int length) Deprecated.boolean
dataPacket
(DataPacket packet) 0 is true -1 is false other is identiferint
dataPacket
(DataPacket packet, boolean needACK) Deprecated.boolean
dataPacketImmediately
(DataPacket packet) boolean
dataResourcePacket
(DataPacket packet) boolean
directDataPacket
(DataPacket packet) Deprecated.int
directDataPacket
(DataPacket packet, boolean needACK) Deprecated.void
display
(IScoreboard scoreboard, DisplaySlot slot) 在指定槽位显示计分板boolean
Whether the entity can active pressure plates.protected void
完成completeLoginSequence后执行dropAndGetItem
(Item item) 在玩家面前的地面上扔下一个物品。返回值为该掉落的物品。boolean
在玩家面前的地面上掉落一个物品。如果物品投放成功,则返回。boolean
entityBaseTick
(int tickDiff) boolean
boolean
fastMove
(double dx, double dy, double dz) void
forceDataPacket
(DataPacket packet, Runnable callback) protected void
得到地址,如果开启waterdogpe兼容,该地址是被修改为兼容waterdogpe型的,反之则与rawSocketAddress
一样获得玩家权限设置.boolean
protected float
偏移客户端传输玩家位置的y轴误差获得移动设备玩家面对载具时出现的交互按钮的语言硬编码。static BatchPacket
getChunkCacheFromData
(int chunkX, int chunkZ, int subChunkCount, byte[] payload) Deprecated.int
获取上一个关闭窗口对应的id获取该玩家的CraftingGrid
获取该玩家的PlayerCursorInventory
得到该玩家的显示名称Item[]
getDrops()
getDummyBossBar
(long bossBarId) 获取一个DummyBossBar对象获取所有DummyBossBar对象getEntityPlayerLookingAt
(int maxDistance) 返回玩家目前正在看的实体。int
得到该玩家的经验值(并不会显示玩家从的经验值总数,而仅仅显示当前等级所在的经验值,即经验条)。int
得到该玩家的等级。得到这个玩家第一次游戏的时间。
Returns the time this player first played in this server.玩家迷雾设置获取玩家的PlayerFood
int
得到gamemode。int
获取击杀该玩家的实体int
int
返回lastEnderPearl
的值int
返回lastInAirTick
的值,代表玩家上次在空中的server tick得到这个玩家上次加入游戏的时间。
Returns the time this player last joined in this server.获取玩家离开的消息int
获取该玩家的登录链数据getMetadata
(String metadataKey) getName()
The current name used by this entity in the name tag, or the static name if the entity don't have nametag.获得下一个tick客户端玩家将要移动的位置int
The name that English name of the type of this entity.int
getPing()
得到该玩家的网络延迟。得到这个接口的Player
对象。
Returns aPlayer
object for this interface.int
getPort()
得到原始地址int
得到原始端口得到原始套接字地址boolean
返回命令发送者所在的服务器.得到套接字地址,如果开启waterdogpe兼容,该套接字地址是被修改为兼容waterdogpe型的,反正则与rawSocketAddress
一样float
返回灵魂急行带来的速度增加倍速getSpawn()
获取该玩家的可用重生点,Deprecated.int
返回startAction
的值double
int
获取该玩家的PlayerUIInventory
int
得到玩家的可视距离返回viewingEnderChest
的值,只在玩家打开末影箱时有效.getWindowById
(int id) 获取Inventory
从指定idint
getWindowId
(Inventory inventory) 获取id从指定Inventory
void
将物品添加到玩家的主要库存中,并将任何多余的物品丢在地上。void
handleDataPacket
(DataPacket packet) protected void
handleLogicInMove
(boolean invalidMotion, double distance) protected void
handleMovement
(Location clientPos) boolean
hasAchievement
(String achievementId) boolean
int
hashCode()
boolean
hasMetadata
(String metadataKey) boolean
hasPermission
(Permission permission) boolean
hasPermission
(String name) boolean
返回这个玩家以前是否来过服务器。
Returns if this player has played in this server before.boolean
void
hide
(DisplaySlot slot) 清除指定槽位的显示内容void
hidePlayer
(Player player) 从当前玩家实例的视角中隐藏指定玩家playerprotected void
实体初始化顺序,先初始化Entity类字段->Entity构造函数->进入init方法->调用initEntity方法->子类字段初始化->子类构造函数boolean
该玩家是否为冒险模式。boolean
isBanned()
返回这个玩家是否被封禁(ban)。
Returns if this player is banned.boolean
玩家是否在挖掘方块boolean
boolean
boolean
该玩家是否为创造模式。boolean
boolean
isEntity()
请使用这个方法来检查发送者是否是一个实体,而不是使用代码"xxx instanceof Entity"
.
因为发送者可能不是"Entity"
的一个实例,但实际上它是以一个实体的身份执行命令(例如:"ExecutorCommandSender"
)boolean
boolean
boolean
boolean
boolean
isOnline()
返回这个玩家是否在线。
Returns if this player is online.boolean
isOp()
返回这个对象是不是服务器管理员。
Returns if this object is an operator.boolean
isPermissionSet
(Permission permission) boolean
isPermissionSet
(String name) boolean
isPlayer()
boolean
boolean
玩家是否在睡觉boolean
该玩家是否为观察者模式。boolean
该玩家是否为生存模式。boolean
返回玩家当前是否正在使用某项物品(右击并按住)。protected boolean
isValidRespawnBlock
(Block block) 判断重生锚是否有效如果重生锚有效则在重生锚上重生或者在床上重生 如果玩家以上2种都没有则在服务器重生点重生boolean
返回这个玩家是否已加入白名单。
Returns if this player is pardoned by whitelist.boolean
kick()
reason=empty stringboolean
kick
(PlayerKickEvent.Reason reason) boolean
kick
(PlayerKickEvent.Reason reason, boolean isAdmin) boolean
kick
(PlayerKickEvent.Reason reason, String reasonString) boolean
kick
(PlayerKickEvent.Reason reason, String reasonString, boolean isAdmin) 踢出该玩家boolean
boolean
void
kill()
protected void
offerMovementTask
(Location newPosition) protected void
onBlock
(Entity entity, EntityDamageEvent e, boolean animate) protected void
onBlockBreakAbort
(Vector3 pos, BlockFace face) protected void
onBlockBreakComplete
(BlockVector3 blockPos, BlockFace face) protected void
onBlockBreakContinue
(Vector3 pos, BlockFace face) protected void
onBlockBreakStart
(Vector3 pos, BlockFace face) void
onBlockChanged
(Vector3 block) void
void
onChunkChanged
(FullChunk chunk) void
onChunkLoaded
(FullChunk chunk) void
onChunkPopulated
(FullChunk chunk) void
onChunkUnloaded
(FullChunk chunk) protected void
玩家客户端初始化完成后调用void
boolean
onUpdate
(int currentTick) void
openSignEditor
(Vector3 position, boolean frontSide) Opens the player's sign editor GUI for the sign at the given position.protected boolean
boolean
pickupEntity
(Entity entity, boolean near) protected void
处理LOGIN_PACKET中执行protected void
processMovement
(int tickDiff) Deprecated.void
void
removeAchievement
(String achievementId) void
permanent=falsevoid
removeAllWindows
(boolean permanent) 清空windows
void
removeAttachment
(PermissionAttachment attachment) void
removeBossBar
(long bossBarId) 移除一个BossBarvoid
removeLine
(IScoreboardLine line) 通知观察者指定计分板上的指定行已删除void
removeMetadata
(String metadataKey, Plugin owningPlugin) void
removeScoreboard
(IScoreboard scoreboard) 通知观察者计分板已删除(若计分板在任意显示槽位中,则会一并清除槽位)void
removeWindow
(Inventory inventory) 移除该玩家身上的指定Inventoryprotected void
removeWindow
(Inventory inventory, boolean isResponse) protected void
void
Reset crafting grid type.void
void
设置inAirTicks
为0void
为下一个显示的标题重新设置标题动画时间和副标题。protected void
respawn()
protected void
revertClientMotion
(Location originalPos) void
save()
void
save
(boolean async) void
saveNBT()
void
sendActionBar
(String title) fadein=1,duration=0,fadeout=1void
sendActionBar
(String title, int fadein, int duration, int fadeout) 在玩家物品栏上方发送一个ActionBar消息。void
常用于刷新。void
sendAnnouncement
(String message) void
sendAnnouncement
(String source, String message) void
void
void
void
在玩家聊天栏发送一个文本void
sendChunk
(int x, int z, int subChunkCount, byte[] payload) void
sendChunk
(int x, int z, DataPacket packet) void
void
sendCommandOutput
(CommandOutputContainer container) Send command output.void
void
sendExperience
(int exp) setExperience的实现部分,用来设置当前等级所对应的经验值,即经验条void
void
sendExperienceLevel
(int level) setExperience的实现部分,用来设置当前等级void
将迷雾设定发送到客户端void
sendMessage
(TextContainer message) 给命令发送者返回信息.void
sendMessage
(String message) 给命令发送者返回信息.void
sendMovementSpeed
(float speed) 发送Attribute.MOVEMENT_SPEED
属性到客户端protected void
protected void
sendPlayStatus
(int status) protected void
sendPlayStatus
(int status, boolean immediate) void
void
在玩家物品栏上方发送一个弹出式的文本void
sendPopupJukebox
(String message) void
sendPosition
(Vector3 pos) void
sendPosition
(Vector3 pos, double yaw) void
sendPosition
(Vector3 pos, double yaw, double pitch) void
sendPosition
(Vector3 pos, double yaw, double pitch, int mode) void
sendPosition
(Vector3 pos, double yaw, double pitch, int mode, Player[] targets) void
sendRawTextMessage
(RawText text) 在玩家聊天栏发送一个JSON文本void
void
sendSystem
(String message) void
在玩家物品栏上方发送一个提示文本void
subtitle=null,fadeIn=20,stay=20,fadeOut=5
void
fadeIn=20,stay=20,fadeOut=5
void
在玩家视角正中央发送一个标题文本。void
发送一个下弹消息框给玩家void
sendTranslation
(String message) void
sendTranslation
(String message, String[] parameters) 在玩家聊天栏发送一个多语言翻译文本,示例:message="Test Message {%0} {%1}" parameters=["Hello","World"]
实际消息内容"Test Message Hello World"
void
sendWhisper
(String message) void
sendWhisper
(String source, String message) void
setAdventureSettings
(AdventureSettings adventureSettings) 用于设置玩家权限,对应游戏中的玩家权限设置.void
setAllowFlight
(boolean value) void
setAllowInteract
(boolean value) void
setAllowInteract
(boolean value, boolean containers) 设置允许交互世界/容器void
setAllowModifyWorld
(boolean value) 设置允许修改世界(未知原因设置完成之后,玩家不允许挖掘方块,但是可以放置方块)void
setAttribute
(Attribute attribute) 以指定Attribute
发送UpdateAttributesPacket数据包到该玩家。void
setAutoJump
(boolean value) void
setBanned
(boolean value) 设置这个玩家是否被封禁(ban)。
Sets this player to be banned or to be pardoned.void
setButtonText
(String text) 设置移动设备玩家面对载具时出现的交互按钮的语言硬编码。void
setCheckMovement
(boolean checkMovement) 设置是否检查该玩家移动void
setCraftingGrid
(CraftingGrid grid) 设置该玩家的CraftingGrid
void
setDisplayName
(String displayName) 只是改变玩家聊天时和在服务器玩家列表中的显示名(不影响命令的玩家参数名,也不影响玩家头顶显示名称)void
setEnableClientCommand
(boolean enable) void
setExperience
(int exp) level = this.getExperienceLevel(),playLevelUpSound=false
void
setExperience
(int exp, int level) playLevelUpSound=falsevoid
setExperience
(int exp, int level, boolean playLevelUpSound) 设置该玩家的经验值和等级void
setFlySneaking
(boolean sneaking) void
setFogStack
(List<PlayerFogPacket.Fog> fogStack) 玩家迷雾设置void
setFoodEnabled
(boolean foodEnabled) 设置该玩家是否开启饮食系统boolean
setGamemode
(int gamemode) boolean
setGamemode
(int gamemode, boolean serverSide) AdventureSettings=nullboolean
setGamemode
(int gamemode, boolean serverSide, AdventureSettings newSettings) boolean
setGamemode
(int gamemode, boolean serverSide, AdventureSettings newSettings, boolean forceUpdate) 设置gamemodevoid
setHasSeenCredits
(boolean hasSeenCredits) void
setHealth
(float health) void
setItemCoolDown
(int coolDown, String itemCategory) 设置指定itemCategory物品的冷却显示效果,注意该方法仅为客户端显示效果,冷却逻辑实现仍需自己实现void
void
setMaxHealth
(int maxHealth) void
setMetadata
(String metadataKey, MetadataValue newMetadataValue) boolean
每次调用此方法都会向客户端发送motion包。若多次调用,motion将在客户端叠加void
setMovementSpeed
(float speed) send=truevoid
setMovementSpeed
(float speed, boolean send) 设置该玩家的移动速度void
setNoShieldTicks
(int noShieldTicks) void
setOp
(boolean value) 把这个对象设置成服务器管理员。
Sets this object to be an operator or not to be.void
setOpenSignFront
(Boolean frontSide) void
setRawTextActionBar
(RawText text) fadein=1,duration=0,fadeout=1void
setRawTextActionBar
(RawText text, int fadein, int duration, int fadeout) 设置一个JSON ActionBar消息。void
setRawTextSubTitle
(RawText text) 设置一个JSON文本副标题。void
setRawTextTitle
(RawText text) 设置一个JSON文本标题。void
void
setRemoveFormat
(boolean remove) 设置removeFormat
为指定值void
setShowingCredits
(boolean showingCredits) void
void
设置玩家的出生点/复活点。void
setSpawnBlock
(Vector3 spawnBlock) 设置保存玩家重生位置的方块的位置。当未知时可能为空。void
setSprinting
(boolean value) void
setSubtitle
(String subtitle) 设置副标题,在主标题下方显示。void
setTimeSinceRest
(int timeSinceRest) void
setTitleAnimationTimes
(int fadein, int duration, int fadeout) 设置标题动画时间void
setUsingItem
(boolean value) 设置玩家当前是否正在使用某项物品startAction
(右击并按住)。void
setViewDistance
(int distance) 设置玩家的可视距离(范围 0--Server.getViewDistance()
)void
设置viewingEnderChest
值为chestvoid
setWhitelisted
(boolean value) 把这个玩家加入白名单,或者取消这个玩家的白名单。
Adds this player to the white list, or removes it from the whitelist.void
shakeCamera
(float intensity, float duration, CameraShakePacket.CameraShakeType shakeType, CameraShakePacket.CameraShakeAction shakeAction) 玩家屏幕振动效果void
void
showDialogWindow
(FormWindowDialog dialog) book=truevoid
showDialogWindow
(FormWindowDialog dialog, boolean book) 向玩家展示一个NPC对话框.int
showFormWindow
(FormWindow window) Automatic id assignmentint
showFormWindow
(FormWindow window, int id) 向玩家显示一个新的FormWindow。 你可以通过监听PlayerFormRespondedEvent来了解FormWindow的结果。void
showPlayer
(Player player) 从当前玩家实例的视角中显示指定玩家playervoid
showXboxProfile
(String xuid) 显示一个XBOX账户的资料窗口boolean
void
将这个实体在客户端生成,让该玩家可以看到它void
void
startFishing
(Item fishingRod) Start fishingvoid
设置startAction
值为-1void
stopFishing
(boolean click) Stop fishingvoid
boolean
switchLevel
(Level level) boolean
teleport
(Location location, PlayerTeleportEvent.TeleportCause cause) void
teleportImmediate
(Location location) Deprecated.void
teleportImmediate
(Location location, PlayerTeleportEvent.TeleportCause cause) Deprecated.toString()
void
transfer
(InetSocketAddress address) 传送该玩家到另一个服务器void
unloadChunk
(int x, int z) void
unloadChunk
(int x, int z, Level level) void
updateBossBar
(String text, int length, long bossBarId) Deprecated.void
updateScore
(IScoreboardLine line) 向观察者发送指定行的新分数void
void
updateTrackingPositions
(boolean delayed) Methods inherited from class cn.nukkit.entity.EntityHuman
despawnFrom, entityBaseTick, getEyeHeight, getHeight, getLength, getNetworkId, getRawUniqueId, getSkin, getSwimmingHeight, getUniqueId, getWidth, setRawUniqueId, setUniqueId
Methods inherited from class cn.nukkit.entity.EntityHumanType
applyNameTag, applyNameTag, calculateEnchantmentProtectionFactor, damageArmor, getEnderChestInventory, getInventory, getOffhandInventory, setInventories, setOnFire
Methods inherited from class cn.nukkit.entity.EntityCreature
onInteract, playerApplyNameTag
Methods inherited from class cn.nukkit.entity.EntityLiving
blockedByShield, collidingWith, getAirTicks, getAttackTime, getAttackTimeBefore, getDrag, getGravity, getLineOfSight, getLineOfSight, getLineOfSight, getLineOfSight, getMovementSpeed, getTargetBlock, getTargetBlock, getTargetBlock, hasLineOfSight, isAttackTimeByShieldKb, isBlocking, isPersistent, knockBack, knockBack, postAttack, preAttack, setAirTicks, setBlocking, setPersistent
Methods inherited from class cn.nukkit.entity.Entity
addEffect, addFreezingTicks, addMotion, addTag, applyEntityCollision, attack, broadcastLinkPacket, broadcastMovement, canBeMovedByCurrents, canBePushed, canBeSavedWithChunk, canClimb, canClimbWalls, canPassThrough, canTriggerWalking, checkObstruction, collideWithBlock, containTag, createAddEntityPacket, createEntity, createEntity, createEntity, createEntity, createEntity, despawnFromAll, dismountEntity, dismountEntity, enableHeadYaw, extinguish, fall, getAbsorption, getAge, getAllTags, getBlocksAround, getBoundingBox, getCollisionBlocks, getCurrentHeight, getDataFlag, getDataProperties, getDataProperty, getDataPropertyBoolean, getDataPropertyByte, getDataPropertyFloat, getDataPropertyInt, getDataPropertyLong, getDataPropertyNBT, getDataPropertyPos, getDataPropertyShort, getDataPropertyString, getDataPropertyType, getDataPropertyVector3f, getDefaultNBT, getDefaultNBT, getDefaultNBT, getDirection, getDirectionPlane, getDirectionVector, getEffect, getEffects, getEntityDefinitions, getFreezingEffectStrength, getFreezingTicks, getFrostbiteInjury, getHealth, getHorizontalFacing, getId, getIdentifier, getIdentifier, getKnownEntities, getKnownEntityIds, getKnownEntityProviders, getLastDamageCause, getLocation, getMaxHealth, getMotion, getMountedOffset, getNameTag, getPassenger, getPassengers, getPosition, getRiding, getSaveId, getSaveId, getSaveId, getSaveIds, getScale, getScoreTag, getSeatPosition, getTickCachedBlocksAround, getTickCachedCollisionBlocks, getViewers, getVisibleName, handleLavaMovement, hasControllingPassenger, hasCustomName, hasEffect, hasWaterAt, hasWaterAt, heal, heal, init, init, isAlive, isBoss, isClosed, isControlling, isGliding, isImmobile, isInEndPortal, isInsideOfFire, isInsideOfLava, isInsideOfSolid, isInsideOfWater, isNameTagAlwaysVisible, isNameTagVisible, isNoClip, isOnFire, isOnGround, isOnLadder, isPassenger, isPreventingSleep, isSneaking, isSpinAttacking, isSprinting, isSwimming, isTouchingWater, isUndead, isUnderBlock, mountEntity, mountEntity, move, moveFlying, onCollideWithPlayer, onInteract, onPhysicalInteraction, onPushByPiston, onStruckByLightning, playActionAnimation, playActionAnimation, playAnimation, playAnimation, playAnimationOnEntities, playAnimationOnEntities, recalculateBoundingBox, recalculateBoundingBox, recalculateEffectColor, registerCustomEntity, registerEntity, registerEntity, registerEntity, registerEntity, removeAllEffects, removeEffect, removeTag, respawnToAll, scheduleUpdate, sendData, sendData, sendData, sendData, sendPotionEffects, setAbsorption, setAmbientSoundEvent, setAmbientSoundEventName, setAmbientSoundInterval, setAmbientSoundIntervalRange, setBooleanEntityProperty, setCanBeSavedWithChunk, setCanClimb, setCanClimb, setCanClimbWalls, setCanClimbWalls, setDataFlag, setDataFlag, setDataProperty, setDataProperty, setEnumEntityProperty, setFloatEntityProperty, setFreezingEffectStrength, setFreezingTicks, setGliding, setGliding, setImmobile, setImmobile, setIntEntityProperty, setLastDamageCause, setNameTag, setNameTagAlwaysVisible, setNameTagAlwaysVisible, setNameTagVisible, setNameTagVisible, setNoClip, setPosition, setPositionAndRotation, setPositionAndRotation, setRotation, setRotation, setScale, setScoreTag, setSeatPosition, setSneaking, setSneaking, setSpinAttacking, setSpinAttacking, setSprinting, setSwimming, setSwimming, spawnToAll, teleport, teleport, teleport, teleport, teleport, updateFallState, updateMovement, updatePassengerPosition, updatePassengers
Methods inherited from class cn.nukkit.level.Location
abs, add, add, add, add, ceil, clone, divide, floor, fromObject, fromObject, fromObject, fromObject, fromObject, getHeadYaw, getPitch, getYaw, multiply, round, setHeadYaw, setPitch, setX, setY, setYaw, setZ, subtract, subtract, subtract, subtract, subtract
Methods inherited from class cn.nukkit.level.Position
getChunk, getLevel, getLevelBlock, getLevelBlock, getLevelBlock, getLevelBlock, getLevelBlockAround, getLevelBlockAtLayer, getLevelBlockEntity, getLevelBlockState, getLevelBlockState, getLevelName, getSide, getSide, getSidePos, getTickCachedLevelBlock, getTickCachedLevelBlockAtLayer, getTypedBlockEntity, getValidLevel, isValid, setComponents, setComponents, setLevel, setStrong, setWeak
Methods inherited from class cn.nukkit.positiontracking.NamedPosition
matchesNamedPosition
Methods inherited from class cn.nukkit.math.Vector3
asBlockVector3, asVector3f, cross, distance, distance, distanceManhattan, distanceSquared, distanceSquared, dot, down, down, east, east, getAxis, getChunkSectionY, getChunkVector, getChunkX, getChunkZ, getFloorX, getFloorY, getFloorZ, getForward, getIntermediateWithXValue, getIntermediateWithYValue, getIntermediateWithZValue, getRight, getSideVec, getSouth, getUp, getWest, getX, getY, getZ, length, lengthSquared, maxPlainDistance, maxPlainDistance, maxPlainDistance, maxPlainDistance, maxPlainDistance, normalize, north, north, rawHashCode, setComponentsAdding, setComponentsAdding, south, south, up, up, west, west
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface cn.nukkit.level.ChunkLoader
getLevel, getPosition, getX, getZ
Methods inherited from interface cn.nukkit.command.CommandSender
getLocation, getPosition
Methods inherited from interface cn.nukkit.entity.EntityAgeable
isBaby, setBaby
Methods inherited from interface cn.nukkit.entity.EntityNameable
getNameTag, isNameTagVisible, isPersistent, playerApplyNameTag, setNameTag, setNameTagVisible, setPersistent
Methods inherited from interface cn.nukkit.entity.IHuman
initHumanEntity, saveHumanEntity
Methods inherited from interface cn.nukkit.IPlayer
getUniqueId
-
Field Details
-
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
- See Also:
-
CRAFTING_STONECUTTER
- See Also:
-
CRAFTING_CARTOGRAPHY
- See Also:
-
CRAFTING_SMITHING
- See Also:
-
TRADE_WINDOW_ID
村民交易window idVillager 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
-
SMITHING_WINDOW_ID
-
achievements
-
usedChunks
-
playedBefore
public boolean playedBefore -
spawned
public boolean spawned -
loggedIn
public boolean loggedIn -
locallyInitialized
-
gamemode
public int gamemode -
lastBreak
public long lastBreak -
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
正在挖掘的方块block being dig
-
breakingBlockFace
正在挖掘的方向direction of dig
-
pickedXPOrb
public int pickedXPOrb -
fishing
-
lastSkinChange
public long lastSkinChange -
breakingBlockTime
-
blockBreakProgress
-
interfaz
-
networkSession
-
windows
-
windowIndex
-
permanentWindows
-
rawSocketAddress
-
loadQueue
-
chunksPerTick
protected final int chunksPerTick -
spawnThreshold
protected final int spawnThreshold -
windowCnt
protected int windowCnt -
closingWindowId
-
messageCounter
protected int messageCounter -
playerUIInventory
-
craftingGrid
-
craftingTransaction
-
enchantTransaction
-
repairItemTransaction
-
grindstoneTransaction
-
smithingTransaction
-
tradingTransaction
-
randomClientId
protected long randomClientId -
forceMovement
@Deprecated @DeprecationDetails(since="1.19.60-r1", reason="Useless, use teleport directly") protected Vector3 forceMovementDeprecated. -
teleportPosition
@Deprecated @DeprecationDetails(since="1.19.60-r1", reason="Useless, use teleport directly") protected Vector3 teleportPositionDeprecated. -
connected
protected boolean connected -
socketAddress
-
removeFormat
protected boolean removeFormat是否移除改玩家聊天中的颜色字符如 §c §1Whether to remove the color character in the chat of the changed player as §c §1
-
username
-
iusername
-
displayName
-
RESOURCE_PACK_CHUNK_SIZE
protected static final int RESOURCE_PACK_CHUNK_SIZE- See Also:
-
startAction
protected int startAction -
sleeping
-
clientID
-
chunkLoadCount
protected int chunkLoadCount -
nextChunkOrderRun
protected int nextChunkOrderRun -
newPosition
-
chunkRadius
protected int chunkRadius -
viewDistance
protected int viewDistance -
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
-
checkMovement
protected boolean checkMovement -
foodData
-
enableClientCommand
protected boolean enableClientCommand -
lastEnderPearl
protected int lastEnderPearl -
lastChorusFruitTeleport
protected int lastChorusFruitTeleport -
formWindowCount
protected int formWindowCount -
formWindows
-
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
-
shouldLogin
protected boolean shouldLogin -
lastRightClickTime
protected double lastRightClickTime -
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
-
verified
protected boolean verified -
loginChainData
-
lastPlayerdLevelUpSoundTime
玩家升级时播放音乐的时间Time to play sound when player upgrades
-
lastAttackEntity
玩家最后攻击的实体.The entity that the player attacked last.
-
fogStack
玩家迷雾设置Player Fog Settings
-
lastBeAttackEntity
最后攻击玩家的实体.The entity that the player is attacked last.
-
flySneaking
-
-
Constructor Details
-
Player
单元测试用的构造函数Constructor for unit testing
- Parameters:
interfaz
- interfazclientID
- clientIDip
- IP地址port
- 端口
-
Player
-
-
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 classEntityHuman
-
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 classEntity
-
checkBlockCollision
protected void checkBlockCollision()- Overrides:
checkBlockCollision
in classEntity
-
checkNearEntities
protected void checkNearEntities() -
handleMovement
-
offerMovementTask
-
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
-
processLogin
protected void processLogin()处理LOGIN_PACKET中执行 -
completeLoginSequence
protected void completeLoginSequence()异步登录任务成功完成后执行 -
onPlayerLocallyInitialized
玩家客户端初始化完成后调用 -
isValidRespawnBlock
判断重生锚是否有效如果重生锚有效则在重生锚上重生或者在床上重生 如果玩家以上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 classEntity
-
sendPlayStatus
protected void sendPlayStatus(int status) -
sendPlayStatus
protected void sendPlayStatus(int status, boolean immediate) -
forceSendEmptyChunks
protected void forceSendEmptyChunks() -
removeWindow
-
addDefaultWindows
protected void addDefaultWindows() -
getBaseOffset
protected float getBaseOffset()Description copied from class:EntityHuman
偏移客户端传输玩家位置的y轴误差- Overrides:
getBaseOffset
in classEntityHuman
- Returns:
- the base offset
-
onBlock
- Overrides:
onBlock
in classEntityHuman
-
getStepHeight
public double getStepHeight()- Overrides:
getStepHeight
in classEntity
-
getLastAttackEntity
- Returns:
lastAttackEntity
-
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() -
stopAction
public void stopAction()设置startAction
值为-1Set 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
返回lastInAirTick
的值,代表玩家上次在空中的server tickReturns the value of
lastInAirTick
,represent the last server tick the player was in the air- Returns:
- int
-
onChorusFruitTeleport
public void onChorusFruitTeleport() -
getViewingEnderChest
返回viewingEnderChest
的值,只在玩家打开末影箱时有效.Returns the value of
viewingEnderChest
, which is only valid when the player opens the Ender Chest. -
setViewingEnderChest
设置viewingEnderChest
值为chestSet the
viewingEnderChest
value to chest- Parameters:
chest
- BlockEnderChest
-
getLeaveMessage
获取玩家离开的消息- Returns:
TranslationContainer
-
getClientSecret
-
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. -
setBanned
public void setBanned(boolean value) Description copied from interface:IPlayer
设置这个玩家是否被封禁(ban)。
Sets this player to be banned or to be pardoned. -
isWhitelisted
public boolean isWhitelisted()Description copied from interface:IPlayer
返回这个玩家是否已加入白名单。
Returns if this player is pardoned by whitelist.- Specified by:
isWhitelisted
in interfaceIPlayer
- 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 interfaceIPlayer
- Parameters:
value
- 如果为true
,把玩家加入白名单。如果为false
,取消这个玩家的白名单。
true
for add andfalse
for remove.- See Also:
-
getPlayer
Description copied from interface:IPlayer
得到这个接口的Player
对象。
Returns aPlayer
object for this interface. -
getFirstPlayed
Description copied from interface:IPlayer
得到这个玩家第一次游戏的时间。
Returns the time this player first played in this server.- Specified by:
getFirstPlayed
in interfaceIPlayer
- Returns:
- Unix时间(以秒为单位。
Unix time in seconds.
-
getLastPlayed
Description copied from interface:IPlayer
得到这个玩家上次加入游戏的时间。
Returns the time this player last joined in this server.- Specified by:
getLastPlayed
in interfaceIPlayer
- 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 interfaceIPlayer
- Returns:
- 这个玩家以前是不是玩过游戏。
If this player has played in this server before.
-
getAdventureSettings
获得玩家权限设置.Get player permission settings.
-
setAdventureSettings
用于设置玩家权限,对应游戏中的玩家权限设置.Used to set player permissions, corresponding to the game's player permissions settings.
- Parameters:
adventureSettings
- 玩家权限设置
player permissions settings
-
resetInAirTicks
public void resetInAirTicks()设置inAirTicks
为0Set
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
Description copied from class:Entity
将这个实体在客户端生成,让该玩家可以看到它Spawn this entity on the client side so that the player can see it
- Overrides:
spawnTo
in classEntityHuman
- Parameters:
player
- the player
-
getServer
Description copied from interface:CommandSender
返回命令发送者所在的服务器.Returns the server of the command sender.
-
getRemoveFormat
public boolean getRemoveFormat()得到removeFormat
get
removeFormat
- Returns:
- boolean
-
setRemoveFormat
public void setRemoveFormat(boolean remove) 设置removeFormat
为指定值- Parameters:
remove
- 是否清楚格式化字符
Whether remove the formatting character
-
setRemoveFormat
public void setRemoveFormat() -
canSee
- Parameters:
player
- 玩家- Returns:
- 是否可以看到该玩家
Whether the player can be seen
-
hidePlayer
从当前玩家实例的视角中隐藏指定玩家playerHide the specified player from the view of the current player instance
- Parameters:
player
- 要隐藏的玩家
Players who want to hide
-
showPlayer
从当前玩家实例的视角中显示指定玩家playerShow the specified player from the view of the current player instance
- Parameters:
player
- 要显示的玩家
Players who want to show
-
canCollideWith
- Overrides:
canCollideWith
in classEntity
-
canCollide
public boolean canCollide()- Overrides:
canCollide
in classEntity
-
resetFallDistance
public void resetFallDistance()- Overrides:
resetFallDistance
in classEntity
-
isOnline
public boolean isOnline()Description copied from 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 interfaceServerOperator
- 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 interfaceServerOperator
- Parameters:
value
-true
为授予管理员,false
为取消管理员。
true
for giving this operator orfalse
for cancelling.
-
isPermissionSet
- Specified by:
isPermissionSet
in interfacePermissible
-
isPermissionSet
- Specified by:
isPermissionSet
in interfacePermissible
-
hasPermission
- Specified by:
hasPermission
in interfacePermissible
-
hasPermission
- Specified by:
hasPermission
in interfacePermissible
-
addAttachment
- Specified by:
addAttachment
in interfacePermissible
-
addAttachment
- Specified by:
addAttachment
in interfacePermissible
-
addAttachment
- Specified by:
addAttachment
in interfacePermissible
-
removeAttachment
- Specified by:
removeAttachment
in interfacePermissible
-
recalculatePermissions
public void recalculatePermissions()- Specified by:
recalculatePermissions
in interfacePermissible
-
isEnableClientCommand
public boolean isEnableClientCommand() -
setEnableClientCommand
public void setEnableClientCommand(boolean enable) -
sendCommandData
public void sendCommandData() -
getEffectivePermissions
- Specified by:
getEffectivePermissions
in interfacePermissible
-
isPlayer
public boolean isPlayer()- Specified by:
isPlayer
in interfaceCommandSender
- Returns:
- 发送者是否为玩家
whether the sender is an player
-
asPlayer
Description copied from interface:CommandSender
如果发送者是一个玩家,返回执行该命令的玩家.return the player who execute the command if the sender is a player.
- Specified by:
asPlayer
in interfaceCommandSender
- 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 interfaceCommandSender
- Returns:
- 发送者是否为实体
whether the sender is an entity
-
asEntity
Description copied from interface:CommandSender
如果发送者是一个实体,返回执行该命令的实体.return the entity who execute the command if the sender is a entity.
- Specified by:
asEntity
in interfaceCommandSender
- Returns:
- 实体对象
Entity instance
-
removeAchievement
-
hasAchievement
-
isConnected
public boolean isConnected() -
getDisplayName
得到该玩家的显示名称Get the display name of the player
- Returns:
displayName
-
setDisplayName
只是改变玩家聊天时和在服务器玩家列表中的显示名(不影响命令的玩家参数名,也不影响玩家头顶显示名称)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
- Specified by:
setSkin
in interfaceIHuman
- Overrides:
setSkin
in classEntityHuman
-
getRawAddress
得到原始地址- Returns:
String
-
getRawPort
public int getRawPort()得到原始端口- Returns:
- int
-
getRawSocketAddress
得到原始套接字地址- Returns:
InetSocketAddress
-
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
得到套接字地址,如果开启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
获得下一个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
获得移动设备玩家面对载具时出现的交互按钮的语言硬编码。Get the language hardcoded for the interaction buttons that appear when mobile device players face the carrier.
-
setButtonText
设置移动设备玩家面对载具时出现的交互按钮的语言硬编码。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
-
isInOverWorld
public boolean isInOverWorld()- Returns:
- 玩家是否在主世界(维度为0)
Is the player in the world(Dimension equal 0)
-
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
设置保存玩家重生位置的方块的位置。当未知时可能为空。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
-
sendChunk
public void sendChunk(int x, int z, int subChunkCount, byte[] payload) -
updateTrackingPositions
-
updateTrackingPositions
-
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
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
-
stopSleep
public void stopSleep() -
awardAchievement
-
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 -
setGamemode
-
setGamemode
public boolean setGamemode(int gamemode, boolean serverSide, AdventureSettings newSettings, boolean forceUpdate) 设置gamemode- Parameters:
gamemode
- 要设置的玩家游戏模式serverSide
- 是否只更新服务端侧玩家游戏模式。若为true,则不会向客户端发送游戏模式更新包newSettings
- 新的AdventureSettingsforceUpdate
- 是否强制更新。若为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
- Overrides:
getDrops
in classEntityHumanType
-
fastMove
public boolean fastMove(double dx, double dy, double dz) -
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 classEntityHuman
- Parameters:
x
- xy
- yz
- zyaw
- 左右旋转pitch
- 上下旋转headYaw
- headYaw
-
setMotion
每次调用此方法都会向客户端发送motion包。若多次调用,motion将在客户端叠加 -
sendAttributes
public void sendAttributes() -
sendFogStack
将迷雾设定发送到客户端 -
sendCameraPresets
-
onUpdate
@PowerNukkitXDifference(info="Calculate fall distance when wearing elytra", since="1.19.60-r1") public boolean onUpdate(int currentTick) -
entityBaseTick
public boolean entityBaseTick(int tickDiff) - Overrides:
entityBaseTick
in classEntityHuman
-
checkInteractNearby
public void checkInteractNearby()检查附近可交互的实体(插件一般不使用)Check for nearby interactable entities (not generally used by plugins)
-
getEntityPlayerLookingAt
返回玩家目前正在看的实体。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
-
canInteract
-
handleDataPacket
@PowerNukkitXDifference(since="1.19.70-r1", info="Use new packet id system.") public void handleDataPacket(DataPacket packet) -
chat
以该玩家的身份发送一条聊天信息。如果消息以/(正斜杠)开头,它将被视为一个命令。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 -
kick
-
kick
-
kick
-
kick
-
kick
-
kick
踢出该玩家Kick out the player
- Parameters:
reason
- 原因枚举
Cause EnumerationreasonString
- 原因字符串
Reason StringisAdmin
- 是否来自管理员踢出
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
Description copied from interface:CommandSender
给命令发送者返回信息.Sends a message to the command sender.
- Specified by:
sendMessage
in interfaceCommandSender
- Parameters:
message
- 要发送的信息.
Message to send.- See Also:
-
sendMessage
Description copied from interface:CommandSender
给命令发送者返回信息.Sends a message to the command sender.
- Specified by:
sendMessage
in interfaceCommandSender
- 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 interfaceCommandSender
- Parameters:
container
- the container
-
sendRawTextMessage
在玩家聊天栏发送一个JSON文本Send a JSON text in the player chat bar
- Parameters:
text
- JSON文本
Json text
-
sendTranslation
- See Also:
-
sendTranslation
在玩家聊天栏发送一个多语言翻译文本,示例: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
- See Also:
-
sendChat
在玩家聊天栏发送一个文本Send a text in the player chat bar
- Parameters:
message
- 消息
-
sendPopup
- See Also:
-
sendPopup
在玩家物品栏上方发送一个弹出式的文本Send a pop-up text above the player's item bar
- Parameters:
message
- 消息
-
sendTip
在玩家物品栏上方发送一个提示文本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
设置副标题,在主标题下方显示。Set subtitle to be displayed below the main title.
- Parameters:
subtitle
- 副标题
-
setRawTextSubTitle
设置一个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
设置一个JSON文本标题。Set a JSON text title.
- Parameters:
text
- JSON文本
JSON text
-
sendTitle
subtitle=null,fadeIn=20,stay=20,fadeOut=5
- See Also:
-
sendTitle
fadeIn=20,stay=20,fadeOut=5
- See Also:
-
sendTitle
在玩家视角正中央发送一个标题文本。Send a title text in the center of the player's view.
- Parameters:
title
- 标题subtitle
- 副标题fadeIn
- 淡入时间
fadeIn time(tick)stay
- 持续时间
stay timefadeOut
- 淡出时间
fadeOut time
-
sendActionBar
fadein=1,duration=0,fadeout=1- See Also:
-
sendActionBar
在玩家物品栏上方发送一个ActionBar消息。Send a ActionBar text above the player's item bar.
- Parameters:
title
- 消息fadein
- 淡入时间duration
- 持续时间fadeout
- 淡出时间
-
setRawTextActionBar
fadein=1,duration=0,fadeout=1 -
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 textfadein
- 淡入时间duration
- 持续时间fadeout
- 淡出时间
-
close
public void close()- Overrides:
close
in classEntityHuman
-
close
notify=true
- See Also:
-
close
notify=true
- See Also:
-
close
- See Also:
-
close
reason="generic",notify=true
- See Also:
-
close
notify=true- See Also:
-
close
关闭该玩家的连接及其一切活动,和kick()
差不多效果,区别在于kick()
是基于close
实现的。Closing the player's connection and all its activities is almost as function as
kick()
, the difference is thatkick()
is implemented based onclose
.- Parameters:
message
- PlayerQuitEvent事件消息
PlayerQuitEvent messagereason
- 登出原因
Reason for logoutnotify
- 是否显示登出画面通知
Whether to display the logout screen notification
-
save
public void save() -
saveNBT
public void saveNBT()- Overrides:
saveNBT
in classEntityHuman
-
save
public void save(boolean async) -
getOriginalName
Description copied from class:Entity
The name that English name of the type of this entity.- Overrides:
getOriginalName
in classEntityHuman
-
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 interfaceCommandSender
- Specified by:
getName
in interfaceIPlayer
- Overrides:
getName
in classEntityHuman
- Returns:
- 命令发送者的名称.
the name of the command sender. - See Also:
-
getLanguageCode
-
kill
public void kill()- Overrides:
kill
in classEntityLiving
-
setHealth
public void setHealth(float health) - Overrides:
setHealth
in classEntityLiving
-
setMaxHealth
public void setMaxHealth(int maxHealth) - Overrides:
setMaxHealth
in classEntity
-
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
增加该玩家的经验值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
设置该玩家的经验值和等级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
以指定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 classEntityLiving
- 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 isDEFAULT_SPEED
send
- 是否发送数据包UpdateAttributesPacket
到客户端
Whether to sendUpdateAttributesPacket
to the client
-
sendMovementSpeed
发送Attribute.MOVEMENT_SPEED
属性到客户端Send
Attribute.MOVEMENT_SPEED
Attribute to Client.- Parameters:
speed
- 属性值
the speed value
-
getKiller
获取击杀该玩家的实体Get the entity that killed this player
- Returns:
- Entity | null
-
attack
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 classEntityHumanType
- Parameters:
source
- 记录伤害源的事件
Record the event of the source of the attack- Returns:
- 是否攻击成功
Whether the attack was successful
-
dropItem
在玩家面前的地面上掉落一个物品。如果物品投放成功,则返回。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
在玩家面前的地面上扔下一个物品。返回值为该掉落的物品。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
-
sendPosition
-
sendPosition
-
sendPosition
-
sendPosition
- Parameters:
pos
- the pos of MovePlayerPacketyaw
- the yaw of MovePlayerPacketpitch
- the pitch of MovePlayerPacketmode
- the mode of MovePlayerPackettargets
- 接受数据包的玩家们
players of receive the packet
-
teleport
-
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
Automatic id assignment- See Also:
-
showFormWindow
向玩家显示一个新的FormWindow。 你可以通过监听PlayerFormRespondedEvent来了解FormWindow的结果。Shows a new FormWindow to the player You can find out FormWindow result by listening to PlayerFormRespondedEvent
- Parameters:
window
- to showid
- form id- Returns:
- form id to use in
PlayerFormRespondedEvent
-
showDialogWindow
book=true -
showDialogWindow
向玩家展示一个NPC对话框.Show dialog window to the player.
- Parameters:
dialog
- NPC对话框
the dialogbook
- 如果为true,将会立即更新该FormWindowDialog.getSceneName()
If true, theFormWindowDialog.getSceneName()
will be updated immediately.
-
addServerSettings
在游戏设置中显示一个新的设置页面。 你可以通过监听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.创建并发送一个BossBar给玩家。Creates and sends a BossBar to the player
- Parameters:
text
- BossBar信息
The BossBar messagelength
- 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
创建并发送一个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
获取一个DummyBossBar对象Get a DummyBossBar object
- Parameters:
bossBarId
- 要查找的BossBar ID
The BossBar ID- Returns:
- DummyBossBar对象
DummyBossBar object - See Also:
-
getDummyBossBars
获取所有DummyBossBar对象Get all DummyBossBar objects
- Returns:
- DummyBossBars Map
-
updateBossBar
Deprecated.更新一个BossBarUpdates a BossBar
- Parameters:
text
- The new BossBar messagelength
- The new BossBar lengthbossBarId
- The BossBar ID
-
removeBossBar
public void removeBossBar(long bossBarId) 移除一个BossBarRemoves a BossBar
- Parameters:
bossBarId
- The BossBar ID
-
getWindowId
- Parameters:
inventory
- the inventory- Returns:
- the window id
-
getWindowById
- Parameters:
id
- 窗口id
the window id
-
addWindow
forceId=null isPermanent=false alwaysOpen = false
-
addWindow
isPermanent=false alwaysOpen = false
-
addWindow
alwaysOpen = false -
addWindow
@Since("1.4.0.0-PN") public int addWindow(Inventory inventory, Integer forceId, boolean isPermanent, boolean alwaysOpen) 添加一个Inventory
窗口显示到该玩家- Parameters:
inventory
- 这个库存窗口
the inventoryforceId
- 强制指定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 inpermanentWindows
alwaysOpen
- 如果为true即使玩家未spawned
也会添加改玩家为指定inventory的viewer
If true, even if the player is notspawned
, 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 viawindowIndex
-
getTopWindow
-
removeWindow
移除该玩家身上的指定InventoryRemove the specified Inventory from the player
- Parameters:
inventory
- the inventory
-
sendAllInventories
public void sendAllInventories()常用于刷新。Commonly used for refreshing.
-
getUIInventory
获取该玩家的PlayerUIInventory
Gets ui inventory of the player.
-
getCursorInventory
获取该玩家的PlayerCursorInventory
Gets cursor inventory of the player.
-
getCraftingGrid
获取该玩家的CraftingGrid
Gets crafting grid of the player.
-
setCraftingGrid
设置该玩家的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 inpermanentWindows
-
getClosingWindowId
获取上一个关闭窗口对应的idGet the id corresponding to the last closed window
-
setMetadata
- Specified by:
setMetadata
in interfaceMetadatable
- Overrides:
setMetadata
in classEntity
-
getMetadata
- Specified by:
getMetadata
in interfaceMetadatable
- Overrides:
getMetadata
in classEntity
-
hasMetadata
- Specified by:
hasMetadata
in interfaceMetadatable
- Overrides:
hasMetadata
in classEntity
-
removeMetadata
- Specified by:
removeMetadata
in interfaceMetadatable
- Overrides:
removeMetadata
in classEntity
-
onChunkChanged
- Specified by:
onChunkChanged
in interfaceChunkLoader
-
onChunkLoaded
- Specified by:
onChunkLoaded
in interfaceChunkLoader
-
onChunkPopulated
- Specified by:
onChunkPopulated
in interfaceChunkLoader
-
onChunkUnloaded
- Specified by:
onChunkUnloaded
in interfaceChunkLoader
-
onBlockChanged
- Specified by:
onBlockChanged
in interfaceChunkLoader
-
getLoaderId
public int getLoaderId()- Specified by:
getLoaderId
in interfaceChunkLoader
-
isLoaderActive
public boolean isLoaderActive()- Specified by:
isLoaderActive
in interfaceChunkLoader
-
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
获取玩家的PlayerFood
Get the player's
PlayerFood
- Returns:
- the food data
-
switchLevel
- Overrides:
switchLevel
in classEntity
-
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
-
setLocale
-
setSprinting
public void setSprinting(boolean value) - Overrides:
setSprinting
in classEntity
-
transfer
传送该玩家到另一个服务器Teleport the player to another server
- Parameters:
address
- the address
-
getLoginChainData
获取该玩家的登录链数据Get the login chain data of this player
- Returns:
- the login chain data
-
pickupEntity
-
hashCode
public int hashCode() -
equals
-
isBreakingBlock
public boolean isBreakingBlock()玩家是否在挖掘方块Whether the player is digging block
- Returns:
- the boolean
-
showXboxProfile
显示一个XBOX账户的资料窗口Show a window of a XBOX account's profile
- Parameters:
xuid
- XUID
-
startFishing
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 forEntityBat
s only.- Overrides:
doesTriggerPressurePlate
in classEntity
- Returns:
- triggers pressure plate
-
getNoShieldTicks
-
setNoShieldTicks
-
toString
-
giveItem
将物品添加到玩家的主要库存中,并将任何多余的物品丢在地上。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
-
setTimeSinceRest
-
getNetworkSession
-
sendPopupJukebox
-
sendSystem
-
sendWhisper
-
sendWhisper
-
sendAnnouncement
-
sendAnnouncement
-
completeUsingItem
-
isShowingCredits
-
setShowingCredits
-
showCredits
-
hasSeenCredits
-
setHasSeenCredits
-
dataPacketImmediately
-
dataResourcePacket
-
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 intensityduration
- the durationshakeType
- the shake typeshakeAction
- 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 downitemCategory
- the item category
-
sendToast
发送一个下弹消息框给玩家Send a Toast message box to the player
- Parameters:
title
- the titlecontent
- the content
-
removeLine
Description copied from interface:IScoreboardViewer
通知观察者指定计分板上的指定行已删除- Specified by:
removeLine
in interfaceIScoreboardViewer
- Parameters:
line
- 目标行
-
updateScore
Description copied from interface:IScoreboardViewer
向观察者发送指定行的新分数- Specified by:
updateScore
in interfaceIScoreboardViewer
- 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 interfaceIScoreboardViewer
- Parameters:
scoreboard
- 目标计分板slot
- 目标槽位
-
hide
Description copied from interface:IScoreboardViewer
清除指定槽位的显示内容- Specified by:
hide
in interfaceIScoreboardViewer
- Parameters:
slot
- 目标槽位
-
removeScoreboard
Description copied from interface:IScoreboardViewer
通知观察者计分板已删除(若计分板在任意显示槽位中,则会一并清除槽位)- Specified by:
removeScoreboard
in interfaceIScoreboardViewer
- Parameters:
scoreboard
- 目标计分板
-
isOpenSignFront
-
setOpenSignFront
-
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
-
isFlySneaking
-
getFogStack
玩家迷雾设置Player Fog Settings
-
setFogStack
玩家迷雾设置Player Fog Settings
-