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() constGets the socket address of this player.
Returns:
the player’s socket address
getAllowFlight
bool getAllowFlight() constDetermines 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() constGets the player’s current device id.
Returns:
the player’s device id
getDeviceOS
std::string getDeviceOS() constGets the player’s current device’s operation system (OS).
Returns:
the player’s device OS
getEnderChest
Inventory &getEnderChest() constGet the player’s EnderChest inventory.
Returns:
The EnderChest of the player
getExpLevel
int getExpLevel() constGets the players current experience level.
Returns:
Current experience level
getExpProgress
float getExpProgress() constGets 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() constGets the current allowed speed that a client can fly.
Returns:
The current allowed speed, default is 0.05.
getGameMode
GameMode getGameMode() constGets this player’s current GameMode .
Returns:
Current game mode
getGameVersion
std::string getGameVersion() constGets the player’s current game version.
Returns:
the player’s game version
getInventory
PlayerInventory &getInventory() constGet the player’s inventory.
Returns:
The inventory of the player, this also contains the armor slots.
getLocale
std::string getLocale() constGets the player’s current locale.
Returns:
the player’s locale
getName
std::string getName() override constReturns 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() constGets the player’s average ping.
Returns:
player ping
getScoreboard
Scoreboard &getScoreboard() constGets the Scoreboard displayed to this player.
Returns:
The current scoreboard seen by this player
getSkin
Skin getSkin() constGets the player’s skin.
Returns:
the player’s skin
getTotalExp
int getTotalExp() constGets 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() constGets the current allowed speed that a client can walk.
Returns:
The current allowed speed, default is 0.10.
getXuid
std::string getXuid() constReturns 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:
amountExp amount to give
giveExpLevels
void giveExpLevels(int amount)Gives the player the amount of experience levels specified.
Parameters:
amountamount of experience levels to give or take
isFlying
bool isFlying() constChecks to see if this player is currently flying or not.
Returns:
True if the player is flying, else false.
isOp
bool isOp() constChecks if this player is a server operator.
Returns:
true if this is an operator, otherwise false
isSneaking
bool isSneaking() constReturns if the player is in sneak mode.
Returns:
true if player is in sneak mode
isSprinting
bool isSprinting() constGets whether the player is sprinting or not.
Returns:
true if player is sprinting.
kick
void kick(std::string message) constKicks player with custom kick message.
Parameters:
messagekick message
performCommand
bool performCommand(std::string command) constMakes the player perform the given command.
Parameters:
commandCommand 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:
locationThe location to play the soundsoundThe internal sound name to playvolumeThe volume of the soundpitchThe pitch of the sound
resetTitle
void resetTitle() constResets 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:
formThe form to send
sendPacket
void sendPacket(int packet_id, std::string_view payload) constSends a packet to the player.
Parameters:
packet_idThe packet ID to be sent.payloadThe payload of the packet to be transmitted.
sendPopup
void sendPopup(std::string message) constSends this player a popup message.
Parameters:
messageMessage to be displayed
sendTip
void sendTip(std::string message) constSends this player a tip message.
Parameters:
messageMessage to be displayed
sendTitle
void sendTitle(std::string title, std::string subtitle) constSends 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:
titleTitle textsubtitleSubtitle text
void sendTitle(std::string title, std::string subtitle, int fade_in, int stay,
int fade_out) constSends a title and a subtitle message to the player. If they are empty strings, the display will be updated as such.
Parameters:
titleTitle textsubtitleSubtitle textfade_intime in ticks for titles to fade in. Defaults to 10.staytime in ticks for titles to stay. Defaults to 70.fade_outtime in ticks for titles to fade out. Defaults to 20.
sendToast
void sendToast(std::string title, std::string content) constSends this player a toast notification.
Parameters:
titleThe title of the toast notification.contentThe content of the toast notification.
setAllowFlight
void setAllowFlight(bool flight)Sets if the Player is allowed to fly via jump key double-tap.
Parameters:
flightIf flight should be allowed.
setExpLevel
Result<void> setExpLevel(int level)Sets the players current experience level.
Parameters:
levelNew 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:
progressNew experience progress
setFlySpeed
void setFlySpeed(float value) constSets the speed at which a client will fly.
Parameters:
valueThe new speed.
setFlying
Result<void> setFlying(bool value)Makes this player start or stop flying.
Parameters:
valueTrue to fly.
setGameMode
void setGameMode(GameMode mode)Sets this player’s current GameMode .
Parameters:
modeNew game mode
setOp
void setOp(bool value)Sets the operator status of this player.
Parameters:
valueNew operator value
setScoreboard
void setScoreboard(Scoreboard &scoreboard)@breif Sets the player’s visible Scoreboard.
Parameters:
scoreboardNew Scoreboard for the player
setSneaking
void setSneaking(bool sneak)Sets the sneak mode of the player.
Parameters:
sneaktrue if player should appear sneaking
setSprinting
void setSprinting(bool sprinting)Sets whether the player is sprinting or not.
Parameters:
sprintingtrue if the player should be sprinting
setWalkSpeed
void setWalkSpeed(float value) constSets the speed at which a client will walk.
Parameters:
valueThe new speed.
spawnParticle
void spawnParticle(std::string name, Location location) constSpawns the particle at the target location.
Parameters:
namethe name of the particle effect to spawnlocationthe location to spawn at
void spawnParticle(std::string name, float x, float y, float z) constSpawns the particle at the target location.
Parameters:
namethe name of the particle effect to spawnxthe position on the x axis to spawn atythe position on the y axis to spawn atzthe position on the z axis to spawn at
void spawnParticle(std::string name, Location location,
std::optional<std::string> molang_variables_json) constSpawns the particle at the target location.
Parameters:
namethe name of the particle effect to spawnlocationthe location to spawn atmolang_variables_jsonthe 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) constSpawns the particle at the target location.
Parameters:
namethe name of the particle effect to spawnxthe position on the x axis to spawn atythe position on the y axis to spawn atzthe position on the z axis to spawn atmolang_variables_jsonthe 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:
soundthe sound to stop
transfer
void transfer(std::string host, int port) constTransfers the player to another server.
Parameters:
updateCommands
void updateCommands() constSend the list of commands to the client.
Generally useful to ensure the client has a complete list of commands after permission changes are done.