接口 Player
- 所有超级接口:
AnimalTamer
,Attributable
,CommandSender
,ConfigurationSerializable
,Conversable
,Damageable
,Entity
,HumanEntity
,InventoryHolder
,LivingEntity
,Metadatable
,Nameable
,OfflinePlayer
,Permissible
,PersistentDataHolder
,PluginMessageRecipient
,ProjectileSource
,ServerOperator
-
嵌套类概要
-
方法概要
修饰符和类型方法说明void
addCustomChatCompletions
(@NotNull Collection<String> completions) Add custom chat completion suggestions shown to the player while typing a message.void
addResourcePack
(@NotNull UUID id, @NotNull String url, @org.jetbrains.annotations.Nullable byte[] hash, @Nullable String prompt, boolean force) Request that the player's client download and include another resource pack.ban
(@Nullable String reason, @Nullable Duration duration, @Nullable String source, boolean kickPlayer) Adds this user to theProfileBanList
.ban
(@Nullable String reason, @Nullable Instant expires, @Nullable String source, boolean kickPlayer) Adds this user to theProfileBanList
.Adds this user to theProfileBanList
.banIp
(@Nullable String reason, @Nullable Duration duration, @Nullable String source, boolean kickPlayer) Adds this user's current IP address to theIpBanList
.banIp
(@Nullable String reason, @Nullable Instant expires, @Nullable String source, boolean kickPlayer) Adds this user's current IP address to theIpBanList
.Adds this user's current IP address to theIpBanList
.boolean
breakBlock
(@NotNull Block block) Force this player to break a Block using the item in their main hand.boolean
Checks to see if an entity has been visually hidden from this player.boolean
检查该玩家是否能看到某玩家.void
强制玩家发送一个聊天消息,或强制使用命令(需要在内容前加 "/").得到一个Address对象,包括这个玩家的IP以及登入端口.getAdvancementProgress
(@NotNull Advancement advancement) 返回玩家指定进度的完成进度.boolean
判断玩家是否能飞起来.已过时。Misleading name.int
Get the player's current client side view distance.得到玩家指南针的指向的位置(Location
).获得玩家在聊天信息中的昵称.float
getExp()
得到当前级别升到下一级别经验进度的百分比.int
Gets the player's cooldown between picking up experience orbs.float
得到该玩家飞行速度.double
获取客户端显示的血量的"压缩率".int
getLevel()
得到玩家的等级.返回玩家本地语言环境.getName()
返回该玩家的玩家名.int
getPing()
Gets the player's estimated ping in milliseconds.Gets the currently displayed player list footer for this player.Gets the currently displayed player list header for this player.得到玩家显示在tab列表中的名称.long
得到玩家的客户端的当前时间,单位为tick.long
返回玩家的客户端的当前时间与玩家当前世界时间的差值.得到玩家所看到的天气.如果返回null,玩家的天气跟世界的天气一致.Gets this player's previousGameMode
Gets the Location where the player will spawn at, null if they don't have a valid respawn point.获取玩家的计分板.获取旁观者模式下镜头跟随的实体.int
得到玩家总共获得了多少经验(等级和经验).float
得到行走速度.Gets theWorldBorder
visible to this Player, or null if viewing the world's world border.void
giveExp
(int amount) 给玩家指定经验.void
giveExpLevels
(int amount) 增加玩家的等级.void
hideEntity
(@NotNull Plugin plugin, @NotNull Entity entity) 从视觉上隐藏一个实体.void
hidePlayer
(@NotNull Player player) 已过时。void
hidePlayer
(@NotNull Plugin plugin, @NotNull Player player) 让该玩家看不见某玩家.boolean
Gets whether the player has the "Allow Server Listings" setting enabled.boolean
isFlying()
检查玩家是否在飞.boolean
获取客户端显示的玩家血量是否被"压缩"了.boolean
已过时。This value is controlled only by the client and is therefore unreliable and vulnerable to spoofing and/or desync depending on the context/time which it is accessedboolean
如果玩家时间于当前世界时间保持了一定的差值则返回true.boolean
查看setSleepingIgnored(boolean)
方法所设置的值.boolean
判断玩家是否在潜行中.boolean
判断玩家是否在疾跑.boolean
Gets if this connection has been transferred from another server.void
kickPlayer
(@Nullable String message) 踢出玩家,并且发送一条自定义的踢出消息.void
loadData()
加载上一次保存的数据(从在world/player文件夹中的玩家名.dat文件中加载 位置,血量,背包,移动方向及其他信息).void
为玩家打开一本成书
.void
Open a Sign for editing by the Player.void
Open a Sign for editing by the Player.boolean
performCommand
(@NotNull String command) 强制玩家执行某个命令.void
playEffect
(@NotNull Location loc, @NotNull Effect effect, int data) 已过时。不安全的参数<T> void
playEffect
(@NotNull Location loc, @NotNull Effect effect, T data) void
已过时。不安全的参数void
在指定位置处为玩家播放一个音符.void
Play a sound for a player at the location of the entity.void
playSound
(@NotNull Entity entity, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch) Play a sound for a player at the location of the entity.void
playSound
(@NotNull Entity entity, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch, long seed) Play a sound for a player at the location of the entity.void
Play a sound for a player at the location of the entity.void
playSound
(@NotNull Entity entity, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch) Play a sound for a player at the location of the entity.void
playSound
(@NotNull Entity entity, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch, long seed) Play a sound for a player at the location of the entity.void
向玩家在某个位置播放一个声音.void
playSound
(@NotNull Location location, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch) 向玩家在指定位置播放声音.void
playSound
(@NotNull Location location, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch, long seed) Play a sound for a player at the location.void
向玩家在某个位置播放一个声音.void
playSound
(@NotNull Location location, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch) 向玩家在指定位置播放声音.void
playSound
(@NotNull Location location, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch, long seed) Play a sound for a player at the location.void
removeCustomChatCompletions
(@NotNull Collection<String> completions) Remove custom chat completion suggestions shown to the player while typing a message.void
Request that the player's client remove a resource pack sent by the server.void
Request that the player's client remove all loaded resource pack sent by the server.void
将玩家时间变为当前世界时间并与世界时间保持同步.void
恢复玩家所看到的天气为世界的天气.void
重置想转玩家显示的屏幕标题.@NotNull CompletableFuture<byte[]>
Retrieves a cookie from this player.void
saveData()
保存玩家数据(位置,血量,背包,移动方向 及其他信息至在world/player文件夹中的"玩家名.dat"文件).void
sendBlockChange
(@NotNull Location loc, @NotNull BlockData block) 向该玩家发送一个伪造的指定位置的方块(Block
)更改数据包.这不会改变世界中的方块.void
sendBlockChange
(@NotNull Location loc, @NotNull Material material, byte data) 已过时。不安全的参数void
sendBlockChanges
(@NotNull Collection<BlockState> blocks) Send a multi-block change.void
sendBlockChanges
(@NotNull Collection<BlockState> blocks, boolean suppressLightUpdates) 已过时。suppressLightUpdates is not functional in versions greater than 1.19.4void
sendBlockDamage
(@NotNull Location loc, float progress) Send block damage.void
sendBlockDamage
(@NotNull Location loc, float progress, int sourceId) Send block damage.void
sendBlockDamage
(@NotNull Location loc, float progress, @NotNull Entity source) Send block damage.void
sendBlockUpdate
(@NotNull Location loc, @NotNull TileState tileState) Send a TileState change.void
sendEquipmentChange
(@NotNull LivingEntity entity, @NotNull Map<EquipmentSlot, ItemStack> items) Send multiple equipment changes for the target entity.void
sendEquipmentChange
(@NotNull LivingEntity entity, @NotNull EquipmentSlot slot, @Nullable ItemStack item) 向玩家发送某个实体的盔甲槽变化数据包.void
sendExperienceChange
(float progress) Send an experience change.void
sendExperienceChange
(float progress, int level) Send an experience change.void
Send a health update to the player using its known server values.void
sendHealthUpdate
(double health, int foodLevel, float saturation) Send a health update to the player.void
sendHurtAnimation
(float yaw) Send a hurt animation.void
sendLinks
(@NotNull ServerLinks links) Sends the given server links to the player.void
Render a map and send it to the player in its entirety.void
sendPotionEffectChange
(@NotNull LivingEntity entity, @NotNull PotionEffect effect) Change a potion effect for the target entity.void
sendPotionEffectChangeRemove
(@NotNull LivingEntity entity, @NotNull PotionEffectType type) Remove a potion effect for the target entity.void
sendRawMessage
(@NotNull String message) 发送一条不含颜色代码的消息.void
sendSignChange
(@NotNull Location loc, @Nullable String[] lines) 向该玩家发送一个伪造的牌子(Sign
)上的字的更改数据包.这不会改变世界中的任何方块.void
向该玩家发送一个伪造的牌子(Sign
)上的字的更改数据包.这不会改变世界中的任何方块.void
sendSignChange
(@NotNull Location loc, @Nullable String[] lines, @NotNull DyeColor dyeColor, boolean hasGlowingText) 向该玩家发送一个伪造的牌子(Sign
)上的字的更改数据包.这不会改变世界中的任何方块.void
已过时。API行为有所改变void
向玩家发送屏幕标题.如果标题和副标题内容都为null, 那么标题将不会被发送出去, 玩家的屏幕也不会有变化.void
setAllowFlight
(boolean flight) 设置玩家是否能够飞起来(就像创造模式).void
setBedSpawnLocation
(@Nullable Location location) 已过时。Misleading name.void
setBedSpawnLocation
(@Nullable Location location, boolean force) 已过时。Misleading name.void
设置玩家指南针的指向的位置(Location
).void
setCustomChatCompletions
(@NotNull Collection<String> completions) Set the list of chat completion suggestions shown to the player while typing a message.void
setDisplayName
(@Nullable String name) 设置玩家在聊天信息中的昵称.void
setExp
(float exp) 设置当前级别升到下一级别经验进度的百分比.void
setExpCooldown
(int ticks) Sets the player's cooldown between picking up experience orbs..void
setFlying
(boolean value) 设置该玩家飞行状态.void
setFlySpeed
(float value) 设置该玩家飞行速度.void
setHealthScale
(double scale) 设置客户端显示的血量的"压缩率".void
setHealthScaled
(boolean scale) 设置客户端是否要显示一个"压缩"了的血量.void
setLevel
(int level) 设置玩家的等级void
setPlayerListFooter
(@Nullable String footer) Sets the currently displayed player list footer for this player.void
setPlayerListHeader
(@Nullable String header) Sets the currently displayed player list header for this player.void
setPlayerListHeaderFooter
(@Nullable String header, @Nullable String footer) Sets the currently displayed player list header and footer for this player.void
setPlayerListName
(@Nullable String name) 设置玩家显示在Tab列表中的名称.void
setPlayerTime
(long time, boolean relative) 设置该玩家客户端的时间,单位为tick.void
设置玩家的客户端的天气.void
请求玩家的客户端下载并且使用指定资源包.void
setResourcePack
(@NotNull String url, @org.jetbrains.annotations.Nullable byte[] hash) 请求玩家的客户端下载并且使用指定资源包.void
setResourcePack
(@NotNull String url, @org.jetbrains.annotations.Nullable byte[] hash, boolean force) Request that the player's client download and switch resource packs.void
setResourcePack
(@NotNull String url, @org.jetbrains.annotations.Nullable byte[] hash, @Nullable String prompt) Request that the player's client download and switch resource packs.void
setResourcePack
(@NotNull String url, @org.jetbrains.annotations.Nullable byte[] hash, @Nullable String prompt, boolean force) Request that the player's client download and switch resource packs.void
setResourcePack
(@NotNull UUID id, @NotNull String url, @org.jetbrains.annotations.Nullable byte[] hash, @Nullable String prompt, boolean force) Request that the player's client download and switch resource packs.void
setRespawnLocation
(@Nullable Location location) Sets the Location where the player will respawn.void
setRespawnLocation
(@Nullable Location location, boolean force) Sets the Location where the player will respawn.void
setScoreboard
(@NotNull Scoreboard scoreboard) 设置玩家的计分板.void
setSleepingIgnored
(boolean isSleeping) 是否忽略该玩家.如果设置为true,不需要该玩家睡觉,只需其他人睡觉,时间也能改变.void
setSneaking
(boolean sneak) 设置玩家潜行模式开启/取消.void
setSpectatorTarget
(@Nullable Entity entity) 设置模式下镜头跟随的实体.void
setSprinting
(boolean sprinting) 设置玩家疾跑状态开启/取消.void
setTexturePack
(@NotNull String url) 已过时。Minecraft已经不使用材质包了,应该用setResourcePack(String)
设置资源包(额这不是一个意思么..).void
setTotalExperience
(int exp) 设置玩家的总经验值(等级和经验).void
setWalkSpeed
(float value) 设置该玩家行走速度.void
setWorldBorder
(@Nullable WorldBorder border) Sets theWorldBorder
visible to this Player.void
Shows the demo screen to the player, this screen is normally only seen in the demo version of the game.void
showEntity
(@NotNull Plugin plugin, @NotNull Entity entity) Allows this player to see an entity that was previously hidden.void
showPlayer
(@NotNull Player player) 已过时。void
showPlayer
(@NotNull Plugin plugin, @NotNull Player player) 让该玩家能看到之前被隐藏的玩家.void
spawnParticle
(@NotNull Particle particle, double x, double y, double z, int count) 在指定位置产生粒子效果 (the number of times specified by count).void
spawnParticle
(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ) Spawns the particle (the number of times specified by count) at the target location.void
spawnParticle
(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra) Spawns the particle (the number of times specified by count) at the target location.<T> void
spawnParticle
(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) Spawns the particle (the number of times specified by count) at the target location.<T> void
spawnParticle
(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) Spawns the particle (the number of times specified by count) at the target location.<T> void
spawnParticle
(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, T data) Spawns the particle (the number of times specified by count) at the target location.<T> void
spawnParticle
(@NotNull Particle particle, double x, double y, double z, int count, T data) Spawns the particle (the number of times specified by count) at the target location.void
spawnParticle
(@NotNull Particle particle, @NotNull Location location, int count) 在指定位置产生粒子效果 (the number of times specified by count).void
spawnParticle
(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ) Spawns the particle (the number of times specified by count) at the target location.void
spawnParticle
(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra) Spawns the particle (the number of times specified by count) at the target location.<T> void
spawnParticle
(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) Spawns the particle (the number of times specified by count) at the target location.<T> void
spawnParticle
(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) Spawns the particle (the number of times specified by count) at the target location.<T> void
spawnParticle
(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, T data) Spawns the particle (the number of times specified by count) at the target location.<T> void
spawnParticle
(@NotNull Particle particle, @NotNull Location location, int count, T data) 在指定位置产生粒子效果 (the number of times specified by count).spigot()
void
停止播放所有声音.void
停止播放指定的声音.void
stopSound
(@NotNull String sound, @Nullable SoundCategory category) 停止播放指定的声音.void
停止播放指定的声音.void
stopSound
(@NotNull SoundCategory category) Stop the specified sound category from playing.void
stopSound
(@NotNull Sound sound, @Nullable SoundCategory category) 停止播放指定的声音.void
storeCookie
(@NotNull NamespacedKey key, @org.jetbrains.annotations.NotNull byte[] value) Stores a cookie in this player's client.void
Requests this player to connect to a different server specified by host and port.void
Update the list of commands sent to the client.void
刷新玩家的背包.确保玩家的背包和服务器内存中玩家的背包一致.从接口继承的方法 org.bukkit.attribute.Attributable
getAttribute
从接口继承的方法 org.bukkit.command.CommandSender
sendMessage, sendMessage, sendMessage, sendMessage
从接口继承的方法 org.bukkit.configuration.serialization.ConfigurationSerializable
serialize
从接口继承的方法 org.bukkit.conversations.Conversable
abandonConversation, abandonConversation, acceptConversationInput, beginConversation, isConversing, sendRawMessage
从接口继承的方法 org.bukkit.entity.Damageable
damage, damage, damage, getAbsorptionAmount, getHealth, getMaxHealth, resetMaxHealth, setAbsorptionAmount, setHealth, setMaxHealth
从接口继承的方法 org.bukkit.entity.Entity
addPassenger, addScoreboardTag, copy, copy, createSnapshot, eject, getAsString, getBoundingBox, getEntityId, getFacing, getFallDistance, getFireTicks, getFreezeTicks, getHeight, getLastDamageCause, getLocation, getLocation, getMaxFireTicks, getMaxFreezeTicks, getNearbyEntities, getPassenger, getPassengers, getPistonMoveReaction, getPortalCooldown, getPose, getScoreboardTags, getServer, getSpawnCategory, getSwimHighSpeedSplashSound, getSwimSound, getSwimSplashSound, getTicksLived, getTrackedBy, getType, getUniqueId, getVehicle, getVelocity, getWidth, getWorld, hasGravity, isCustomNameVisible, isDead, isEmpty, isFrozen, isGlowing, isInsideVehicle, isInvulnerable, isInWater, isInWorld, isPersistent, isSilent, isValid, isVisibleByDefault, isVisualFire, leaveVehicle, playEffect, remove, removePassenger, removeScoreboardTag, setCustomNameVisible, setFallDistance, setFireTicks, setFreezeTicks, setGlowing, setGravity, setInvulnerable, setLastDamageCause, setPassenger, setPersistent, setPortalCooldown, setRotation, setSilent, setTicksLived, setVelocity, setVisibleByDefault, setVisualFire, teleport, teleport, teleport, teleport
从接口继承的方法 org.bukkit.entity.HumanEntity
closeInventory, discoverRecipe, discoverRecipes, dropItem, fireworkBoost, getAttackCooldown, getBedLocation, getCooldown, getDiscoveredRecipes, getEnchantmentSeed, getEnderChest, getExhaustion, getExpToLevel, getFoodLevel, getGameMode, getInventory, getItemInHand, getItemOnCursor, getLastDeathLocation, getMainHand, getOpenInventory, getSaturatedRegenRate, getSaturation, getShoulderEntityLeft, getShoulderEntityRight, getSleepTicks, getStarvationRate, getUnsaturatedRegenRate, hasCooldown, hasDiscoveredRecipe, isBlocking, isHandRaised, openEnchanting, openInventory, openInventory, openMerchant, openMerchant, openWorkbench, setCooldown, setEnchantmentSeed, setExhaustion, setFoodLevel, setGameMode, setItemInHand, setItemOnCursor, setLastDeathLocation, setSaturatedRegenRate, setSaturation, setShoulderEntityLeft, setShoulderEntityRight, setStarvationRate, setUnsaturatedRegenRate, setWindowProperty, sleep, undiscoverRecipe, undiscoverRecipes, wakeup
从接口继承的方法 org.bukkit.entity.LivingEntity
addPotionEffect, addPotionEffect, addPotionEffects, attack, canBreatheUnderwater, getActivePotionEffects, getArrowCooldown, getArrowsInBody, getCanPickupItems, getCategory, getCollidableExemptions, getDeathSound, getDrinkingSound, getEatingSound, getEquipment, getEyeHeight, getEyeHeight, getEyeLocation, getFallDamageSound, getFallDamageSoundBig, getFallDamageSoundSmall, getHurtSound, getItemInUse, getItemInUseTicks, getKiller, getLastDamage, getLastTwoTargetBlocks, getLeashHolder, getLineOfSight, getMaximumAir, getMaximumNoDamageTicks, getMemory, getNoActionTicks, getNoDamageTicks, getPotionEffect, getRemainingAir, getRemoveWhenFarAway, getTargetBlock, getTargetBlockExact, getTargetBlockExact, hasAI, hasLineOfSight, hasPotionEffect, isClimbing, isCollidable, isGliding, isInvisible, isLeashed, isRiptiding, isSleeping, isSwimming, playHurtAnimation, rayTraceBlocks, rayTraceBlocks, removePotionEffect, setAI, setArrowCooldown, setArrowsInBody, setCanPickupItems, setCollidable, setGliding, setInvisible, setItemInUseTicks, setLastDamage, setLeashHolder, setMaximumAir, setMaximumNoDamageTicks, setMemory, setNoActionTicks, setNoDamageTicks, setRemainingAir, setRemoveWhenFarAway, setSwimming, swingMainHand, swingOffHand
从接口继承的方法 org.bukkit.metadata.Metadatable
getMetadata, hasMetadata, removeMetadata, setMetadata
从接口继承的方法 org.bukkit.Nameable
getCustomName, setCustomName
从接口继承的方法 org.bukkit.OfflinePlayer
ban, ban, ban, decrementStatistic, decrementStatistic, decrementStatistic, decrementStatistic, decrementStatistic, decrementStatistic, getFirstPlayed, getLastDeathLocation, getLastPlayed, getLocation, getPlayer, getPlayerProfile, getStatistic, getStatistic, getStatistic, getUniqueId, hasPlayedBefore, incrementStatistic, incrementStatistic, incrementStatistic, incrementStatistic, incrementStatistic, incrementStatistic, isBanned, isOnline, isWhitelisted, setStatistic, setStatistic, setStatistic, setWhitelisted
从接口继承的方法 org.bukkit.permissions.Permissible
addAttachment, addAttachment, addAttachment, addAttachment, getEffectivePermissions, hasPermission, hasPermission, isPermissionSet, isPermissionSet, recalculatePermissions, removeAttachment
从接口继承的方法 org.bukkit.persistence.PersistentDataHolder
getPersistentDataContainer
从接口继承的方法 org.bukkit.plugin.messaging.PluginMessageRecipient
getListeningPluginChannels, sendPluginMessage
从接口继承的方法 org.bukkit.projectiles.ProjectileSource
launchProjectile, launchProjectile
从接口继承的方法 org.bukkit.permissions.ServerOperator
isOp, setOp
-
方法详细资料
-
getName
返回该玩家的玩家名.原文:Returns the name of this player
- 指定者:
getName
在接口中AnimalTamer
- 指定者:
getName
在接口中CommandSender
- 指定者:
getName
在接口中HumanEntity
- 指定者:
getName
在接口中OfflinePlayer
- 返回:
- 玩家名
-
getDisplayName
获得玩家在聊天信息中的昵称.这个昵称只显示在聊天信息中,能以颜色加以修饰.
原文:Gets the "friendly" name to display of this player. This may include color.
Note that this name will not be displayed in game, only in chat and places defined by plugins.
- 返回:
- 显示的名称.
-
setDisplayName
设置玩家在聊天信息中的昵称.这个名字只显示在聊天信息中,能以颜色加以修饰.
原文Sets the "friendly" name to display of this player. This may include color.
Note that this name will not be displayed in game, only in chat and places defined by plugins.
- 参数:
name
- 显示的名称.
-
getPlayerListName
得到玩家显示在tab列表中的名称.原文:Gets the name that is shown on the player list.
- 返回:
- 玩家名(显示于tab列表)
-
setPlayerListName
设置玩家显示在Tab列表中的名称.如果设置为null则此名字与
getName()
相同.原文:Sets the name that is shown on the in-game player list.
If the value is null, the name will be identical to
getName()
.- 参数:
name
- 新的显示在玩家列表中的名字
-
getPlayerListHeader
Gets the currently displayed player list header for this player.- 返回:
- player list header or null
-
setPlayerListHeader
Sets the currently displayed player list header for this player.- 参数:
header
- player list header, null for empty
-
setCompassTarget
设置玩家指南针的指向的位置(Location
).原文:Set the target of the player's compass.
- 参数:
loc
- 指向
-
getCompassTarget
- 返回:
- 指向
-
getAddress
得到一个Address对象,包括这个玩家的IP以及登入端口.原文:Gets the socket address of this player
- 返回:
- 玩家的Address对象
-
isTransferred
boolean isTransferred()Gets if this connection has been transferred from another server.- 返回:
- true if the connection has been transferred
-
retrieveCookie
Retrieves a cookie from this player.- 参数:
key
- the key identifying the cookie cookie- 返回:
- a
CompletableFuture
that will be completed when the Cookie response is received or otherwise available. If the cookie is not set in the client, theCompletableFuture
will complete with a null value.
-
storeCookie
void storeCookie(@NotNull @NotNull NamespacedKey key, @NotNull @org.jetbrains.annotations.NotNull byte[] value) Stores a cookie in this player's client.- 参数:
key
- the key identifying the cookie cookievalue
- the data to store in the cookie- 抛出:
IllegalStateException
- if a cookie cannot be stored at this time
-
transfer
Requests this player to connect to a different server specified by host and port.- 参数:
host
- the host of the server to transfer toport
- the port of the server to transfer to- 抛出:
IllegalStateException
- if a transfer cannot take place at this time
-
sendRawMessage
发送一条不含颜色代码的消息.译注:就是会把颜色代码过滤掉然后
CommandSender.sendMessage(java.lang.String)
原文:Sends this sender a message raw
- 指定者:
sendRawMessage
在接口中Conversable
- 参数:
message
- 要发送的消息
-
kickPlayer
踢出玩家,并且发送一条自定义的踢出消息.原文:Kicks player with custom kick message.
- 参数:
message
- 踢出消息
-
ban
@Nullable @Nullable BanEntry<PlayerProfile> ban(@Nullable @Nullable String reason, @Nullable @Nullable Date expires, @Nullable @Nullable String source, boolean kickPlayer) Adds this user to theProfileBanList
. If a previous ban exists, this will update the entry.- 参数:
reason
- reason for the ban, null indicates implementation defaultexpires
- date for the ban's expiration (unban), or null to imply foreversource
- source of the ban, null indicates implementation defaultkickPlayer
- if the player need to be kick- 返回:
- the entry for the newly created ban, or the entry for the (updated) previous ban
-
ban
@Nullable @Nullable BanEntry<PlayerProfile> ban(@Nullable @Nullable String reason, @Nullable @Nullable Instant expires, @Nullable @Nullable String source, boolean kickPlayer) Adds this user to theProfileBanList
. If a previous ban exists, this will update the entry.- 参数:
reason
- reason for the ban, null indicates implementation defaultexpires
- date for the ban's expiration (unban), or null to imply foreversource
- source of the ban, null indicates implementation defaultkickPlayer
- if the player need to be kick- 返回:
- the entry for the newly created ban, or the entry for the (updated) previous ban
-
ban
@Nullable @Nullable BanEntry<PlayerProfile> ban(@Nullable @Nullable String reason, @Nullable @Nullable Duration duration, @Nullable @Nullable String source, boolean kickPlayer) Adds this user to theProfileBanList
. If a previous ban exists, this will update the entry.- 参数:
reason
- reason for the ban, null indicates implementation defaultduration
- the duration how long the ban lasts, or null to imply foreversource
- source of the ban, null indicates implementation defaultkickPlayer
- if the player need to be kick- 返回:
- the entry for the newly created ban, or the entry for the (updated) previous ban
-
banIp
@Nullable @Nullable BanEntry<InetAddress> banIp(@Nullable @Nullable String reason, @Nullable @Nullable Date expires, @Nullable @Nullable String source, boolean kickPlayer) Adds this user's current IP address to theIpBanList
. If a previous ban exists, this will update the entry. IfgetAddress()
is null this method will throw an exception.- 参数:
reason
- reason for the ban, null indicates implementation defaultexpires
- date for the ban's expiration (unban), or null to imply foreversource
- source of the ban, null indicates implementation defaultkickPlayer
- if the player need to be kick- 返回:
- the entry for the newly created ban, or the entry for the (updated) previous ban
-
banIp
@Nullable @Nullable BanEntry<InetAddress> banIp(@Nullable @Nullable String reason, @Nullable @Nullable Instant expires, @Nullable @Nullable String source, boolean kickPlayer) Adds this user's current IP address to theIpBanList
. If a previous ban exists, this will update the entry. IfgetAddress()
is null this method will throw an exception.- 参数:
reason
- reason for the ban, null indicates implementation defaultexpires
- date for the ban's expiration (unban), or null to imply foreversource
- source of the ban, null indicates implementation defaultkickPlayer
- if the player need to be kick- 返回:
- the entry for the newly created ban, or the entry for the (updated) previous ban
-
banIp
@Nullable @Nullable BanEntry<InetAddress> banIp(@Nullable @Nullable String reason, @Nullable @Nullable Duration duration, @Nullable @Nullable String source, boolean kickPlayer) Adds this user's current IP address to theIpBanList
. If a previous ban exists, this will update the entry. IfgetAddress()
is null this method will throw an exception.- 参数:
reason
- reason for the ban, null indicates implementation defaultduration
- the duration how long the ban lasts, or null to imply foreversource
- source of the ban, null indicates implementation defaultkickPlayer
- if the player need to be kick- 返回:
- the entry for the newly created ban, or the entry for the (updated) previous ban
-
chat
强制玩家发送一个聊天消息,或强制使用命令(需要在内容前加 "/").原文:Says a message (or runs a command).
- 参数:
msg
- 要发送的聊天消息
-
performCommand
强制玩家执行某个命令.原文:Makes the player perform the given command
- 参数:
command
- 要执行的命令(不带'/')- 返回:
- JavaPlugin内的onCommand()方法的返回值
-
isOnGround
已过时。This value is controlled only by the client and is therefore unreliable and vulnerable to spoofing and/or desync depending on the context/time which it is accessedReturns true if the entity is supported by a block. This value is a state updated by the client after each movement.- 指定者:
isOnGround
在接口中Entity
- 返回:
- True if entity is on ground.
- 另请参阅:
-
isSneaking
boolean isSneaking()判断玩家是否在潜行中.原文:Returns if the player is in sneak mode
- 返回:
- 如果在潜行模式返回true
-
setSneaking
void setSneaking(boolean sneak) 设置玩家潜行模式开启/取消.原文:Sets the sneak mode the player
- 参数:
sneak
- true表示在潜行,false反之
-
isSprinting
boolean isSprinting()判断玩家是否在疾跑.原文:Gets whether the player is sprinting or not.
- 返回:
- true表示玩家在疾跑,false反之
-
setSprinting
void setSprinting(boolean sprinting) 设置玩家疾跑状态开启/取消.原文:Sets whether the player is sprinting or not.
- 参数:
sprinting
- true表示在疾跑,false反之
-
saveData
void saveData()保存玩家数据(位置,血量,背包,移动方向 及其他信息至在world/player文件夹中的"玩家名.dat"文件).原文:Saves the players current location, health, inventory, motion, and other information into the username.dat file, in the world/player folder
-
loadData
void loadData()加载上一次保存的数据(从在world/player文件夹中的玩家名.dat文件中加载 位置,血量,背包,移动方向及其他信息).这将会覆盖当前内存中的数据.
原文:Loads the players current location, health, inventory, motion, and other information from the username.dat file, in the world/player folder.
Note: This will overwrite the players current inventory, health, motion, etc, with the state from the saved dat file.
-
setSleepingIgnored
void setSleepingIgnored(boolean isSleeping) 是否忽略该玩家.如果设置为true,不需要该玩家睡觉,只需其他人睡觉,时间也能改变.如果所有玩家都把这个项设置为true但是没有人睡觉,则什么事也不会发生.
原文:Sets whether the player is ignored as not sleeping. If everyone is either sleeping or has this flag set, then time will advance to the next day. If everyone has this flag set but no one is actually in bed, then nothing will happen.
- 参数:
isSleeping
- 是否忽略该玩家
-
isSleepingIgnored
boolean isSleepingIgnored()- 返回:
- 判断是否全部睡觉时是否忽略该玩家
-
getBedSpawnLocation
已过时。Misleading name. This method also returns the location of respawn anchors.Gets the Location where the player will spawn at their bed, null if they have not slept in one or their current bed spawn is invalid.- 指定者:
getBedSpawnLocation
在接口中OfflinePlayer
- 返回:
- Bed Spawn Location if bed exists, otherwise null.
- 另请参阅:
-
getRespawnLocation
Gets the Location where the player will spawn at, null if they don't have a valid respawn point.- 指定者:
getRespawnLocation
在接口中OfflinePlayer
- 返回:
- respawn location if exists, otherwise null.
-
setBedSpawnLocation
已过时。Misleading name. This method sets the player's respawn location more generally and is not limited to beds.Sets the Location where the player will spawn at their bed.- 参数:
location
- where to set the respawn location- 另请参阅:
-
setRespawnLocation
Sets the Location where the player will respawn.- 参数:
location
- where to set the respawn location
-
setBedSpawnLocation
已过时。Misleading name. This method sets the player's respawn location more generally and is not limited to beds.Sets the Location where the player will spawn at their bed.- 参数:
location
- where to set the respawn locationforce
- whether to forcefully set the respawn location even if a valid bed is not present- 另请参阅:
-
setRespawnLocation
Sets the Location where the player will respawn.- 参数:
location
- where to set the respawn locationforce
- whether to forcefully set the respawn location even if a valid respawn point is not present
-
playNote
已过时。不安全的参数在指定位置处为玩家播放一个音符.
This will work with cake.原文:Play a note for the player at a location.
This will work with cake.- 参数:
loc
- 播放音符的位置instrument
- 乐器IDnote
- 音符ID.
-
playNote
void playNote(@NotNull @NotNull Location loc, @NotNull @NotNull Instrument instrument, @NotNull @NotNull Note note) 在指定位置处为玩家播放一个音符.
This will work with cake.如果使用
Instrument.CUSTOM_HEAD
调用此方法, 将静默失败.原文:Play a note for the player at a location.
This will work with cake.This method will fail silently when called with
Instrument.CUSTOM_HEAD
.- 参数:
loc
- 播放音符的位置instrument
- 乐器IDnote
- 音符
-
playSound
void playSound(@NotNull @NotNull Location location, @NotNull @NotNull Sound sound, float volume, float pitch) 向玩家在某个位置播放一个声音.当位置或声音为null或玩家的客户端没开启声音时,这个方法无效.
原文:Play a sound for a player at the location.
This function will fail silently if Location or Sound are null.
- 参数:
location
- 要播放声音的位置sound
- 要播放的声音volume
- 音量 默认 1Fpitch
- 音高 默认 0F
-
playSound
void playSound(@NotNull @NotNull Location location, @NotNull @NotNull String sound, float volume, float pitch) 向玩家在某个位置播放一个声音.当位置或声音为null或玩家的客户端没开启声音时,这个方法无效. 玩家客户端不存在指定声音本操作也将无效.
原文:Play a sound for a player at the location.
This function will fail silently if Location or Sound are null. No sound will be heard by the player if their client does not have the respective sound for the value passed.
- 参数:
location
- 要播放声音的位置sound
- 要播放的声音volume
- 音量 默认 1Fpitch
- 音高 默认 0F
-
playSound
void playSound(@NotNull @NotNull Location location, @NotNull @NotNull Sound sound, @NotNull @NotNull SoundCategory category, float volume, float pitch) 向玩家在指定位置播放声音.当位置或声音为null或玩家的客户端没开启声音时,这个方法无效.
原文:Play a sound for a player at the location.
This function will fail silently if Location or Sound are null.
- 参数:
location
- 声音播放位置sound
- 要播放的声音category
- 声音的分类volume
- 音量pitch
- 音调
-
playSound
void playSound(@NotNull @NotNull Location location, @NotNull @NotNull String sound, @NotNull @NotNull SoundCategory category, float volume, float pitch) 向玩家在指定位置播放声音.当位置或声音为null或玩家的客户端没开启声音时,这个方法无效. 玩家客户端不存在指定声音本操作也将无效.
原文:Play a sound for a player at the location.
This function will fail silently if Location or Sound are null. No sound will be heard by the player if their client does not have the respective sound for the value passed.
- 参数:
location
- 声音播放位置sound
- 要播放的声音category
- 声音的分类volume
- 音量pitch
- 音调
-
playSound
void playSound(@NotNull @NotNull Location location, @NotNull @NotNull Sound sound, @NotNull @NotNull SoundCategory category, float volume, float pitch, long seed) Play a sound for a player at the location. For sounds with multiple variations passing the same seed will always play the same variation.This function will fail silently if Location or Sound are null.
- 参数:
location
- The location to play the soundsound
- The sound to playcategory
- The category of the soundvolume
- The volume of the soundpitch
- The pitch of the soundseed
- The seed for the sound
-
playSound
void playSound(@NotNull @NotNull Location location, @NotNull @NotNull String sound, @NotNull @NotNull SoundCategory category, float volume, float pitch, long seed) Play a sound for a player at the location. For sounds with multiple variations passing the same seed will always play the same variation.This function will fail silently if Location or Sound are null. No sound will be heard by the player if their client does not have the respective sound for the value passed.
- 参数:
location
- The location to play the soundsound
- The internal sound name to playcategory
- The category of the soundvolume
- The volume of the soundpitch
- The pitch of the soundseed
- The seed for the sound
-
playSound
void playSound(@NotNull @NotNull Entity entity, @NotNull @NotNull Sound sound, float volume, float pitch) Play a sound for a player at the location of the entity.This function will fail silently if Entity or Sound are null.
- 参数:
entity
- The entity to play the soundsound
- The sound to playvolume
- The volume of the soundpitch
- The pitch of the sound
-
playSound
void playSound(@NotNull @NotNull Entity entity, @NotNull @NotNull String sound, float volume, float pitch) Play a sound for a player at the location of the entity.This function will fail silently if Entity or Sound are null.
- 参数:
entity
- The entity to play the soundsound
- The sound to playvolume
- The volume of the soundpitch
- The pitch of the sound
-
playSound
void playSound(@NotNull @NotNull Entity entity, @NotNull @NotNull Sound sound, @NotNull @NotNull SoundCategory category, float volume, float pitch) Play a sound for a player at the location of the entity.This function will fail silently if Entity or Sound are null.
- 参数:
entity
- The entity to play the soundsound
- The sound to playcategory
- The category of the soundvolume
- The volume of the soundpitch
- The pitch of the sound
-
playSound
void playSound(@NotNull @NotNull Entity entity, @NotNull @NotNull String sound, @NotNull @NotNull SoundCategory category, float volume, float pitch) Play a sound for a player at the location of the entity.This function will fail silently if Entity or Sound are null.
- 参数:
entity
- The entity to play the soundsound
- The sound to playcategory
- The category of the soundvolume
- The volume of the soundpitch
- The pitch of the sound
-
playSound
void playSound(@NotNull @NotNull Entity entity, @NotNull @NotNull Sound sound, @NotNull @NotNull SoundCategory category, float volume, float pitch, long seed) Play a sound for a player at the location of the entity. For sounds with multiple variations passing the same seed will always play the same variation.This function will fail silently if Entity or Sound are null.
- 参数:
entity
- The entity to play the soundsound
- The sound to playcategory
- The category of the soundvolume
- The volume of the soundpitch
- The pitch of the soundseed
- The seed for the sound
-
playSound
void playSound(@NotNull @NotNull Entity entity, @NotNull @NotNull String sound, @NotNull @NotNull SoundCategory category, float volume, float pitch, long seed) Play a sound for a player at the location of the entity. For sounds with multiple variations passing the same seed will always play the same variation.This function will fail silently if Entity or Sound are null.
- 参数:
entity
- The entity to play the soundsound
- The sound to playcategory
- The category of the soundvolume
- The volume of the soundpitch
- The pitch of the soundseed
- The seed for the sound
-
stopSound
停止播放指定的声音.原文:Stop the specified sound from playing.
- 参数:
sound
- 指定声音
-
stopSound
停止播放指定的声音.原文:Stop the specified sound from playing.
- 参数:
sound
- 指定声音
-
stopSound
停止播放指定的声音.原文:Stop the specified sound from playing.
- 参数:
sound
- 指定声音category
- 声音类别
-
stopSound
停止播放指定的声音.原文:Stop the specified sound from playing.
- 参数:
sound
- 指定声音category
- 声音类别
-
stopSound
Stop the specified sound category from playing.- 参数:
category
- the sound category to stop
-
stopAllSounds
void stopAllSounds()停止播放所有声音.原文:Stop all sounds from playing.
-
playEffect
@Deprecated void playEffect(@NotNull @NotNull Location loc, @NotNull @NotNull Effect effect, int data) 已过时。不安全的参数- 参数:
loc
- 要播放粒子效果的位置effect
- 要播放的粒子效果data
- 某些效果需要的附加值.
-
playEffect
<T> void playEffect(@NotNull @NotNull Location loc, @NotNull @NotNull Effect effect, @Nullable T data) 在某个位置(Location
)向玩家播放一个粒子效果(Effect
).原文:Plays an effect to just this player.
译注1:data参数一般为0就行,但是如果要播放的效果为
Effect
.StepSound(方块被打破时的粒子效果),data就为Material
类型.例:playEffect(loc,
Effect
.StepSound, Material.REDSTONE_BLOCK)将 在loc的位置播放一个红石块(REDSTONE_BLOCK)被打破的粒子效果.译注2:
Material
只能表示主ID,不能表示副ID,所以播放绿色羊毛的打破效果貌似是不可能的, 但是由于data是泛型,我们猜测会不会data也可以是能表示任何方块
类型?由于时间关系不能测试,请谅解. -
breakBlock
Force this player to break a Block using the item in their main hand. This method will respect enchantments, handle item durability (if applicable) and drop experience and the correct items according to the tool/item in the player's hand.Note that this method will call a
BlockBreakEvent
, meaning that this method may not be successful in breaking the block if the event was cancelled by a third party plugin. Care should be taken if running this method in a BlockBreakEvent listener as recursion may be possible if it is invoked on the sameBlock
being broken in the event.Additionally, a
BlockDropItemEvent
is called for the items dropped by this method (if successful).The block must be in the same world as the player.
- 参数:
block
- the block to break- 返回:
- true if the block was broken, false if the break failed
-
sendBlockChange
@Deprecated void sendBlockChange(@NotNull @NotNull Location loc, @NotNull @NotNull Material material, byte data) 已过时。不安全的参数向该玩家发送一个伪造的指定位置的方块(Block
)更改数据包.这不会改变世界中的方块.原文:Send a block change. This fakes a block change packet for a user at a certain location. This will not actually change the world in any way.
译注:意思就是,向玩家发送一个伪造的,更新方块的数据包,那个位置本来是石头的,这个玩家看起来那里就变成了钻石矿.
但是这并没有真的在世界中放置一个钻石矿.其他玩家看到的还是石头.挖掉后也不会真的掉钻石.(我想还是举例说明比较好..)
例1:sendBlockChange(loc,Material.DIAMOND_ORE,(byte)0)将让玩家的客户端认为loc的位置是一个钻石矿石(DIAMOND_ORE) 但其实并没有改变.
例2:sendBlockChange(loc,Material.WOOL,(byte)14)将让玩家的客户端认为loc的位置是一个红色羊毛(附加值为14的WOOL).
- 参数:
loc
- 要改变的方块的位置material
- 要改变成的方块的类型data
- 要改变成的方块的副ID
-
sendBlockChange
向该玩家发送一个伪造的指定位置的方块(Block
)更改数据包.这不会改变世界中的方块.原文:Send a block change. This fakes a block change packet for a user at a certain location. This will not actually change the world in any way.
- 参数:
loc
- 要改变的方块的位置block
- 新方块
-
sendBlockChanges
Send a multi-block change. This fakes a block change packet for a user at multiple locations. This will not actually change the world in any way.This method may send multiple packets to the client depending on the blocks in the collection. A packet must be sent for each chunk section modified, meaning one packet for each 16x16x16 block area. Even if only one block is changed in two different chunk sections, two packets will be sent.
Additionally, this method cannot guarantee the functionality of changes being sent to the player in chunks not loaded by the client. It is the responsibility of the caller to ensure that the client is within range of the changed blocks or to handle any side effects caused as a result.
- 参数:
blocks
- the block states to send to the player
-
sendBlockChanges
@Deprecated void sendBlockChanges(@NotNull @NotNull Collection<BlockState> blocks, boolean suppressLightUpdates) 已过时。suppressLightUpdates is not functional in versions greater than 1.19.4Send a multi-block change. This fakes a block change packet for a user at multiple locations. This will not actually change the world in any way.This method may send multiple packets to the client depending on the blocks in the collection. A packet must be sent for each chunk section modified, meaning one packet for each 16x16x16 block area. Even if only one block is changed in two different chunk sections, two packets will be sent.
Additionally, this method cannot guarantee the functionality of changes being sent to the player in chunks not loaded by the client. It is the responsibility of the caller to ensure that the client is within range of the changed blocks or to handle any side effects caused as a result.
- 参数:
blocks
- the block states to send to the playersuppressLightUpdates
- whether or not light updates should be suppressed when updating the blocks on the client
-
sendBlockDamage
Send block damage. This fakes block break progress at a certain location sourced by this player. This will not actually change the block's break progress in any way.- 参数:
loc
- the location of the damaged blockprogress
- the progress from 0.0 - 1.0 where 0 is no damage and 1.0 is the most damaged
-
sendBlockDamage
void sendBlockDamage(@NotNull @NotNull Location loc, float progress, @NotNull @NotNull Entity source) Send block damage. This fakes block break progress at a certain location sourced by the provided entity. This will not actually change the block's break progress in any way.At the same location for each unique damage source sent to the player, a separate damage overlay will be displayed with the given progress. This allows for block damage at different progress from multiple entities at once.
- 参数:
loc
- the location of the damaged blockprogress
- the progress from 0.0 - 1.0 where 0 is no damage and 1.0 is the most damagedsource
- the entity to which the damage belongs
-
sendBlockDamage
Send block damage. This fakes block break progress at a certain location sourced by the provided entity id. This will not actually change the block's break progress in any way.At the same location for each unique damage source sent to the player, a separate damage overlay will be displayed with the given progress. This allows for block damage at different progress from multiple entities at once.
- 参数:
loc
- the location of the damaged blockprogress
- the progress from 0.0 - 1.0 where 0 is no damage and 1.0 is the most damagedsourceId
- the entity id of the entity to which the damage belongs. Can be an id that does not associate directly with an existing or loaded entity.
-
sendEquipmentChange
void sendEquipmentChange(@NotNull @NotNull LivingEntity entity, @NotNull @NotNull EquipmentSlot slot, @Nullable @Nullable ItemStack item) 向玩家发送某个实体的盔甲槽变化数据包. 本方法可针对指定玩家伪造某个实体的盔甲, 且不会实际改变指定实体的盔甲槽内容.原文:Send the equipment change of an entity. This fakes the equipment change of an entity for a user. This will not actually change the inventory of the specified entity in any way.
- 参数:
entity
- 玩家会看到哪个实体的变化slot
- 要伪造哪一盔甲槽的变化item
- 玩家将看到的盔甲物品
-
sendEquipmentChange
void sendEquipmentChange(@NotNull @NotNull LivingEntity entity, @NotNull @NotNull Map<EquipmentSlot, ItemStack> items) Send multiple equipment changes for the target entity. This will not actually change the entity's equipment in any way.- 参数:
entity
- the entity whose equipment to changeitems
- the slots to change, where the values are the items to which the slot should be changed. null values will set the slot to air
-
sendSignChange
void sendSignChange(@NotNull @NotNull Location loc, @Nullable @Nullable String[] lines) throws IllegalArgumentException 向该玩家发送一个伪造的牌子(Sign
)上的字的更改数据包.这不会改变世界中的任何方块.如果那个位置没有牌子,这个方法将用
sendBlockChange(org.bukkit.Location, org.bukkit.block.data.BlockData)
方法在那个位置伪造一个牌子然后更改它.如果客户端认为在指定的位置没有牌子,则会显示一个错误给玩家.
要改变告示牌的所有属性(包括告示牌背面), 请使用
sendBlockUpdate(org.bukkit.Location, org.bukkit.block.TileState)
.原文:Send a sign change. This fakes a sign change packet for a user at a certain location. This will not actually change the world in any way. This method will use a sign at the location's block or a faked sign sent via
sendBlockChange(org.bukkit.Location, org.bukkit.block.data.BlockData)
.If the client does not have a sign at the given location it will display an error message to the user.
To change all attributes of a sign, including the back Side, use
sendBlockUpdate(org.bukkit.Location, org.bukkit.block.TileState)
.译注:该方法类似于
sendBlockChange(org.bukkit.Location, org.bukkit.Material, byte)
, 只不过sendBlockChange是伪装一个方块成其他方块,而它只是伪装牌子上的字.- 参数:
loc
- 要让玩家看起来改变了的牌子的位置lines
- null或大小等于4的String数组;数组中每个元素都代表一行- 抛出:
IllegalArgumentException
- 如果location参数为nullIllegalArgumentException
- 如果lines数组的长度小于4
-
sendSignChange
void sendSignChange(@NotNull @NotNull Location loc, @Nullable @Nullable String[] lines, @NotNull @NotNull DyeColor dyeColor) throws IllegalArgumentException 向该玩家发送一个伪造的牌子(Sign
)上的字的更改数据包.这不会改变世界中的任何方块.如果那个位置没有牌子,这个方法将用
sendBlockChange(org.bukkit.Location, org.bukkit.block.data.BlockData)
方法在那个位置伪造一个牌子然后更改它.如果客户端认为在指定的位置没有牌子,则会显示一个错误给玩家.
要改变告示牌的所有属性(包括告示牌背面), 请使用
sendBlockUpdate(org.bukkit.Location, org.bukkit.block.TileState)
.原文:Send a sign change. This fakes a sign change packet for a user at a certain location. This will not actually change the world in any way. This method will use a sign at the location's block or a faked sign sent via
sendBlockChange(org.bukkit.Location, org.bukkit.block.data.BlockData)
.If the client does not have a sign at the given location it will display an error message to the user.
To change all attributes of a sign, including the back Side, use
sendBlockUpdate(org.bukkit.Location, org.bukkit.block.TileState)
.- 参数:
loc
- 要让玩家看起来改变了的牌子的位置lines
- null或大小等于4的String数组;数组中每个元素都代表一行dyeColor
- 告示牌的颜色(文字的颜色)- 抛出:
IllegalArgumentException
- 如果location参数为nullIllegalArgumentException
- 如果dyeColor参数为nullIllegalArgumentException
- 如果lines数组的长度小于4
-
sendSignChange
void sendSignChange(@NotNull @NotNull Location loc, @Nullable @Nullable String[] lines, @NotNull @NotNull DyeColor dyeColor, boolean hasGlowingText) throws IllegalArgumentException 向该玩家发送一个伪造的牌子(Sign
)上的字的更改数据包.这不会改变世界中的任何方块.如果那个位置没有牌子,这个方法将用
sendBlockChange(org.bukkit.Location, org.bukkit.block.data.BlockData)
方法在那个位置伪造一个牌子然后更改它.如果客户端认为在指定的位置没有牌子,则会显示一个错误给玩家.
要改变告示牌的所有属性(包括告示牌背面), 请使用
sendBlockUpdate(org.bukkit.Location, org.bukkit.block.TileState)
.原文:Send a sign change. This fakes a sign change packet for a user at a certain location. This will not actually change the world in any way. This method will use a sign at the location's block or a faked sign sent via
sendBlockChange(org.bukkit.Location, org.bukkit.block.data.BlockData)
.If the client does not have a sign at the given location it will display an error message to the user.
To change all attributes of a sign, including the back Side, use
sendBlockUpdate(org.bukkit.Location, org.bukkit.block.TileState)
.- 参数:
loc
- 要让玩家看起来改变了的牌子的位置lines
- null或大小等于4的String数组;数组中每个元素都代表一行dyeColor
- 告示牌的颜色(文字的颜色)hasGlowingText
- 文字是否发光- 抛出:
IllegalArgumentException
- 如果location参数为nullIllegalArgumentException
- 如果dyeColor参数为nullIllegalArgumentException
- 如果lines数组的长度小于4
-
sendBlockUpdate
@Experimental void sendBlockUpdate(@NotNull @NotNull Location loc, @NotNull @NotNull TileState tileState) throws IllegalArgumentException Send a TileState change. This fakes a TileState change for a user at the given location. This will not actually change the world in any way. This method will use a TileState at the location's block or a faked TileState sent viasendBlockChange(org.bukkit.Location, org.bukkit.block.data.BlockData)
.If the client does not have an appropriate tile at the given location it may display an error message to the user.
BlockData.createBlockState()
can be used to create aBlockState
.- 参数:
loc
- the location of the signtileState
- the tile state- 抛出:
IllegalArgumentException
- if location is nullIllegalArgumentException
- if tileState is null
-
sendPotionEffectChange
void sendPotionEffectChange(@NotNull @NotNull LivingEntity entity, @NotNull @NotNull PotionEffect effect) Change a potion effect for the target entity. This will not actually change the entity's potion effects in any way.Note: Sending an effect change to a player for themselves may cause unexpected behavior on the client. Effects sent this way will also not be removed when their timer reaches 0, they can be removed with
sendPotionEffectChangeRemove(LivingEntity, PotionEffectType)
- 参数:
entity
- the entity whose potion effects to changeeffect
- the effect to change
-
sendPotionEffectChangeRemove
void sendPotionEffectChangeRemove(@NotNull @NotNull LivingEntity entity, @NotNull @NotNull PotionEffectType type) Remove a potion effect for the target entity. This will not actually change the entity's potion effects in any way.Note: Sending an effect change to a player for themselves may cause unexpected behavior on the client.
- 参数:
entity
- the entity whose potion effects to changetype
- the effect type to remove
-
sendMap
Render a map and send it to the player in its entirety. This may be used when streaming the map in the normal manner is not desirable.- 参数:
map
- The map to be sent
-
sendHurtAnimation
void sendHurtAnimation(float yaw) Send a hurt animation. This fakes incoming damage towards the player from the given yaw relative to the player's direction.- 参数:
yaw
- the yaw in degrees relative to the player's direction where 0 is in front of the player, 90 is to the right, 180 is behind, and 270 is to the left
-
sendLinks
Sends the given server links to the player.- 参数:
links
- links to send
-
addCustomChatCompletions
Add custom chat completion suggestions shown to the player while typing a message.- 参数:
completions
- the completions to send
-
removeCustomChatCompletions
Remove custom chat completion suggestions shown to the player while typing a message. Online player names cannot be removed with this method. This will affect only custom completions added byaddCustomChatCompletions(Collection)
orsetCustomChatCompletions(Collection)
.- 参数:
completions
- the completions to remove
-
setCustomChatCompletions
Set the list of chat completion suggestions shown to the player while typing a message.If completions were set previously, this method will remove them all and replace them with the provided completions.
- 参数:
completions
- the completions to set
-
updateInventory
刷新玩家的背包.确保玩家的背包和服务器内存中玩家的背包一致.译注:在以前的版本(好吧我也不知道是什么版本)中假如不调用该方法当更改背包时会出现莫名其妙的事情,比如 背包看起来是空的,点一下空的格突然出现了东西之类的....
原文:Forces an update of the player's entire inventory.
-
getPreviousGameMode
Gets this player's previousGameMode
- 返回:
- Previous game mode or null
-
setPlayerTime
void setPlayerTime(long time, boolean relative) 设置该玩家客户端的时间,单位为tick.假如relative为true则玩家时间会随着世界时间变动而变动,并且保持一个差值,反之客户端时间固定不动.
注意!如果relative为true,那么time表示的就是客户端的时间与世界的时间之差(相对于世界的时间),而如果为false 那么time表示的就是一个绝对的时间.
原文:Sets the current time on the player's client. When relative is true the player's time will be kept synchronized to its world time with the specified offset.
When using non relative time the player's time will stay fixed at the specified time parameter. It's up to the caller to continue updating the player's time. To restore player time to normal use resetPlayerTime().
- 参数:
time
- 绝对时间或与世界的时间之差,单位为tickrelative
- 是否让玩家的时间和世界的时间保持一个差值
-
getPlayerTime
long getPlayerTime()得到玩家的客户端的当前时间,单位为tick.原文:Returns the player's current timestamp.
- 返回:
- 玩家客户端的时间,单位为tick
-
getPlayerTimeOffset
long getPlayerTimeOffset()返回玩家的客户端的当前时间与玩家当前世界时间的差值.如玩家时间是固定的,则返回玩家时间. 原文:Returns the player's current time offset relative to server time, or the current player's fixed time if the player's time is absolute.
- 返回:
- 玩家当前时间与当前世界时间的差或玩家当前时间.单位为tick
-
isPlayerTimeRelative
boolean isPlayerTimeRelative()如果玩家时间于当前世界时间保持了一定的差值则返回true.原文:Returns true if the player's time is relative to the server time, otherwise the player's time is absolute and will not change its current time unless done so with setPlayerTime().
- 返回:
- true if the player's time is relative to the server time.
-
resetPlayerTime
void resetPlayerTime()将玩家时间变为当前世界时间并与世界时间保持同步.原文 Restores the normal condition where the player's time is synchronized with the server time.
Equivalent to calling setPlayerTime(0, true).
-
setPlayerWeather
设置玩家的客户端的天气.使用
resetPlayerWeather()
来恢复正常.原文:Sets the type of weather the player will see. When used, the weather status of the player is locked until
resetPlayerWeather()
is used.- 参数:
type
- 要让玩家看到的天气
-
getPlayerWeather
得到玩家所看到的天气.如果返回null,玩家的天气跟世界的天气一致.原文:Returns the type of weather the player is currently experiencing.
- 返回:
- 玩家所看到的天气或null
-
resetPlayerWeather
void resetPlayerWeather()恢复玩家所看到的天气为世界的天气.原文:Restores the normal condition where the player's weather is controlled by server conditions.
-
getExpCooldown
int getExpCooldown()Gets the player's cooldown between picking up experience orbs.- 返回:
- The cooldown in ticks
-
setExpCooldown
void setExpCooldown(int ticks) Sets the player's cooldown between picking up experience orbs.. Note: Setting this to 0 allows the player to pick up instantly, but setting this to a negative value will cause the player to be unable to pick up xp-orbs. Calling this Method will result inPlayerExpCooldownChangeEvent
being called.- 参数:
ticks
- The cooldown in ticks
-
giveExp
void giveExp(int amount) 给玩家指定经验.原文:Gives the player the amount of experience specified.
- 参数:
amount
- 要给的经验
-
giveExpLevels
void giveExpLevels(int amount) 增加玩家的等级.支持负数(减少等级).
原文:Gives the player the amount of experience levels specified. Levels can be taken by specifying a negative amount.
- 参数:
amount
- 要增加的等级(正数)或要减少的等级(负数)
-
getExp
float getExp()得到当前级别升到下一级别经验进度的百分比.0表示毫无进展(0%), 0.99表示差一点点(99%), 1表示要升级了(100%).
原文:Gets the players current experience points towards the next level.
This is a percentage value. 0 is "no progress" and 1 is "next level".
- 返回:
- 离下一级的小数形式百分比
-
setExp
void setExp(float exp) 设置当前级别升到下一级别经验进度的百分比.0表示毫无进展(0%), 0.99表示差一点点(99%), 1表示要升级了(100%).
Sets the players current experience points towards the next level
This is a percentage value. 0 is "no progress" and 1 is "next level".
- 参数:
exp
- 新的离下一级的小数形式百分比
-
getLevel
int getLevel()得到玩家的等级.原文:Gets the players current experience level
- 返回:
- 玩家的经验等级
-
setLevel
void setLevel(int level) 设置玩家的等级. 原文:Sets the players current experience level
- 参数:
level
- 新的等级
-
getTotalExperience
int getTotalExperience()得到玩家总共获得了多少经验(等级和经验).
这个数值指玩家随着时间的推移收集的全部经验, 并且此值目前不会在客户端上显示.原文:Gets the players total experience points.
This refers to the total amount of experience the player has collected over time and is not currently displayed to the client.- 返回:
- 玩家总共有多少经验
-
setTotalExperience
void setTotalExperience(int exp) 设置玩家的总经验值(等级和经验).
这个数值指玩家随着时间的推移收集的全部经验, 并且此值目前不会在客户端上显示.原文: Sets the players current experience points.
This refers to the total amount of experience the player has collected over time and is not currently displayed to the client.- 参数:
exp
- 总经验值
-
sendExperienceChange
void sendExperienceChange(float progress) Send an experience change. This fakes an experience change packet for a user. This will not actually change the experience points in any way.- 参数:
progress
- Experience progress percentage (between 0.0 and 1.0)- 另请参阅:
-
sendExperienceChange
void sendExperienceChange(float progress, int level) Send an experience change. This fakes an experience change packet for a user. This will not actually change the experience points in any way.- 参数:
progress
- New experience progress percentage (between 0.0 and 1.0)level
- New experience level- 另请参阅:
-
getAllowFlight
boolean getAllowFlight()判断玩家是否能飞起来.译注:如果玩家确实在创造模式,那么一般返回true,除非被setAllowFlight(false).
原文:Determines if the Player is allowed to fly via jump key double-tap like in creative mode.
- 返回:
- 玩家能不能飞起来
-
setAllowFlight
void setAllowFlight(boolean flight) 设置玩家是否能够飞起来(就像创造模式).译注:如果被设置为false,即便是创造模式也不能飞.
原文:Sets if the Player is allowed to fly via jump key double-tap like in creative mode.
- 参数:
flight
- 是否允许该玩家飞行.
-
hidePlayer
已过时。让该玩家看不见某玩家.原文:Hides a player from this player
- 参数:
player
- 要让该玩家看不见的玩家.
-
hidePlayer
让该玩家看不见某玩家.原文:Hides a player from this player
- 参数:
plugin
- Plugin 要隐藏该玩家的插件player
- Player 要让该玩家看不见的玩家.
-
showPlayer
已过时。让该玩家能看到某玩家.原文:Allows this player to see a player that was previously hidden
- 参数:
player
- 要让该玩家看得见的玩家.
-
showPlayer
让该玩家能看到之前被隐藏的玩家. 如果另一个插件也隐藏了这个玩家, 那么玩家将继续处于隐藏状态直至其他插件也调用了此方法.原文:Allows this player to see a player that was previously hidden. If another another plugin had hidden the player too, then the player will remain hidden until the other plugin calls this method too.
- 参数:
plugin
- Plugin 要使某玩家现身的插件player
- Player 使某玩家现身
-
canSee
检查该玩家是否能看到某玩家.原文:Checks to see if a player has been hidden from this player
- 参数:
player
- 要检查该玩家是否能看到的玩家- 返回:
- true表示能看到,false反之.
-
hideEntity
从视觉上隐藏一个实体.原文:Visually hides an entity from this player.
- 参数:
plugin
- 要隐藏此实体的插件实例entity
- 要隐藏的实体
-
showEntity
Allows this player to see an entity that was previously hidden. If another another plugin had hidden the entity too, then the entity will remain hidden until the other plugin calls this method too.- 参数:
plugin
- Plugin that wants to show the entityentity
- Entity to show
-
canSee
Checks to see if an entity has been visually hidden from this player.- 参数:
entity
- Entity to check- 返回:
- True if the provided entity is not being hidden from this player
-
isFlying
boolean isFlying()检查玩家是否在飞.原文:Checks to see if this player is currently flying or not.
- 返回:
- true表示该玩家在飞,false反之.
-
setFlying
void setFlying(boolean value) 设置该玩家飞行状态.原文:Makes this player start or stop flying.
- 参数:
value
- true表示正在飞
-
setFlySpeed
设置该玩家飞行速度.速度为-1~1之间,负数代表玩家会反着飞...
译注:不代表行走的速度!.
原文:Sets the speed at which a client will fly. Negative values indicate reverse directions.
- 参数:
value
- 新的飞行速度,在-1~1之间.- 抛出:
IllegalArgumentException
- 如果速度不在-1~1之间则抛出.
-
setWalkSpeed
设置该玩家行走速度.速度在-1~1之间,负数代表玩家会倒着走(整人专用233~)...
译注:不代表飞行的速度! 原文:Sets the speed at which a client will walk. Negative values indicate reverse directions.
- 参数:
value
- 新的行走速度.- 抛出:
IllegalArgumentException
- 当速度不在-1~1时间则抛出
-
getFlySpeed
float getFlySpeed()得到该玩家飞行速度.译注:不代表行走速度! 原文:Gets the current allowed speed that a client can fly.
- 返回:
- 飞行速度.取值-1~1.
-
getWalkSpeed
float getWalkSpeed()得到行走速度.译注:不代表飞行速度! 原文:Gets the current allowed speed that a client can walk.
- 返回:
- 行走速度,取值-1~1
-
setTexturePack
已过时。Minecraft已经不使用材质包了,应该用setResourcePack(String)
设置资源包(额这不是一个意思么..).设置服务器材质包.(因为已过时所以不详解了).介绍同
setResourcePack(java.lang.String)
Request that the player's client download and switch texture packs.The player's client will download the new texture pack asynchronously in the background, and will automatically switch to it once the download is complete. If the client has downloaded and cached the same texture pack in the past, it will perform a file size check against the response content to determine if the texture pack has changed and needs to be downloaded again. When this request is sent for the very first time from a given server, the client will first display a confirmation GUI to the player before proceeding with the download.
Notes:
- Players can disable server textures on their client, in which
case this method will have no affect on them. Use the
PlayerResourcePackStatusEvent
to figure out whether or not the player loaded the pack! - There is no concept of resetting texture packs back to default within Minecraft, so players will have to relog to do so or you have to send an empty pack.
- The request is send with "null" as the hash. This might result in newer versions not loading the pack correctly.
- 参数:
url
- The URL from which the client will download the texture pack. The string must contain only US-ASCII characters and should be encoded as per RFC 1738.- 抛出:
IllegalArgumentException
- Thrown if the URL is null.IllegalArgumentException
- Thrown if the URL is too long.
- Players can disable server textures on their client, in which
case this method will have no affect on them. Use the
-
setResourcePack
请求玩家的客户端下载并且使用指定资源包.玩家的客户端将在后台异步下载新的资源包,并且下载完成后会自动使用那个资源包.如果 这个资源包已经下载好了,客户端先会检查给定URL的资源包跟已经下载的资源包是否一样. 如果不一样就会重新下载,一样就直接使用.
在开始下载之前,客户端会显示一个GUI确定界面,提示要不要下载资源包.如果玩家选择不要, 就不能下载.
注意:
- 如果玩家的客户端没有开启"使用服务器资源包"这个方法将失效. 使用
PlayerResourcePackStatusEvent
方法以推断玩家是否加载了你设置的资源包! - 在Minecraft中没有将资源包重置为默认的概念,所以玩家必须重新登陆才能这么做,或者你必须发送一个空白的资源包.
- 请求以空字符串作hash发送. 这可能导致较新版本的客户端不能正确加载资源包.
原文:Request that the player's client download and switch texture packs.
The player's client will download the new texture pack asynchronously in the background, and will automatically switch to it once the download is complete. If the client has downloaded and cached the same texture pack in the past, it will perform a file size check against the response content to determine if the texture pack has changed and needs to be downloaded again. When this request is sent for the very first time from a given server, the client will first display a confirmation GUI to the player before proceeding with the download.
Notes:
- Players can disable server textures on their client, in which
case this method will have no affect on them. Use the
PlayerResourcePackStatusEvent
to figure out whether or not the player loaded the pack! - There is no concept of resetting texture packs back to default within Minecraft, so players will have to relog to do so or you have to send an empty pack.
- The request is send with empty string as the hash. This might result in newer versions not loading the pack correctly.
- 参数:
url
- 资源包的URL地址.只能包含US-ASCII字符并且使用RFC 1738编码.- 抛出:
IllegalArgumentException
- 当URL为null时抛出IllegalArgumentException
- 当URL太长或者不符合规范时抛出
- 如果玩家的客户端没有开启"使用服务器资源包"这个方法将失效. 使用
-
setResourcePack
void setResourcePack(@NotNull @NotNull String url, @Nullable @org.jetbrains.annotations.Nullable byte[] hash) 请求玩家的客户端下载并且使用指定资源包.玩家的客户端将在后台异步下载新的资源包,并且下载完成后会自动使用那个资源包.如果 这个资源包已经下载好了,客户端先会检查给定URL的资源包跟已经下载的资源包是否一样. 如果不一样就会重新下载,一样就直接使用.
在开始下载之前,客户端会显示一个GUI确定界面,提示要不要下载资源包.如果玩家选择不要, 就不能下载.
注意:
- 如果玩家的客户端没有开启"使用服务器资源包"这个方法将失效. 使用
PlayerResourcePackStatusEvent
方法以推断玩家是否加载了你设置的资源包! - 在Minecraft中没有将资源包重置为默认的概念,所以玩家必须重新登陆才能这么做,或者你必须发送一个空白的资源包.
原文:Request that the player's client download and switch resource packs.
The player's client will download the new resource pack asynchronously in the background, and will automatically switch to it once the download is complete. If the client has downloaded and cached a resource pack with the same hash in the past it will not download but directly apply the cached pack. If the hash is null and the client has downloaded and cached the same resource pack in the past, it will perform a file size check against the response content to determine if the resource pack has changed and needs to be downloaded again. When this request is sent for the very first time from a given server, the client will first display a confirmation GUI to the player before proceeding with the download.
Notes:
- Players can disable server resources on their client, in which
case this method will have no affect on them. Use the
PlayerResourcePackStatusEvent
to figure out whether or not the player loaded the pack! - There is no concept of resetting resource packs back to default within Minecraft, so players will have to relog to do so or you have to send an empty pack.
- 参数:
url
- 资源包的URL地址.只能包含US-ASCII字符并且使用RFC 1738编码.hash
- 资源包文件的sha1哈希值,被用于正确地应用缓存版本的资源包而不需再重新下载(如果之前下载过).必须是20字节长!- 抛出:
IllegalArgumentException
- 当URL为null时抛出IllegalArgumentException
- 当URL太长或者不符合规范时抛出IllegalArgumentException
- 当hash为null时抛出Thrown if the hash is null.IllegalArgumentException
- 当hash不是20字节长时抛出
- 如果玩家的客户端没有开启"使用服务器资源包"这个方法将失效. 使用
-
setResourcePack
void setResourcePack(@NotNull @NotNull String url, @Nullable @org.jetbrains.annotations.Nullable byte[] hash, @Nullable @Nullable String prompt) Request that the player's client download and switch resource packs.The player's client will download the new resource pack asynchronously in the background, and will automatically switch to it once the download is complete. If the client has downloaded and cached a resource pack with the same hash in the past it will not download but directly apply the cached pack. If the hash is null and the client has downloaded and cached the same resource pack in the past, it will perform a file size check against the response content to determine if the resource pack has changed and needs to be downloaded again. When this request is sent for the very first time from a given server, the client will first display a confirmation GUI to the player before proceeding with the download.
Notes:
- Players can disable server resources on their client, in which
case this method will have no affect on them. Use the
PlayerResourcePackStatusEvent
to figure out whether or not the player loaded the pack! - To remove a resource pack you can use
removeResourcePack(UUID)
orremoveResourcePacks()
. - The request is sent with empty string as the hash when the hash is not provided. This might result in newer versions not loading the pack correctly.
- 参数:
url
- The URL from which the client will download the resource pack. The string must contain only US-ASCII characters and should be encoded as per RFC 1738.hash
- The sha1 hash sum of the resource pack file which is used to apply a cached version of the pack directly without downloading if it is available. Hast to be 20 bytes long!prompt
- The optional custom prompt message to be shown to client.- 抛出:
IllegalArgumentException
- Thrown if the URL is null.IllegalArgumentException
- Thrown if the URL is too long. The length restriction is an implementation specific arbitrary value.IllegalArgumentException
- Thrown if the hash is not 20 bytes long.
- Players can disable server resources on their client, in which
case this method will have no affect on them. Use the
-
setResourcePack
void setResourcePack(@NotNull @NotNull String url, @Nullable @org.jetbrains.annotations.Nullable byte[] hash, boolean force) Request that the player's client download and switch resource packs.The player's client will download the new resource pack asynchronously in the background, and will automatically switch to it once the download is complete. If the client has downloaded and cached a resource pack with the same hash in the past it will not download but directly apply the cached pack. If the hash is null and the client has downloaded and cached the same resource pack in the past, it will perform a file size check against the response content to determine if the resource pack has changed and needs to be downloaded again. When this request is sent for the very first time from a given server, the client will first display a confirmation GUI to the player before proceeding with the download.
Notes:
- Players can disable server resources on their client, in which
case this method will have no affect on them. Use the
PlayerResourcePackStatusEvent
to figure out whether or not the player loaded the pack! - To remove a resource pack you can use
removeResourcePack(UUID)
orremoveResourcePacks()
. - The request is sent with empty string as the hash when the hash is not provided. This might result in newer versions not loading the pack correctly.
- 参数:
url
- The URL from which the client will download the resource pack. The string must contain only US-ASCII characters and should be encoded as per RFC 1738.hash
- The sha1 hash sum of the resource pack file which is used to apply a cached version of the pack directly without downloading if it is available. Hast to be 20 bytes long!force
- If true, the client will be disconnected from the server when it declines to use the resource pack.- 抛出:
IllegalArgumentException
- Thrown if the URL is null.IllegalArgumentException
- Thrown if the URL is too long. The length restriction is an implementation specific arbitrary value.IllegalArgumentException
- Thrown if the hash is not 20 bytes long.
- Players can disable server resources on their client, in which
case this method will have no affect on them. Use the
-
setResourcePack
void setResourcePack(@NotNull @NotNull String url, @Nullable @org.jetbrains.annotations.Nullable byte[] hash, @Nullable @Nullable String prompt, boolean force) Request that the player's client download and switch resource packs.The player's client will download the new resource pack asynchronously in the background, and will automatically switch to it once the download is complete. If the client has downloaded and cached a resource pack with the same hash in the past it will not download but directly apply the cached pack. If the hash is null and the client has downloaded and cached the same resource pack in the past, it will perform a file size check against the response content to determine if the resource pack has changed and needs to be downloaded again. When this request is sent for the very first time from a given server, the client will first display a confirmation GUI to the player before proceeding with the download.
Notes:
- Players can disable server resources on their client, in which
case this method will have no affect on them. Use the
PlayerResourcePackStatusEvent
to figure out whether or not the player loaded the pack! - To remove a resource pack you can use
removeResourcePack(UUID)
orremoveResourcePacks()
. - The request is sent with empty string as the hash when the hash is not provided. This might result in newer versions not loading the pack correctly.
- 参数:
url
- The URL from which the client will download the resource pack. The string must contain only US-ASCII characters and should be encoded as per RFC 1738.hash
- The sha1 hash sum of the resource pack file which is used to apply a cached version of the pack directly without downloading if it is available. Hast to be 20 bytes long!prompt
- The optional custom prompt message to be shown to client.force
- If true, the client will be disconnected from the server when it declines to use the resource pack.- 抛出:
IllegalArgumentException
- Thrown if the URL is null.IllegalArgumentException
- Thrown if the URL is too long. The length restriction is an implementation specific arbitrary value.IllegalArgumentException
- Thrown if the hash is not 20 bytes long.
- Players can disable server resources on their client, in which
case this method will have no affect on them. Use the
-
setResourcePack
void setResourcePack(@NotNull @NotNull UUID id, @NotNull @NotNull String url, @Nullable @org.jetbrains.annotations.Nullable byte[] hash, @Nullable @Nullable String prompt, boolean force) Request that the player's client download and switch resource packs.The player's client will download the new resource pack asynchronously in the background, and will automatically switch to it once the download is complete. If the client has downloaded and cached a resource pack with the same hash in the past it will not download but directly apply the cached pack. If the hash is null and the client has downloaded and cached the same resource pack in the past, it will perform a file size check against the response content to determine if the resource pack has changed and needs to be downloaded again. When this request is sent for the very first time from a given server, the client will first display a confirmation GUI to the player before proceeding with the download.
Notes:
- Players can disable server resources on their client, in which
case this method will have no affect on them. Use the
PlayerResourcePackStatusEvent
to figure out whether or not the player loaded the pack! - To remove a resource pack you can use
removeResourcePack(UUID)
orremoveResourcePacks()
. - The request is sent with empty string as the hash when the hash is not provided. This might result in newer versions not loading the pack correctly.
- 参数:
id
- Unique resource pack ID.url
- The URL from which the client will download the resource pack. The string must contain only US-ASCII characters and should be encoded as per RFC 1738.hash
- The sha1 hash sum of the resource pack file which is used to apply a cached version of the pack directly without downloading if it is available. Hast to be 20 bytes long!prompt
- The optional custom prompt message to be shown to client.force
- If true, the client will be disconnected from the server when it declines to use the resource pack.- 抛出:
IllegalArgumentException
- Thrown if the URL is null.IllegalArgumentException
- Thrown if the URL is too long. The length restriction is an implementation specific arbitrary value.IllegalArgumentException
- Thrown if the hash is not 20 bytes long.
- Players can disable server resources on their client, in which
case this method will have no affect on them. Use the
-
addResourcePack
void addResourcePack(@NotNull @NotNull UUID id, @NotNull @NotNull String url, @Nullable @org.jetbrains.annotations.Nullable byte[] hash, @Nullable @Nullable String prompt, boolean force) Request that the player's client download and include another resource pack.The player's client will download the new resource pack asynchronously in the background, and will automatically add to it once the download is complete. If the client has downloaded and cached a resource pack with the same hash in the past it will not download but directly apply the cached pack. If the hash is null and the client has downloaded and cached the same resource pack in the past, it will perform a file size check against the response content to determine if the resource pack has changed and needs to be downloaded again. When this request is sent for the very first time from a given server, the client will first display a confirmation GUI to the player before proceeding with the download.
Notes:
- Players can disable server resources on their client, in which
case this method will have no affect on them. Use the
PlayerResourcePackStatusEvent
to figure out whether or not the player loaded the pack! - To remove a resource pack you can use
removeResourcePack(UUID)
orremoveResourcePacks()
. - The request is sent with empty string as the hash when the hash is not provided. This might result in newer versions not loading the pack correctly.
- 参数:
id
- Unique resource pack ID.url
- The URL from which the client will download the resource pack. The string must contain only US-ASCII characters and should be encoded as per RFC 1738.hash
- The sha1 hash sum of the resource pack file which is used to apply a cached version of the pack directly without downloading if it is available. Hast to be 20 bytes long!prompt
- The optional custom prompt message to be shown to client.force
- If true, the client will be disconnected from the server when it declines to use the resource pack.- 抛出:
IllegalArgumentException
- Thrown if the URL is null.IllegalArgumentException
- Thrown if the URL is too long. The length restriction is an implementation specific arbitrary value.IllegalArgumentException
- Thrown if the hash is not 20 bytes long.
- Players can disable server resources on their client, in which
case this method will have no affect on them. Use the
-
removeResourcePack
Request that the player's client remove a resource pack sent by the server.- 参数:
id
- the id of the resource pack.- 抛出:
IllegalArgumentException
- If the ID is null.
-
removeResourcePacks
void removeResourcePacks()Request that the player's client remove all loaded resource pack sent by the server. -
getScoreboard
获取玩家的计分板.原文:Gets the Scoreboard displayed to this player
- 返回:
- The current scoreboard seen by this player
-
setScoreboard
void setScoreboard(@NotNull @NotNull Scoreboard scoreboard) throws IllegalArgumentException, IllegalStateException 设置玩家的计分板.原文:Sets the player's visible Scoreboard.
- 参数:
scoreboard
- 要设置成的计分板- 抛出:
IllegalArgumentException
- 如果计分板为null则抛出IllegalArgumentException
- 如果计分板不是由scoreboard manager
创建的 则抛出.IllegalStateException
- 如果没有该玩家的数据,即该玩家没有进入过服务器则抛出.
-
getWorldBorder
Gets theWorldBorder
visible to this Player, or null if viewing the world's world border.- 返回:
- the player's world border
-
setWorldBorder
Sets theWorldBorder
visible to this Player.- 参数:
border
- the border to set, or null to set to the world border of the player's current world- 抛出:
UnsupportedOperationException
- if setting the border to that of a world in which the player is not currently present.- 另请参阅:
-
sendHealthUpdate
void sendHealthUpdate(double health, int foodLevel, float saturation) Send a health update to the player. This will adjust the health, food, and saturation on the client and will not affect the player's actual values on the server. As soon as any of these values change on the server, changes sent by this method will no longer be visible.- 参数:
health
- the health. If 0.0, the client will believe it is deadfoodLevel
- the food levelsaturation
- the saturation
-
sendHealthUpdate
void sendHealthUpdate()Send a health update to the player using its known server values. This will synchronize the health, food, and saturation on the client and therefore may be useful when changing a player's maximum health attribute. -
isHealthScaled
boolean isHealthScaled()获取客户端显示的玩家血量是否被"压缩"了.译注:当玩家的最大血量过多时(
Damageable.setMaxHealth(double)
),每一排血量将会被 挤在一起,以免挡住玩家的视线,这就是"压缩".这个方法就是判断血量是否被压缩了.(完全没用的说..).原文:Gets if the client is displayed a 'scaled' health, that is, health on a scale from 0-
getHealthScale()
.- 返回:
- 客户端显示的血量是否被压缩了
- 另请参阅:
-
setHealthScaled
void setHealthScaled(boolean scale) 设置客户端是否要显示一个"压缩"了的血量.显示的血量遵循一个规则:
显示的血量 = getHealth() / getMaxHealth() * getHealthScale()
.译注:当玩家的最大血量过多时(
Damageable.setMaxHealth(double)
),每一排血量将会被 挤在一起,以免挡住玩家的视线,这就是"压缩".这个方法就是设置血量是否要被"压缩".(完全没用的说..).原文:Sets if the client is displayed a 'scaled' health, that is, health on a scale from 0-
getHealthScale()
.Displayed health follows a simple formula
displayedHealth = getHealth() / getMaxHealth() * getHealthScale()
.- 参数:
scale
- 血量是否要被压缩
-
setHealthScale
设置客户端显示的血量的"压缩率".显示的血量遵循一个规则:
显示的血量 = getHealth() / getMaxHealth() * getHealthScale()
.译注:当玩家的最大血量过多时(
Damageable.setMaxHealth(double)
),每一排血量将会被 挤在一起,以免挡住玩家的视线,这就是"压缩".这个方法就是设置血量的"压缩率".(完全没用的说..).原文:Sets the number to scale health to for the client; this will also
setHealthScaled(true)
.Displayed health follows a simple formula
displayedHealth = getHealth() / getMaxHealth() * getHealthScale()
.- 参数:
scale
- 血量的"压缩率"- 抛出:
IllegalArgumentException
- 如果scale <0IllegalArgumentException
- 如果scale为Double.NaN
IllegalArgumentException
- 如果scale太大了
-
getHealthScale
double getHealthScale()获取客户端显示的血量的"压缩率".详见
setHealthScale(double)
原文:Gets the number that health is scaled to for the client.- 返回:
- 客户端显示的血量条的"压缩率"
- 另请参阅:
-
getSpectatorTarget
获取旁观者模式下镜头跟随的实体.原文:Gets the entity which is followed by the camera when in
GameMode.SPECTATOR
.- 返回:
- 正在跟随的实体, 如果未跟随实体或不处于旁观者模式返回null
-
setSpectatorTarget
设置模式下镜头跟随的实体.原文:Sets the entity which is followed by the camera when in
GameMode.SPECTATOR
.- 参数:
entity
- 要跟随的实体, 设为null重置- 抛出:
IllegalStateException
- 若玩家不处于旁观者模式
-
sendTitle
已过时。API行为有所改变向玩家发送屏幕标题.如果标题和副标题内容都为null, 那么标题将不会被发送出去, 玩家的屏幕也不会有变化. 如果这些参数是空字符串(注意空字符串与null有区别), 那么玩家的屏幕将会被更新(本质上讲, 虽然看起来没啥变化) 如果字符串包含多行文本, 那么只有第一行文本才会被发送出去. 标题将以玩家客户端默认的淡入淡出时间显示.原文:Sends a title and a subtitle message to the player. If either of these values are null, they will not be sent and the display will remain unchanged. If they are empty strings, the display will be updated as such. If the strings contain a new line, only the first line will be sent. be displayed with the client's default timings.
- 参数:
title
- 标题文本subtitle
- 副标题文本
-
sendTitle
void sendTitle(@Nullable @Nullable String title, @Nullable @Nullable String subtitle, int fadeIn, int stay, int fadeOut) 向玩家发送屏幕标题.如果标题和副标题内容都为null, 那么标题将不会被发送出去, 玩家的屏幕也不会有变化. 如果这些参数是空字符串(注意空字符串与null有区别), 那么玩家的屏幕将会被更新(本质上讲, 虽然看起来没啥变化) 如果字符串包含多行文本, 那么只有第一行文本才会被发送出去. 所有时间值都可以取-1来表示最后一次(或者上一次)发送标题所用的值(如果尚无任何标题曾被显示过则取默认值).原文:Sends a title and a subtitle message to the player. If either of these values are null, they will not be sent and the display will remain unchanged. If they are empty strings, the display will be updated as such. If the strings contain a new line, only the first line will be sent. All timings values may take a value of -1 to indicate that they will use the last value sent (or the defaults if no title has been displayed).
- 参数:
title
- 标题文本subtitle
- 副标题文本fadeIn
- 标题淡入时间,以tick为单位.默认值取10.stay
- 标题停留/展示时长,以tick为单位.默认值取70.fadeOut
- 标题淡出时间,以tick为单位.默认值取20.
-
resetTitle
void resetTitle()重置想转玩家显示的屏幕标题. 这将清除已显示的标题/副标题并重置标题显示计时器至默认值.原文:Resets the title displayed to the player. This will clear the displayed title / subtitle and reset timings to their default values.
-
spawnParticle
void spawnParticle(@NotNull @NotNull Particle particle, @NotNull @NotNull Location location, int count) 在指定位置产生粒子效果 (the number of times specified by count).原文:Sawns the particle (the number of times specified by count) at the target location.
- 参数:
particle
- 要产生的粒子效果location
- 粒子效果产生位置count
- the number of particles
-
spawnParticle
在指定位置产生粒子效果 (the number of times specified by count).原文:Sawns the particle (the number of times specified by count) at the target location.
- 参数:
particle
- 要产生的粒子效果x
- 粒子效果产生位置x轴y
- 粒子效果产生位置y轴z
- 粒子效果产生位置z轴count
- the number of particles
-
spawnParticle
<T> void spawnParticle(@NotNull @NotNull Particle particle, @NotNull @NotNull Location location, int count, @Nullable T data) 在指定位置产生粒子效果 (the number of times specified by count).原文:Sawns the particle (the number of times specified by count) at the target location.
- 类型参数:
T
- 粒子效果数据类型 (请参阅Particle.getDataType()
- 参数:
particle
- 要产生的粒子效果location
- 粒子效果产生位置count
- 粒子数目data
- 粒子效果的数据或null, 其数据类型取决于Particle.getDataType()
-
spawnParticle
<T> void spawnParticle(@NotNull @NotNull Particle particle, double x, double y, double z, int count, @Nullable T data) Spawns the particle (the number of times specified by count) at the target location.- 类型参数:
T
- 粒子效果数据类型 (请参阅Particle.getDataType()
- 参数:
particle
- the particle to spawnx
- the position on the x axis to spawn aty
- the position on the y axis to spawn atz
- the position on the z axis to spawn atcount
- the number of particlesdata
- 粒子效果的数据或null, 其数据类型取决于Particle.getDataType()
-
spawnParticle
void spawnParticle(@NotNull @NotNull Particle particle, @NotNull @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ) Spawns the particle (the number of times specified by count) at the target location. The position of each particle will be randomized positively and negatively by the offset parameters on each axis.- 参数:
particle
- the particle to spawnlocation
- the location to spawn atcount
- the number of particlesoffsetX
- the maximum random offset on the X axisoffsetY
- the maximum random offset on the Y axisoffsetZ
- the maximum random offset on the Z axis
-
spawnParticle
void spawnParticle(@NotNull @NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ) Spawns the particle (the number of times specified by count) at the target location. The position of each particle will be randomized positively and negatively by the offset parameters on each axis.- 参数:
particle
- the particle to spawnx
- the position on the x axis to spawn aty
- the position on the y axis to spawn atz
- the position on the z axis to spawn atcount
- the number of particlesoffsetX
- the maximum random offset on the X axisoffsetY
- the maximum random offset on the Y axisoffsetZ
- the maximum random offset on the Z axis
-
spawnParticle
<T> void spawnParticle(@NotNull @NotNull Particle particle, @NotNull @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, @Nullable T data) Spawns the particle (the number of times specified by count) at the target location. The position of each particle will be randomized positively and negatively by the offset parameters on each axis.- 类型参数:
T
- 粒子效果数据类型 (请参阅Particle.getDataType()
- 参数:
particle
- the particle to spawnlocation
- the location to spawn atcount
- the number of particlesoffsetX
- the maximum random offset on the X axisoffsetY
- the maximum random offset on the Y axisoffsetZ
- the maximum random offset on the Z axisdata
- 粒子效果的数据或null, 其数据类型取决于Particle.getDataType()
-
spawnParticle
<T> void spawnParticle(@NotNull @NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, @Nullable T data) Spawns the particle (the number of times specified by count) at the target location. The position of each particle will be randomized positively and negatively by the offset parameters on each axis.- 类型参数:
T
- 粒子效果数据类型 (请参阅Particle.getDataType()
- 参数:
particle
- the particle to spawnx
- the position on the x axis to spawn aty
- the position on the y axis to spawn atz
- the position on the z axis to spawn atcount
- the number of particlesoffsetX
- the maximum random offset on the X axisoffsetY
- the maximum random offset on the Y axisoffsetZ
- the maximum random offset on the Z axisdata
- 粒子效果的数据或null, 其数据类型取决于Particle.getDataType()
-
spawnParticle
void spawnParticle(@NotNull @NotNull Particle particle, @NotNull @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra) Spawns the particle (the number of times specified by count) at the target location. The position of each particle will be randomized positively and negatively by the offset parameters on each axis.- 参数:
particle
- the particle to spawnlocation
- the location to spawn atcount
- the number of particlesoffsetX
- the maximum random offset on the X axisoffsetY
- the maximum random offset on the Y axisoffsetZ
- the maximum random offset on the Z axisextra
- the extra data for this particle, depends on the particle used (normally speed)
-
spawnParticle
void spawnParticle(@NotNull @NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra) Spawns the particle (the number of times specified by count) at the target location. The position of each particle will be randomized positively and negatively by the offset parameters on each axis.- 参数:
particle
- the particle to spawnx
- the position on the x axis to spawn aty
- the position on the y axis to spawn atz
- the position on the z axis to spawn atcount
- the number of particlesoffsetX
- the maximum random offset on the X axisoffsetY
- the maximum random offset on the Y axisoffsetZ
- the maximum random offset on the Z axisextra
- the extra data for this particle, depends on the particle used (normally speed)
-
spawnParticle
<T> void spawnParticle(@NotNull @NotNull Particle particle, @NotNull @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, @Nullable T data) Spawns the particle (the number of times specified by count) at the target location. The position of each particle will be randomized positively and negatively by the offset parameters on each axis.- 类型参数:
T
- 粒子效果数据类型 (请参阅Particle.getDataType()
- 参数:
particle
- the particle to spawnlocation
- the location to spawn atcount
- the number of particlesoffsetX
- the maximum random offset on the X axisoffsetY
- the maximum random offset on the Y axisoffsetZ
- the maximum random offset on the Z axisextra
- the extra data for this particle, depends on the particle used (normally speed)data
- 粒子效果的数据或null, 其数据类型取决于Particle.getDataType()
-
spawnParticle
<T> void spawnParticle(@NotNull @NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, @Nullable T data) Spawns the particle (the number of times specified by count) at the target location. The position of each particle will be randomized positively and negatively by the offset parameters on each axis.- 类型参数:
T
- 粒子效果数据类型 (请参阅Particle.getDataType()
- 参数:
particle
- the particle to spawnx
- the position on the x axis to spawn aty
- the position on the y axis to spawn atz
- the position on the z axis to spawn atcount
- the number of particlesoffsetX
- the maximum random offset on the X axisoffsetY
- the maximum random offset on the Y axisoffsetZ
- the maximum random offset on the Z axisextra
- the extra data for this particle, depends on the particle used (normally speed)data
- 粒子效果的数据或null, 其数据类型取决于Particle.getDataType()
-
spawnParticle
<T> void spawnParticle(@NotNull @NotNull Particle particle, @NotNull @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, @Nullable T data, boolean force) Spawns the particle (the number of times specified by count) at the target location. The position of each particle will be randomized positively and negatively by the offset parameters on each axis.- 类型参数:
T
- type of particle data (seeParticle.getDataType()
- 参数:
particle
- the particle to spawnlocation
- the location to spawn atcount
- the number of particlesoffsetX
- the maximum random offset on the X axisoffsetY
- the maximum random offset on the Y axisoffsetZ
- the maximum random offset on the Z axisextra
- the extra data for this particle, depends on the particle used (normally speed)data
- the data to use for the particle or null, the type of this depends onParticle.getDataType()
force
- whether to send the particle to the player in an extended range and encourage their client to render it regardless of settings
-
spawnParticle
<T> void spawnParticle(@NotNull @NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, @Nullable T data, boolean force) Spawns the particle (the number of times specified by count) at the target location. The position of each particle will be randomized positively and negatively by the offset parameters on each axis.- 类型参数:
T
- type of particle data (seeParticle.getDataType()
- 参数:
particle
- the particle to spawnx
- the position on the x axis to spawn aty
- the position on the y axis to spawn atz
- the position on the z axis to spawn atcount
- the number of particlesoffsetX
- the maximum random offset on the X axisoffsetY
- the maximum random offset on the Y axisoffsetZ
- the maximum random offset on the Z axisextra
- the extra data for this particle, depends on the particle used (normally speed)data
- the data to use for the particle or null, the type of this depends onParticle.getDataType()
force
- whether to send the particle to the player in an extended range and encourage their client to render it regardless of settings
-
getAdvancementProgress
@NotNull @NotNull AdvancementProgress getAdvancementProgress(@NotNull @NotNull Advancement advancement) 返回玩家指定进度的完成进度. 原文:Return the player's progression on the specified advancement.- 参数:
advancement
- 进度- 返回:
- 有关玩家进度的详细信息
-
getClientViewDistance
int getClientViewDistance()Get the player's current client side view distance.
Will default to the server view distance if the client has not yet communicated this information,- 返回:
- client view distance as above
-
getPing
int getPing()Gets the player's estimated ping in milliseconds. In Vanilla this value represents a weighted average of the response time to application layer ping packets sent. This value does not represent the network round trip time and as such may have less granularity and be impacted by other sources. For these reasons it should not be used for anti-cheat purposes. Its recommended use is only as a qualitative indicator of connection quality (Vanilla uses it for this purpose in the tab list).- 返回:
- player ping
-
getLocale
返回玩家本地语言环境. 语言环境值的格式尚未被适当地定义.
原生 Minecraft 客户端将使用全小写 语言/国家, 用短下划线分隔. 但自定义资源包可能会使用他们想要的任意格式.原文:Gets the player's current locale. The value of the locale String is not defined properly.
The vanilla Minecraft client will use lowercase language / country pairs separated by an underscore, but custom resource packs may use any format they wish.- 返回:
- 玩家语言环境
-
updateCommands
void updateCommands()Update the list of commands sent to the client.
Generally useful to ensure the client has a complete list of commands after permission changes are done. -
openBook
为玩家打开一本成书
.原文:Open a
Material.WRITTEN_BOOK
for a Player- 参数:
book
- 要为玩家打开的书
-
openSign
Open a Sign for editing by the Player. The Sign must be placed in the same world as the player.- 参数:
sign
- The sign to edit
-
openSign
Open a Sign for editing by the Player. The Sign must be placed in the same world as the player.- 参数:
sign
- The sign to editside
- The side to edit
-
showDemoScreen
void showDemoScreen()Shows the demo screen to the player, this screen is normally only seen in the demo version of the game.
Servers can modify the text on this screen using a resource pack. -
isAllowingServerListings
boolean isAllowingServerListings()Gets whether the player has the "Allow Server Listings" setting enabled.- 返回:
- whether the player allows server listings
-
spigot
- 指定者:
spigot
在接口中CommandSender
- 指定者:
spigot
在接口中Entity
-