public interface Player extends Humanoid, User, RemoteSource, Viewer, ChatTypeMessageReceiver
Any methods called on Player that are not on User do not store any data that persists across server restarts.
UNKNOWN
Modifier and Type | Method and Description |
---|---|
boolean |
closeInventory()
Closes the currently viewed entity of this player, if it is currently
viewing one.
|
default Value<Instant> |
firstPlayed()
|
default Value<GameMode> |
gameMode()
|
ChatVisibility |
getChatVisibility()
Gets the current player chat visibility setting.
|
PlayerConnection |
getConnection()
Gets the appropriate
PlayerConnection linking this Player
to a client. |
CooldownTracker |
getCooldownTracker()
Gets the
CooldownTracker for this player, allowing control
over the player's item cooldowns. |
Set<SkinPart> |
getDisplayedSkinParts()
Gets the skin parts that this player has allowed to render.
|
default DisplayNameData |
getDisplayNameData()
Gets a copy of the current
DisplayNameData for this
Player . |
Inventory |
getEnderChestInventory()
Gets the
Inventory available for this Player's shared EnderChest
contents. |
default GameModeData |
getGameModeData()
Gets a copy of the current
GameModeData for this Player . |
default JoinData |
getJoinData()
Gets a copy of the current
JoinData . |
Optional<Container> |
getOpenInventory()
Gets the currently viewed inventory of this player, if it is
currently viewing one.
|
AdvancementProgress |
getProgress(Advancement advancement)
Gets the
AdvancementProgress for the
specified Advancement . |
Scoreboard |
getScoreboard()
Gets the
Scoreboard displayed to the player. |
Optional<Entity> |
getSpectatorTarget()
Gets the
Entity followed by the camera when in the
spectator gamemode . |
TabList |
getTabList()
Gets this player's
TabList . |
Collection<AdvancementTree> |
getUnlockedAdvancementTrees()
Gets all the
AdvancementTree s that this
Player already unlocked. |
int |
getViewDistance()
Gets the view distance setting of the player.
|
Optional<WorldBorder> |
getWorldBorder()
Gets the
WorldBorder for this player, if present. |
default boolean |
hasPlayedBefore()
|
boolean |
isChatColorsEnabled()
Gets whether the player has colors enabled in chat.
|
boolean |
isSleepingIgnored()
Gets whether this
Player will be ignored when checking whether to
skip the night due to players sleeping. |
default boolean |
isViewingInventory()
Returns whether this player has an open inventory at the moment
or not.
|
void |
kick()
Kicks the player, showing the default kick reason (the translation key
disconnect.disconnected ). |
void |
kick(Text reason)
Kicks the player given a reason.
|
default Value<Instant> |
lastPlayed()
|
Optional<Container> |
openInventory(Inventory inventory)
Opens the given Inventory for the player to view.
|
Optional<Container> |
openInventory(Inventory inventory,
Text displayName)
Opens a given Inventory for the player to view with a custom displayName.
|
boolean |
respawnPlayer()
Manually respawns the player.
|
void |
sendResourcePack(ResourcePack pack)
Sends a given
ResourcePack to this player. |
void |
setScoreboard(Scoreboard scoreboard)
Sets the
Scoreboard displayed to the player. |
void |
setSleepingIgnored(boolean sleepingIgnored)
Sets whether this
Player will be ignored when checking whether
to skip the night due to players sleeping. |
void |
setSpectatorTarget(Entity entity)
Sets the
Entity followed by the camera when in the
spectator gamemode . |
void |
setWorldBorder(WorldBorder border,
Cause cause)
Sets the
WorldBorder instance for this player to the given world
border. |
MessageChannelEvent.Chat |
simulateChat(Text message,
Cause cause)
Simulates a chat message from a player.
|
exhaustion, foodLevel, getFoodData, saturation
getDamageableData, getHeadRotation, getHealthData, health, lastAttacker, lastDamage, lookAt, maxHealth, setHeadRotation
addPassenger, addTag, canSee, clearPassengers, createArchetype, createSnapshot, damage, getBaseVehicle, getBoundingBox, getCreator, getNearbyEntities, getNearbyEntities, getNotifier, getPassengers, getRandom, getRotation, getScale, getTags, getTransform, getType, getVehicle, getVelocity, gravity, hasPassenger, hasTag, isLoaded, isOnGround, isRemoved, remove, removePassenger, removeTag, setCreator, setLocation, setLocationAndRotation, setLocationAndRotation, setLocationAndRotationSafely, setLocationAndRotationSafely, setLocationSafely, setNotifier, setRotation, setScale, setTransform, setTransformSafely, setVehicle, setVelocity, transferToWorld, transferToWorld, transferToWorld, transferToWorld
getLocation, getWorld
setRawData, validateRawData
getContentVersion, toContainer
getApplicableProperties, getProperty
copyFrom, copyFrom, get, getContainers, getOrCreate, offer, offer, offer, offer, offer, offer, remove, remove, remove, require, supports, transform, tryOffer, tryOffer, tryOffer, tryOffer, undo
copy, get, getKeys, getOrElse, getOrNull, getValue, getValues, require, supports, supports
getTranslation
launchProjectile, launchProjectile
getTeamRepresentation
getName, getPlayer, getPosition, getProfile, getRotation, getStatisticData, getWorldUniqueId, isOnline, setLocation, setRotation
getBoots, getChestplate, getHelmet, getItemInHand, getLeggings, setBoots, setChestplate, setHelmet, setItemInHand, setLeggings
canEquip, canEquip, equip, getEquipped
getInventory
getLocale, getName
getMessageChannel, sendMessage, sendMessage, sendMessage, sendMessages, sendMessages, setMessageChannel
asSubjectReference, getCommandSource, getContainingCollection, getOption, getOption, getParents, getParents, getPermissionValue, getSubjectData, getTransientSubjectData, hasPermission, hasPermission, isChildOf, isChildOf, isSubjectDataPersisted
getActiveContexts, getFriendlyIdentifier, getIdentifier
clearTitle, playRecord, playSound, playSound, playSound, playSound, playSound, playSound, resetBlockChange, resetBlockChange, resetTitle, sendBlockChange, sendBlockChange, sendBookView, sendTitle, spawnParticles, spawnParticles, stopRecord, stopSounds, stopSounds, stopSounds, stopSounds
sendMessage, sendMessage, sendMessage, sendMessages, sendMessages
default boolean isViewingInventory()
Optional<Container> getOpenInventory()
Optional.empty()
Optional<Container> openInventory(Inventory inventory) throws IllegalArgumentException
inventory
- The inventory to viewOptional.empty()
IllegalArgumentException
- if a PluginContainer
is not the
root of the causeOptional<Container> openInventory(Inventory inventory, Text displayName)
Note that not all inventories support a custom display name.
inventory
- The inventory to viewdisplayName
- The display name to setOptional.empty()
boolean closeInventory() throws IllegalArgumentException
IllegalArgumentException
- if a PluginContainer
is not the
root of the causeint getViewDistance()
ChatVisibility getChatVisibility()
boolean isChatColorsEnabled()
MessageChannelEvent.Chat simulateChat(Text message, Cause cause)
This method sends a message as if it came from this player.
To send a message to this player instead, see
MessageReceiver.sendMessage(Text)
or
ChatTypeMessageReceiver.sendMessage(ChatType, Text)
.
Commands cannot be sent using this method. To send commands, use
CommandManager.process(CommandSource, String)
.
If text formatting is not supported in the implementation it will be displayed as plain text.
message
- The message to sendcause
- The cause for the messageSet<SkinPart> getDisplayedSkinParts()
PlayerConnection getConnection()
PlayerConnection
linking this Player
to a client.getConnection
in interface RemoteSource
void sendResourcePack(ResourcePack pack)
ResourcePack
to this player.pack
- The ResourcePack to sendvoid kick()
disconnect.disconnected
).void kick(Text reason)
reason
- The reason for the kickScoreboard getScoreboard()
Scoreboard
displayed to the player.void setScoreboard(Scoreboard scoreboard)
Scoreboard
displayed to the player.scoreboard
- The scoreboard to displaydefault JoinData getJoinData()
JoinData
.
Since a Player
is already online, it means that the player
has joined the server at least once, meaning there is a guaranteed
initial join Instant
. Users may not have ever joined a server
before.
default Value<Instant> firstPlayed()
default boolean hasPlayedBefore()
default DisplayNameData getDisplayNameData()
DisplayNameData
for this
Player
.default GameModeData getGameModeData()
GameModeData
for this Player
.boolean isSleepingIgnored()
Player
will be ignored when checking whether to
skip the night due to players sleeping. The time in a world will be
advanced to day if all players in it either are sleeping or have this
tag.Player
will be ignored when checking whether
to skip the nightvoid setSleepingIgnored(boolean sleepingIgnored)
Player
will be ignored when checking whether
to skip the night due to players sleeping. The time in a world will be
advanced to day if all players in it either are sleeping or have this
tag.sleepingIgnored
- Whether this Player
will be ignored when
checking whether to skip the nightInventory getEnderChestInventory()
Inventory
available for this Player's shared EnderChest
contents.getEnderChestInventory
in interface User
boolean respawnPlayer()
If the player is not dead, this method will return false
Optional<Entity> getSpectatorTarget()
Entity
followed by the camera when in the
spectator gamemode
.void setSpectatorTarget(@Nullable Entity entity)
Entity
followed by the camera when in the
spectator gamemode
.entity
- The entity to spectateOptional<WorldBorder> getWorldBorder()
WorldBorder
for this player, if present. If no border is
set, an empty Optional
is returned.WorldBorder
of this player as an Optional
, if
presentvoid setWorldBorder(@Nullable WorldBorder border, Cause cause)
WorldBorder
instance for this player to the given world
border. If null
is passed, the world border is unset.border
- The world border to be used, may be null
cause
- The cause of the border's changeCooldownTracker getCooldownTracker()
CooldownTracker
for this player, allowing control
over the player's item cooldowns.AdvancementProgress getProgress(Advancement advancement)
AdvancementProgress
for the
specified Advancement
.advancement
- The advancementCollection<AdvancementTree> getUnlockedAdvancementTrees()
AdvancementTree
s that this
Player
already unlocked.