endstone::Player
Represents a player.
Bases: endstone::Mob
, endstone::OfflinePlayer
Functions:
Name | Description |
---|---|
closeForm | Closes the forms that are currently open for the player. |
getAddress | Gets the socket address of this player. |
getAllowFlight | Determines if the Player is allowed to fly via jump key double-tap. |
getDeviceId | Gets the player’s current device id. |
getDeviceOS | Gets the player’s current device’s operation system (OS). |
getEnderChest | Get the player’s EnderChest inventory. |
getExpLevel | Gets the players current experience level. |
getExpProgress | Gets the players current experience progress towards the next level. |
getFlySpeed | Gets the current allowed speed that a client can fly. |
getGameMode | Gets this player’s current GameMode . |
getGameVersion | Gets the player’s current game version. |
getInventory | Get the player’s inventory. |
getLocale | Gets the player’s current locale. |
getName | Returns the name of this player. |
getPing | Gets the player’s average ping. |
getScoreboard | Gets the Scoreboard displayed to this player. |
getSkin | Gets the player’s skin. |
getTotalExp | Gets the players total experience points. |
getWalkSpeed | Gets the current allowed speed that a client can walk. |
getXuid | Returns the Xbox User ID (XUID) of this player. |
giveExp | Gives the player the amount of experience specified. |
giveExpLevels | Gives the player the amount of experience levels specified. |
isFlying | Checks to see if this player is currently flying or not. |
isOp | Checks if this player is a server operator. |
isSneaking | Returns if the player is in sneak mode. |
isSprinting | Gets whether the player is sprinting or not. |
kick | Kicks player with custom kick message. |
performCommand | Makes the player perform the given command. |
playSound | Play a sound for a player at the location. |
resetTitle | Resets the title displayed to the player. This will clear the displayed title / subtitle and reset timings to their default values. |
sendForm | Sends a form to the player. |
sendPacket | Sends a packet to the player. |
sendPopup | Sends this player a popup message. |
sendTip | Sends this player a tip message. |
sendTitle | Sends a title and a subtitle message to the player. If they are empty strings, the display will be updated as such. The titles will be displayed with the default timings. |
sendTitle | Sends a title and a subtitle message to the player. If they are empty strings, the display will be updated as such. |
sendToast | Sends this player a toast notification. |
setAllowFlight | Sets if the Player is allowed to fly via jump key double-tap. |
setExpLevel | Sets the players current experience level. |
setExpProgress | Sets the players current experience progress towards the next level. |
setFlySpeed | |
setFlying | Makes this player start or stop flying. |
setGameMode | Sets this player’s current GameMode . |
setOp | Sets the operator status of this player. |
setScoreboard | |
setSneaking | Sets the sneak mode of the player. |
setSprinting | Sets whether the player is sprinting or not. |
setWalkSpeed | |
spawnParticle | Spawns the particle at the target location. |
spawnParticle | Spawns the particle at the target location. |
spawnParticle | Spawns the particle at the target location. |
spawnParticle | Spawns the particle at the target location. |
stopAllSounds | Stop all sounds from playing. |
stopSound | Stop the specified sound from playing. |
transfer | Transfers the player to another server. |
updateCommands | Send the list of commands to the client. |
closeForm
void closeForm()
Closes the forms that are currently open for the player.
getAddress
SocketAddress getAddress() const
Gets the socket address of this player.
Returns:
the player’s socket address
getAllowFlight
bool getAllowFlight() const
Determines if the Player is allowed to fly via jump key double-tap.
Returns:
True if the player is allowed to fly.
getDeviceId
std::string getDeviceId() const
Gets the player’s current device id.
Returns:
the player’s device id
getDeviceOS
std::string getDeviceOS() const
Gets the player’s current device’s operation system (OS).
Returns:
the player’s device OS
getEnderChest
Inventory &getEnderChest() const
Get the player’s EnderChest inventory.
Returns:
The EnderChest of the player
getExpLevel
int getExpLevel() const
Gets the players current experience level.
Returns:
Current experience level
getExpProgress
float getExpProgress() const
Gets the players current experience progress towards the next level.
This is a percentage value. 0.0 is “no progress” and 1.0 is “next level”.
Returns:
Current experience points
getFlySpeed
float getFlySpeed() const
Gets the current allowed speed that a client can fly.
Returns:
The current allowed speed, default is 0.05.
getGameMode
GameMode getGameMode() const
Gets this player’s current GameMode .
Returns:
Current game mode
getGameVersion
std::string getGameVersion() const
Gets the player’s current game version.
Returns:
the player’s game version
getInventory
PlayerInventory &getInventory() const
Get the player’s inventory.
Returns:
The inventory of the player, this also contains the armor slots.
getLocale
std::string getLocale() const
Gets the player’s current locale.
Returns:
the player’s locale
getName
std::string getName() override const
Returns the name of this player.
Returns:
Player name or null if we have not seen a name for this player yet
getPing
std::chrono::milliseconds getPing() const
Gets the player’s average ping.
Returns:
player ping
getScoreboard
Scoreboard &getScoreboard() const
Gets the Scoreboard displayed to this player.
Returns:
The current scoreboard seen by this player
getSkin
Skin getSkin() const
Gets the player’s skin.
Returns:
the player’s skin
getTotalExp
int getTotalExp() const
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.
Returns:
Current total experience points
getWalkSpeed
float getWalkSpeed() const
Gets the current allowed speed that a client can walk.
Returns:
The current allowed speed, default is 0.10.
getXuid
std::string getXuid() const
Returns the Xbox User ID (XUID) of this player.
Returns:
Player XUID
giveExp
void giveExp(int amount)
Gives the player the amount of experience specified.
Parameters:
amount
Exp amount to give
giveExpLevels
void giveExpLevels(int amount)
Gives the player the amount of experience levels specified.
Parameters:
amount
amount of experience levels to give or take
isFlying
bool isFlying() const
Checks to see if this player is currently flying or not.
Returns:
True if the player is flying, else false.
isOp
bool isOp() const
Checks if this player is a server operator.
Returns:
true if this is an operator, otherwise false
isSneaking
bool isSneaking() const
Returns if the player is in sneak mode.
Returns:
true if player is in sneak mode
isSprinting
bool isSprinting() const
Gets whether the player is sprinting or not.
Returns:
true if player is sprinting.
kick
void kick(std::string message) const
Kicks player with custom kick message.
Parameters:
message
kick message
performCommand
bool performCommand(std::string command) const
Makes the player perform the given command.
Parameters:
command
Command to perform
Returns:
true if the command was successful, otherwise false
playSound
void playSound(Location location, std::string sound, float volume, float pitch)
Play a sound for a player at the location.
Parameters:
location
The location to play the soundsound
The internal sound name to playvolume
The volume of the soundpitch
The pitch of the sound
resetTitle
void resetTitle() const
Resets the title displayed to the player. This will clear the displayed title / subtitle and reset timings to their default values.
sendForm
void sendForm(FormVariant form)
Sends a form to the player.
Parameters:
form
The form to send
sendPacket
void sendPacket(int packet_id, std::string_view payload) const
Sends a packet to the player.
Parameters:
packet_id
The packet ID to be sent.payload
The payload of the packet to be transmitted.
sendPopup
void sendPopup(std::string message) const
Sends this player a popup message.
Parameters:
message
Message to be displayed
sendTip
void sendTip(std::string message) const
Sends this player a tip message.
Parameters:
message
Message to be displayed
sendTitle
void sendTitle(std::string title, std::string subtitle) const
Sends a title and a subtitle message to the player. If they are empty strings, the display will be updated as such. The titles will be displayed with the default timings.
Parameters:
title
Title textsubtitle
Subtitle text
void sendTitle(std::string title, std::string subtitle, int fade_in, int stay,
int fade_out) const
Sends a title and a subtitle message to the player. If they are empty strings, the display will be updated as such.
Parameters:
title
Title textsubtitle
Subtitle textfade_in
time in ticks for titles to fade in. Defaults to 10.stay
time in ticks for titles to stay. Defaults to 70.fade_out
time in ticks for titles to fade out. Defaults to 20.
sendToast
void sendToast(std::string title, std::string content) const
Sends this player a toast notification.
Parameters:
title
The title of the toast notification.content
The content of the toast notification.
setAllowFlight
void setAllowFlight(bool flight)
Sets if the Player is allowed to fly via jump key double-tap.
Parameters:
flight
If flight should be allowed.
setExpLevel
Result<void> setExpLevel(int level)
Sets the players current experience level.
Parameters:
level
New experience level
setExpProgress
Result<void> setExpProgress(float progress)
Sets the players current experience progress towards the next level.
This is a percentage value. 0.0 is “no progress” and 1.0 is “next level”.
Parameters:
progress
New experience progress
setFlySpeed
void setFlySpeed(float value) const
Sets the speed at which a client will fly.
Parameters:
value
The new speed.
setFlying
Result<void> setFlying(bool value)
Makes this player start or stop flying.
Parameters:
value
True to fly.
setGameMode
void setGameMode(GameMode mode)
Sets this player’s current GameMode .
Parameters:
mode
New game mode
setOp
void setOp(bool value)
Sets the operator status of this player.
Parameters:
value
New operator value
setScoreboard
void setScoreboard(Scoreboard &scoreboard)
@breif Sets the player’s visible Scoreboard.
Parameters:
scoreboard
New Scoreboard for the player
setSneaking
void setSneaking(bool sneak)
Sets the sneak mode of the player.
Parameters:
sneak
true if player should appear sneaking
setSprinting
void setSprinting(bool sprinting)
Sets whether the player is sprinting or not.
Parameters:
sprinting
true if the player should be sprinting
setWalkSpeed
void setWalkSpeed(float value) const
Sets the speed at which a client will walk.
Parameters:
value
The new speed.
spawnParticle
void spawnParticle(std::string name, Location location) const
Spawns the particle at the target location.
Parameters:
name
the name of the particle effect to spawnlocation
the location to spawn at
void spawnParticle(std::string name, float x, float y, float z) const
Spawns the particle at the target location.
Parameters:
name
the name of the particle effect 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 at
void spawnParticle(std::string name, Location location,
std::optional<std::string> molang_variables_json) const
Spawns the particle at the target location.
Parameters:
name
the name of the particle effect to spawnlocation
the location to spawn atmolang_variables_json
the customizable molang variables that can be adjusted for this particle, in json
void spawnParticle(std::string name, float x, float y, float z,
std::optional<std::string> molang_variables_json) const
Spawns the particle at the target location.
Parameters:
name
the name of the particle effect 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 atmolang_variables_json
the customizable molang variables that can be adjusted for this particle, in json
stopAllSounds
void stopAllSounds()
Stop all sounds from playing.
stopSound
void stopSound(std::string sound)
Stop the specified sound from playing.
Parameters:
sound
the sound to stop
transfer
void transfer(std::string host, int port) const
Transfers the player to another server.
Parameters:
updateCommands
void updateCommands() const
Send the list of commands to the client.
Generally useful to ensure the client has a complete list of commands after permission changes are done.