Package cn.nukkit
Class Player
- All Implemented Interfaces:
CommandSender
,EntityAgeable
,EntityDamageable
,EntityNameable
,InventoryHolder
,IPlayer
,ChunkLoader
,Metadatable
,Permissible
,ServerOperator
,IScoreboardViewer
,Cloneable
public class Player
extends EntityHuman
implements CommandSender, InventoryHolder, ChunkLoader, IPlayer, IScoreboardViewer
- Author:
- MagicDroidX & Box (Nukkit Project)
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
protected AdventureSettings
static final int
static final int
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.google.common.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 List<PlayerFogPacket.Fog>
玩家迷雾设置protected PlayerFood
protected Vector3
protected int
protected Map<Integer,
FormWindow> int
static final int
protected GrindstoneTransaction
protected int
protected final SourceInterface
protected String
protected Entity
玩家最后攻击的实体.protected Entity
最后攻击玩家的实体.long
protected int
protected int
protected int
protected Vector3
protected double
long
protected final it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap<Boolean>
boolean
boolean
static final float
protected int
protected final NetworkPlayerSession
protected Vector3
protected int
static final int
static final int
static final int
static final int
int
boolean
protected PlayerUIInventory
protected long
protected final InetSocketAddress
protected boolean
protected RepairItemTransaction
protected static final int
protected Map<Integer,
FormWindow> protected boolean
protected Vector3
static final int
protected SmithingTransaction
protected InetSocketAddress
protected Position
boolean
protected Position
protected final int
static final int
protected int
protected int
static final int
static final int
protected Vector3
static final int
protected TradingTransaction
protected String
static final int
protected int
protected int
Fields inherited from class cn.nukkit.entity.EntityHuman
DATA_PLAYER_BED_POSITION, DATA_PLAYER_BUTTON_TEXT, DATA_PLAYER_FLAG_DEAD, DATA_PLAYER_FLAG_SLEEP, DATA_PLAYER_FLAGS, 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_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_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_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_ROARING, DATA_FLAG_ROLLING, DATA_FLAG_SADDLED, DATA_FLAG_SCARED, 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_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, scale, server, temporalVector, ticksLived, timing, 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) void
addExperience
(int add, boolean playLevelUpSound) void
addMovement
(double x, double y, double z, double yaw, double pitch, double headYaw) int
addServerSettings
(FormWindow window) Shows a new setting page in game settings You can find out settings result by listening to PlayerFormRespondedEventint
int
int
int
asEntity()
asPlayer()
boolean
attack
(EntityDamageEvent source) 当一个实体被攻击时(即接受一个实体伤害事件 这个事件可以是由其他实体攻击导致,也可能是自然伤害)调用.boolean
awardAchievement
(String achievementId) boolean
batchDataPacket
(DataPacket packet) Deprecated.static int
calculateRequireExperience
(int level) boolean
canCollideWith
(Entity entity) boolean
canInteract
(Vector3 pos, double maxDistance) boolean
canInteract
(Vector3 pos, double maxDistance, double maxDiff) boolean
boolean
Sends a chat message as this player.protected void
protected void
protected void
checkGroundState
(double movX, double movY, double movZ, double dx, double dy, double dz) void
protected void
void
protected boolean
void
void
close()
void
close
(TextContainer message) void
close
(TextContainer message, String reason) void
close
(TextContainer message, String reason, boolean notify) void
void
void
protected void
void
completeUsingItem
(int itemId, int action) long
createBossBar
(DummyBossBar dummyBossBar) Creates and sends a BossBar to the playerlong
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
dropAndGetItem
(Item item) Drops an item on the ground in front of the player.boolean
Drops an item on the ground in front of the player.boolean
entityBaseTick
(int tickDiff) boolean
boolean
fastMove
(double dx, double dy, double dz) void
forceDataPacket
(DataPacket packet, Runnable callback) protected void
boolean
Deprecated.static BatchPacket
getChunkCacheFromData
(int chunkX, int chunkZ, int subChunkCount, byte[] payload) Deprecated.int
Item[]
getDrops()
getDummyBossBar
(long bossBarId) Get a DummyBossBar objectGet all DummyBossBar objectsgetEntityPlayerLookingAt
(int maxDistance) Returns the Entity the player is looking at currentlyint
int
得到这个玩家第一次游戏的时间。
Returns the time this player first played in this server.玩家迷雾设置int
int
int
int
得到这个玩家上次加入游戏的时间。
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.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
返回命令发送者所在的服务器。
Returns the server of the command sender.float
getSpawn()
The block that holds the player respawn position.int
double
int
int
getWindowById
(int id) int
getWindowId
(Inventory inventory) void
Adds the items to the main player inventory and drops on the floor any excess.void
handleDataPacket
(DataPacket packet) protected void
handleLogicInMove
(boolean invalidMotion, double distance, double delta) protected void
handleMovement
(Vector3 clientPos) boolean
hasAchievement
(String achievementId) boolean
Deprecated.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) protected void
boolean
boolean
isBanned()
返回这个玩家是否被封禁(ban)。
Returns if this player is banned.boolean
boolean
boolean
boolean
boolean
boolean
isEntity()
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
Returns whether the player is currently using an item (right-click and hold).protected boolean
isValidRespawnBlock
(Block block) 我们在玩家客户端初始化后才发送游戏模式,以解决观察者模式疾跑速度不正确的问题 只有在玩家客户端进入游戏显示后再设置观察者模式,疾跑速度才正常boolean
返回这个玩家是否已加入白名单。
Returns if this player is pardoned by whitelist.boolean
kick()
boolean
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
onBlock
(Entity entity, EntityDamageEvent e, boolean animate) 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) protected boolean
boolean
pickupEntity
(Entity entity, boolean near) protected void
protected void
processMovement
(int tickDiff) void
void
removeAchievement
(String achievementId) void
void
removeAllWindows
(boolean permanent) void
removeAttachment
(PermissionAttachment attachment) void
removeBossBar
(long bossBarId) Removes a BossBarvoid
removeLine
(IScoreboardLine line) 通知观察者指定计分板上的指定行已删除void
removeMetadata
(String metadataKey, Plugin owningPlugin) void
removeScoreboard
(IScoreboard scoreboard) 通知观察者计分板已删除(若计分板在任意显示槽位中,则会一并清除槽位)void
removeWindow
(Inventory inventory) protected void
removeWindow
(Inventory inventory, boolean isResponse) protected void
void
void
void
void
Resets both title animation times and subtitle for the next shown titleprotected void
respawn()
protected void
revertClientMotion
(Location originalPos) void
save()
void
save
(boolean async) void
saveNBT()
void
sendActionBar
(String title) void
sendActionBar
(String title, int fadein, int duration, int fadeout) void
void
sendAnnouncement
(String message) void
sendAnnouncement
(String source, String message) void
void
void
void
sendChunk
(int x, int z, int subChunkCount, byte[] payload) void
sendChunk
(int x, int z, DataPacket packet) void
void
void
sendExperience
(int exp) void
void
sendExperienceLevel
(int level) void
将迷雾设定发送到客户端void
sendMessage
(TextContainer message) 给命令发送者返回信息。
Sends a message to the command sender.void
sendMessage
(String message) 给命令发送者返回信息。
Sends a message to the command sender.void
sendMovementSpeed
(float 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) void
Deprecated.void
sendSystem
(String message) void
void
void
void
void
void
sendTranslation
(String message) void
sendTranslation
(String message, String[] parameters) void
sendWhisper
(String message) void
sendWhisper
(String source, String message) void
setAdventureSettings
(AdventureSettings adventureSettings) void
setAllowFlight
(boolean value) Deprecated.void
setAllowInteract
(boolean value) void
setAllowInteract
(boolean value, boolean containers) void
setAllowModifyWorld
(boolean value) void
setAttribute
(Attribute attribute) void
setAutoJump
(boolean value) Deprecated.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) void
setDisplayName
(String displayName) void
setEnableClientCommand
(boolean enable) void
setExperience
(int exp) void
setExperience
(int exp, int level) void
setExperience
(int exp, int level, boolean playLevelUpSound) void
setFogStack
(List<PlayerFogPacket.Fog> fogStack) 玩家迷雾设置void
setFoodEnabled
(boolean foodEnabled) boolean
setGamemode
(int gamemode) boolean
setGamemode
(int gamemode, boolean serverSide) boolean
setGamemode
(int gamemode, boolean serverSide, AdventureSettings newSettings) boolean
setGamemode
(int gamemode, boolean serverSide, AdventureSettings newSettings, boolean forceUpdate) void
setHasSeenCredits
(boolean hasSeenCredits) void
setHealth
(float health) void
setItemCoolDown
(int coolDown, String itemCategory) void
void
setMaxHealth
(int maxHealth) void
setMetadata
(String metadataKey, MetadataValue newMetadataValue) boolean
void
setMovementSpeed
(float speed) void
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
setRawTextActionBar
(RawText text) void
setRawTextActionBar
(RawText text, int fadein, int duration, int fadeout) void
setRawTextSubTitle
(RawText text) void
setRawTextTitle
(RawText text) void
void
setRemoveFormat
(boolean remove) void
setShowingCredits
(boolean showingCredits) void
void
void
setSpawnBlock
(Position spawnBlock) void
setSpawnBlock
(Vector3 spawnBlock) Sets the position of the block that holds the player respawn position.void
setSprinting
(boolean value) void
setSubtitle
(String subtitle) void
setTimeSinceRest
(int timeSinceRest) void
setTitleAnimationTimes
(int fadein, int duration, int fadeout) void
setUsingItem
(boolean value) void
setViewDistance
(int distance) void
void
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) void
showDialogWindow
(FormWindowDialog dialog, boolean book) int
showFormWindow
(FormWindow window) Shows a new FormWindow to the player You can find out FormWindow result by listening to PlayerFormRespondedEventint
showFormWindow
(FormWindow window, int id) Shows a new FormWindow to the player You can find out FormWindow result by listening to PlayerFormRespondedEventvoid
showPlayer
(Player player) void
showXboxProfile
(String xuid) Show a window of a XBOX account's profileboolean
void
void
void
startFishing
(Item fishingRod) Start fishingvoid
void
stopFishing
(boolean click) Stop fishingvoid
boolean
switchLevel
(Level level) boolean
teleport
(Location location, PlayerTeleportEvent.TeleportCause cause) void
teleportImmediate
(Location location) void
teleportImmediate
(Location location, PlayerTeleportEvent.TeleportCause cause) 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, getBaseOffset, getEyeHeight, getHeight, getLength, getNetworkId, getRawUniqueId, getSkin, getSwimmingHeight, getUniqueId, getWidth
Methods inherited from class cn.nukkit.entity.EntityHumanType
applyNameTag, applyNameTag, calculateEnchantmentProtectionFactor, damageArmor, getEnderChestInventory, getInventory, getOffhandInventory, setOnFire
Methods inherited from class cn.nukkit.entity.EntityCreature
onInteract, playerApplyNameTag
Methods inherited from class cn.nukkit.entity.EntityLiving
blockedByShield, collidingWith, entityBaseTick, 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, canClimb, canClimbWalls, canCollide, canPassThrough, canTriggerWalking, checkObstruction, collideWithBlock, containTag, createAddEntityPacket, 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, 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, heal, heal, 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, onPushByPiston, onStruckByLightning, 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, setCanClimb, setCanClimb, setCanClimbWalls, setCanClimbWalls, setDataFlag, setDataFlag, setDataProperty, setDataProperty, setFreezingEffectStrength, setFreezingTicks, setGliding, setGliding, setImmobile, setImmobile, 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, setYaw, subtract, subtract, subtract, subtract, subtract
Methods inherited from class cn.nukkit.level.Position
getChunk, getLevel, getLevelBlock, getLevelBlock, getLevelBlock, getLevelBlockAround, getLevelBlockAtLayer, getLevelBlockEntity, getLevelBlockState, getLevelBlockState, getLevelName, getSide, getSide, 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, setX, setY, setZ, 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.inventory.InventoryHolder
getInventory
Methods inherited from interface cn.nukkit.IPlayer
getUniqueId
-
Field Details
-
EMPTY_ARRAY
-
SURVIVAL
public static final int SURVIVAL- See Also:
-
CREATIVE
public static final int CREATIVE- See Also:
-
ADVENTURE
public static final int ADVENTURE- See Also:
-
SPECTATOR
public static final int SPECTATOR- See Also:
-
VIEW
public static final int VIEW- See Also:
-
SURVIVAL_SLOTS
public static final int SURVIVAL_SLOTS- See Also:
-
CREATIVE_SLOTS
public static final int CREATIVE_SLOTS- See Also:
-
CRAFTING_SMALL
public static final int CRAFTING_SMALL- See Also:
-
CRAFTING_BIG
public static final int CRAFTING_BIG- See Also:
-
CRAFTING_ANVIL
public static final int CRAFTING_ANVIL- See Also:
-
CRAFTING_ENCHANT
public static final int CRAFTING_ENCHANT- See Also:
-
CRAFTING_BEACON
public static final int CRAFTING_BEACON- See Also:
-
CRAFTING_GRINDSTONE
- See Also:
-
CRAFTING_STONECUTTER
- See Also:
-
CRAFTING_CARTOGRAPHY
- See Also:
-
CRAFTING_SMITHING
- See Also:
-
TRADE_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
-
RESOURCE_PACK_CHUNK_SIZE
- See Also:
-
achievements
-
usedChunks
-
interfaz
-
networkSession
-
windows
-
windowIndex
-
permanentWindows
-
rawSocketAddress
-
loadQueue
-
chunksPerTick
protected final int chunksPerTick -
spawnThreshold
protected final int spawnThreshold -
playedBefore
public boolean playedBefore -
spawned
public boolean spawned -
loggedIn
public boolean loggedIn -
locallyInitialized
-
gamemode
public int gamemode -
lastBreak
public long lastBreak -
speed
-
craftingType
public int craftingType -
creationTime
public long creationTime -
breakingBlock
-
pickedXPOrb
public int pickedXPOrb -
fishing
-
lastSkinChange
public long lastSkinChange -
windowCnt
protected int windowCnt -
closingWindowId
-
messageCounter
protected int messageCounter -
playerUIInventory
-
craftingGrid
-
craftingTransaction
-
enchantTransaction
-
repairItemTransaction
-
grindstoneTransaction
-
smithingTransaction
-
tradingTransaction
-
randomClientId
protected long randomClientId -
forceMovement
-
teleportPosition
-
connected
protected boolean connected -
socketAddress
-
removeFormat
protected boolean removeFormat -
username
-
iusername
-
displayName
-
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
-
inAirTicks
protected int inAirTicks -
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.google.common.cache.Cache<String,FormWindowDialog> dialogWindows我们使用google的cache来存储NPC对话框发送信息 原因是发送过去的对话框客户端有几率不响应,在特定情况下我们无法清除这些对话框,这会导致内存泄漏 5分钟后未响应的对话框会被清除 -
dummyBossBars
-
shouldLogin
protected boolean shouldLogin -
lastRightClickTime
protected double lastRightClickTime -
lastRightClickPos
-
lastPlayerdLevelUpSoundTime
-
lastAttackEntity
玩家最后攻击的实体.The entity that the player attacked last.
-
lastBeAttackEntity
最后攻击玩家的实体.The entity that the player is attacked last.
-
fogStack
玩家迷雾设置Player Fog Settings
-
-
Constructor Details
-
Player
-
Player
-
-
Method Details
-
calculateRequireExperience
public static int calculateRequireExperience(int level) -
getChunkCacheFromData
public static BatchPacket getChunkCacheFromData(int chunkX, int chunkZ, int subChunkCount, byte[] payload) -
sendNextChunk
protected void sendNextChunk() -
initEntity
protected void initEntity()- Overrides:
initEntity
in classEntityHuman
-
doFirstSpawn
protected void doFirstSpawn() -
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
-
processMovement
protected void processMovement(int tickDiff) -
handleLogicInMove
protected void handleLogicInMove(boolean invalidMotion, double distance, double delta) -
resetClientMovement
protected void resetClientMovement() -
revertClientMotion
-
processLogin
protected void processLogin() -
completeLoginSequence
protected void completeLoginSequence() -
onPlayerLocallyInitialized
玩家客户端初始化完成后调用 -
isValidRespawnBlock
我们在玩家客户端初始化后才发送游戏模式,以解决观察者模式疾跑速度不正确的问题 只有在玩家客户端进入游戏显示后再设置观察者模式,疾跑速度才正常 -
respawn
@PowerNukkitDifference(info="will force using the spawnposition if the value spawnBlock is null,to fix the bug of command /spawnpoint", since="1.6.0.0-PNX") protected void respawn() -
checkChunks
protected void checkChunks()- Overrides:
checkChunks
in classEntity
-
checkTeleportPosition
protected boolean checkTeleportPosition() -
sendPlayStatus
protected void sendPlayStatus(int status) -
sendPlayStatus
protected void sendPlayStatus(int status, boolean immediate) -
forceSendEmptyChunks
protected void forceSendEmptyChunks() -
removeWindow
-
addDefaultWindows
protected void addDefaultWindows() -
onBlock
- Overrides:
onBlock
in classEntityHuman
-
getStepHeight
public double getStepHeight()- Overrides:
getStepHeight
in classEntity
-
getLastAttackEntity
- Returns:
lastAttackEntity
-
getLastBeAttackEntity
- Returns:
lastBeAttackEntity
-
getSoulSpeedMultiplier
public float getSoulSpeedMultiplier() -
getStartActionTick
public int getStartActionTick() -
startAction
public void startAction() -
stopAction
public void stopAction() -
getLastEnderPearlThrowingTick
public int getLastEnderPearlThrowingTick() -
onThrowEnderPearl
public void onThrowEnderPearl() -
getLastChorusFruitTeleport
public int getLastChorusFruitTeleport() -
onChorusFruitTeleport
public void onChorusFruitTeleport() -
getViewingEnderChest
-
setViewingEnderChest
-
getLeaveMessage
-
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
-
setAdventureSettings
-
resetInAirTicks
public void resetInAirTicks() -
getAllowFlight
Deprecated. -
setAllowFlight
Deprecated. -
setAllowModifyWorld
public void setAllowModifyWorld(boolean value) -
setAllowInteract
public void setAllowInteract(boolean value) -
setAllowInteract
public void setAllowInteract(boolean value, boolean containers) -
setAutoJump
Deprecated. -
hasAutoJump
Deprecated. -
spawnTo
- Overrides:
spawnTo
in classEntityHuman
-
getServer
Description copied from interface:CommandSender
返回命令发送者所在的服务器。
Returns the server of the command sender. -
getRemoveFormat
public boolean getRemoveFormat() -
setRemoveFormat
public void setRemoveFormat(boolean remove) -
setRemoveFormat
public void setRemoveFormat() -
canSee
-
hidePlayer
-
showPlayer
-
canCollideWith
- Overrides:
canCollideWith
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
-
asPlayer
- Specified by:
asPlayer
in interfaceCommandSender
-
isEntity
public boolean isEntity()- Specified by:
isEntity
in interfaceCommandSender
- Returns:
- whether the sender is an entity
please use this method to check whether the sender is an entity instead of using code"xxx instanceof Entity"
because the sender may not an instance of"Entity"
but in fact it is executing commands identity as an entity(eg:"ExecutorCommandSender"
)
-
asEntity
- Specified by:
asEntity
in interfaceCommandSender
-
removeAchievement
-
hasAchievement
-
isConnected
public boolean isConnected() -
getDisplayName
-
setDisplayName
-
setSkin
- Overrides:
setSkin
in classEntityHuman
-
getRawAddress
-
getRawPort
public int getRawPort() -
getRawSocketAddress
-
getAddress
-
getPort
public int getPort() -
getSocketAddress
-
getNextPosition
-
isSleeping
public boolean isSleeping() -
getInAirTicks
public int getInAirTicks() -
isUsingItem
public boolean isUsingItem()Returns whether the player is currently using an item (right-click and hold).- Returns:
- bool
-
setUsingItem
public void setUsingItem(boolean value) -
getButtonText
-
setButtonText
-
unloadChunk
public void unloadChunk(int x, int z) -
unloadChunk
-
isInOverWorld
public boolean isInOverWorld() -
getSpawn
-
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) -
getSpawnBlock
The block that holds the player respawn position. May be null when unknown.保存着玩家重生位置的方块。当未知时可能为空。
- Returns:
- The position of a bed, respawn anchor, or null when unknown.
床、重生锚的位置,如果未知,则为空。
-
setSpawnBlock
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
床或重生锚的位置
-
setSpawnBlock
-
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() -
sleepOn
-
stopSleep
public void stopSleep() -
awardAchievement
-
getGamemode
public int getGamemode() -
setGamemode
public boolean setGamemode(int gamemode) -
setGamemode
public boolean setGamemode(int gamemode, boolean serverSide) -
setGamemode
-
setGamemode
@PowerNukkitXDifference(since="1.19.50-r3", info="Implement the new spectator game mode") public boolean setGamemode(int gamemode, boolean serverSide, AdventureSettings newSettings, boolean forceUpdate) - Parameters:
gamemode
- 要设置的玩家游戏模式serverSide
- 是否只更新服务端侧玩家游戏模式。若为true,则不会向客户端发送游戏模式更新包newSettings
- 新的AdventureSettingsforceUpdate
- 是否强制更新。若为true,将取消对形参'gamemode'的检查- Returns:
-
sendSettings
Deprecated. -
isSurvival
public boolean isSurvival() -
isCreative
public boolean isCreative() -
isSpectator
public boolean isSpectator() -
isAdventure
public boolean isAdventure() -
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) - Overrides:
addMovement
in classEntityHuman
-
setMotion
-
sendAttributes
public void sendAttributes() -
sendFogStack
将迷雾设定发送到客户端 -
onUpdate
public boolean onUpdate(int currentTick) -
entityBaseTick
public boolean entityBaseTick(int tickDiff) - Overrides:
entityBaseTick
in classEntityLiving
-
checkInteractNearby
public void checkInteractNearby() -
getEntityPlayerLookingAt
Returns the Entity the player is looking at currently- Parameters:
maxDistance
- the maximum distance to check for entities- Returns:
- Entity|null either NULL if no entity is found or an instance of the entity
-
checkNetwork
public void checkNetwork() -
canInteract
-
canInteract
-
handleDataPacket
-
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() -
kick
-
kick
-
kick
-
kick
-
kick
-
kick
-
getViewDistance
public int getViewDistance() -
setViewDistance
public void setViewDistance(int distance) -
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.
-
sendRawTextMessage
-
sendTranslation
-
sendTranslation
-
sendChat
-
sendChat
-
sendPopup
-
sendPopup
-
sendTip
-
clearTitle
public void clearTitle() -
resetTitleSettings
public void resetTitleSettings()Resets both title animation times and subtitle for the next shown title -
setSubtitle
-
setRawTextSubTitle
-
setTitleAnimationTimes
public void setTitleAnimationTimes(int fadein, int duration, int fadeout) -
setRawTextTitle
-
sendTitle
-
sendTitle
-
sendTitle
-
sendActionBar
-
sendActionBar
-
setRawTextActionBar
-
setRawTextActionBar
@PowerNukkitXOnly @Since("1.6.0.0-PNX") public void setRawTextActionBar(RawText text, int fadein, int duration, int fadeout) -
close
public void close()- Overrides:
close
in classEntityHuman
-
close
-
close
-
close
-
close
-
close
-
close
-
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:
-
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() -
setExperience
public void setExperience(int exp) -
getExperienceLevel
public int getExperienceLevel() -
addExperience
public void addExperience(int add) -
addExperience
-
setExperience
public void setExperience(int exp, int level) -
setExperience
-
sendExperience
public void sendExperience() -
sendExperience
public void sendExperience(int exp) -
sendExperienceLevel
public void sendExperienceLevel() -
sendExperienceLevel
public void sendExperienceLevel(int level) -
setAttribute
-
setMovementSpeed
public void setMovementSpeed(float speed) - Overrides:
setMovementSpeed
in classEntityLiving
-
setMovementSpeed
public void setMovementSpeed(float speed, boolean send) -
sendMovementSpeed
-
getKiller
-
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 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 if the item was dropped or null if the item was null
-
sendPosition
-
sendPosition
-
sendPosition
-
sendPosition
-
sendPosition
-
teleport
-
teleportImmediate
-
teleportImmediate
-
showFormWindow
Shows a new FormWindow to the player You can find out FormWindow result by listening to PlayerFormRespondedEvent- Parameters:
window
- to show- Returns:
- form id to use in
PlayerFormRespondedEvent
-
showFormWindow
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
-
showDialogWindow
-
addServerSettings
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.Creates and sends a BossBar to the player- Parameters:
text
- The BossBar messagelength
- The BossBar percentage- Returns:
- bossBarId The BossBar ID, you should store it if you want to remove or update the BossBar later
-
createBossBar
Creates and sends a BossBar to the player- Parameters:
dummyBossBar
- DummyBossBar Object (Instantiate it by the Class Builder)- Returns:
- bossBarId The BossBar ID, you should store it if you want to remove or update the BossBar later
- See Also:
-
getDummyBossBar
Get a DummyBossBar object- Parameters:
bossBarId
- The BossBar ID- Returns:
- DummyBossBar object
- See Also:
-
getDummyBossBars
Get all DummyBossBar objects- Returns:
- DummyBossBars Map
-
updateBossBar
Deprecated.Updates a BossBar- Parameters:
text
- The new BossBar messagelength
- The new BossBar lengthbossBarId
- The BossBar ID
-
removeBossBar
public void removeBossBar(long bossBarId) Removes a BossBar- Parameters:
bossBarId
- The BossBar ID
-
getWindowId
-
getWindowById
-
addWindow
-
addWindow
-
addWindow
-
addWindow
-
getTopWindow
-
removeWindow
-
sendAllInventories
public void sendAllInventories() -
getUIInventory
-
getCursorInventory
-
getCraftingGrid
-
setCraftingGrid
-
resetCraftingGridType
public void resetCraftingGridType() -
removeAllWindows
public void removeAllWindows() -
removeAllWindows
public void removeAllWindows(boolean permanent) -
getClosingWindowId
-
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
-
isFoodEnabled
public boolean isFoodEnabled() -
setFoodEnabled
public void setFoodEnabled(boolean foodEnabled) -
getFoodData
-
switchLevel
- Overrides:
switchLevel
in classEntity
-
setCheckMovement
public void setCheckMovement(boolean checkMovement) -
isCheckingMovement
public boolean isCheckingMovement()- Since:
- 1.2.1.0-PN
-
getLocale
-
setLocale
-
setSprinting
public void setSprinting(boolean value) - Overrides:
setSprinting
in classEntity
-
transfer
-
getLoginChainData
-
pickupEntity
-
hashCode
public int hashCode() -
equals
-
isBreakingBlock
public boolean isBreakingBlock() -
showXboxProfile
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) -
setItemCoolDown
@PowerNukkitXOnly @Since("1.19.21-r4") public void setItemCoolDown(int coolDown, String itemCategory) -
sendToast
-
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
- 目标计分板
-
getFogStack
玩家迷雾设置Player Fog Settings
-
setFogStack
玩家迷雾设置Player Fog Settings
-