Skip to content

Class endstone::Player

ClassList > endstone > Player

Represents a player.

  • #include <endstone/player.h>

Inherits the following classes: endstone::Mob

Public Functions

Type Name
virtual Player * asPlayer () override const
Gets a CommandSender asPlayer .
virtual void closeForm () = 0
Closes the forms that are currently open for the player.
virtual const SocketAddress & getAddress () const = 0
Gets the socket address of this player.
virtual bool getAllowFlight () const = 0
Determines if the Player is allowed to fly via jump key double-tap.
virtual std::string getDeviceId () const = 0
Gets the player's current device id.
virtual std::string getDeviceOS () const = 0
Gets the player's current device's operation system (OS).
virtual int getExpLevel () const = 0
Gets the players current experience level.
virtual float getExpProgress () const = 0
Gets the players current experience progress towards the next level.
virtual float getFlySpeed () const = 0
Gets the current allowed speed that a client can fly.
virtual GameMode getGameMode () const = 0
Gets this player's current GameMode.
virtual std::string getGameVersion () const = 0
Gets the player's current game version.
virtual PlayerInventory & getInventory () const = 0
Get the player's inventory.
virtual std::string getLocale () const = 0
Gets the player's current locale.
virtual std::chrono::milliseconds getPing () const = 0
Gets the player's average ping.
virtual Scoreboard & getScoreboard () const = 0
Gets the Scoreboard displayed to this player.
virtual const Skin & getSkin () const = 0
Gets the player's skin.
virtual int getTotalExp () const = 0
Gets the players total experience points.
virtual UUID getUniqueId () const = 0
Returns the UUID of this player.
virtual float getWalkSpeed () const = 0
Gets the current allowed speed that a client can walk.
virtual std::string getXuid () const = 0
Returns the Xbox User ID (XUID) of this player.
virtual void giveExp (int amount) = 0
Gives the player the amount of experience specified.
virtual void giveExpLevels (int amount) = 0
Gives the player the amount of experience levels specified.
virtual bool isFlying () const = 0
Checks to see if this player is currently flying or not.
virtual void kick (std::string message) const = 0
Kicks player with custom kick message.
virtual bool performCommand (std::string command) const = 0
Makes the player perform the given command.
virtual void resetTitle () const = 0
Resets the title displayed to the player. This will clear the displayed title / subtitle and reset timings to their default values.
virtual void sendForm (FormVariant form) = 0
Sends a form to the player.
virtual void sendPacket (Packet & packet) = 0
Sends a packet to the player.
virtual void sendPopup (std::string message) const = 0
Sends this player a popup message.
virtual void sendTip (std::string message) const = 0
Sends this player a tip message.
virtual void sendTitle (std::string title, std::string subtitle) const = 0
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.
virtual void sendTitle (std::string title, std::string subtitle, int fade_in, int stay, int fade_out) const = 0
Sends a title and a subtitle message to the player. If they are empty strings, the display will be updated as such.
virtual void sendToast (std::string title, std::string content) const = 0
Sends this player a toast notification.
virtual void setAllowFlight (bool flight) = 0
Sets if the Player is allowed to fly via jump key double-tap.
virtual Result< void > setExpLevel (int level) = 0
Sets the players current experience level.
virtual Result< void > setExpProgress (float progress) = 0
Sets the players current experience progress towards the next level.
virtual void setFlySpeed (float value) const = 0
virtual Result< void > setFlying (bool value) = 0
Makes this player start or stop flying.
virtual void setGameMode (GameMode mode) = 0
Sets this player's current GameMode.
virtual void setScoreboard (Scoreboard & scoreboard) = 0
virtual void setWalkSpeed (float value) const = 0
virtual void transfer (std::string host, int port) const = 0
Transfers the player to another server.
virtual void updateCommands () const = 0
Send the list of commands to the client.

Public Functions inherited from endstone::Mob

See endstone::Mob

Type Name
virtual bool isGliding () const = 0
Checks to see if an actor is gliding, such as using an Elytra.

Public Functions inherited from endstone::Actor

See endstone::Actor

Type Name
virtual Actor * asActor () override const
Gets a CommandSender asActor .
virtual Dimension & getDimension () const = 0
virtual std::int64_t getId () const = 0
Returns a unique id for this actor.
virtual Level & getLevel () const = 0
virtual Location getLocation () const = 0
virtual std::uint64_t getRuntimeId () const = 0
virtual std::vector< std::string > getScoreboardTags () const = 0
Returns a list of scoreboard tags for this actor.
virtual Vector< float > getVelocity () const = 0
virtual bool isDead () const = 0
Returns true if this actor has been marked for removal.
virtual bool isInLava () const = 0
virtual bool isInWater () const = 0
virtual bool isOnGround () const = 0
virtual void setRotation (float yaw, float pitch) = 0
virtual void teleport (Location location) = 0
virtual void teleport (Actor & target) = 0

Public Functions inherited from endstone::CommandSender

See endstone::CommandSender

Type Name
virtual Actor * asActor () const
Gets a CommandSender asActor .
virtual CommandSender * asCommandSender () override const
Casts a Permissible asCommandSender .
virtual ConsoleCommandSender * asConsole () const
Gets a CommandSender as Console.
virtual Player * asPlayer () const
Gets a CommandSender asPlayer .
virtual std::string getName () const = 0
Gets the name of this command sender.
virtual Server & getServer () const = 0
Returns the server instance that this command is running on.
virtual void sendErrorMessage (const Message & message) const = 0
Sends this sender a error message.
void sendErrorMessage (const fmt::format_string< Args... > format, Args &&... args) const
virtual void sendMessage (const Message & message) const = 0
Sends this sender a message.
void sendMessage (const fmt::format_string< Args... > format, Args &&... args) const

Public Functions inherited from endstone::Permissible

See endstone::Permissible

Type Name
virtual Result< PermissionAttachment * > addAttachment (Plugin & plugin, const std::string & name, bool value) = 0
virtual Result< PermissionAttachment * > addAttachment (Plugin & plugin) = 0
virtual CommandSender * asCommandSender () const = 0
Casts a Permissible asCommandSender .
virtual std::unordered_set< PermissionAttachmentInfo * > getEffectivePermissions () const = 0
virtual bool hasPermission (std::string name) const = 0
virtual bool hasPermission (const Permission & perm) const = 0
virtual bool isOp () const = 0
Checks if this object is a server operator.
virtual bool isPermissionSet (std::string name) const = 0
virtual bool isPermissionSet (const Permission & perm) const = 0
virtual void recalculatePermissions () = 0
virtual Result< void > removeAttachment (PermissionAttachment & attachment) = 0
virtual void setOp (bool value) = 0
Sets the operator status of this object.
virtual ~Permissible () = default

Protected Types

Type Name
typedef std::variant< MessageForm, ActionForm, ModalForm > FormVariant

Public Functions Documentation

function asPlayer

Gets a CommandSender asPlayer .

inline virtual Player * endstone::Player::asPlayer () override const

Returns:

Player, nullptr if not a Player

Implements endstone::CommandSender::asPlayer


function closeForm

virtual void endstone::Player::closeForm () = 0

function getAddress

Gets the socket address of this player.

virtual const SocketAddress & endstone::Player::getAddress () const = 0

Returns:

the player's socket address


function getAllowFlight

Determines if the Player is allowed to fly via jump key double-tap.

virtual bool endstone::Player::getAllowFlight () const = 0

Returns:

True if the player is allowed to fly.


function getDeviceId

Gets the player's current device id.

virtual std::string endstone::Player::getDeviceId () const = 0

Returns:

the player's device id


function getDeviceOS

Gets the player's current device's operation system (OS).

virtual std::string endstone::Player::getDeviceOS () const = 0

Returns:

the player's device OS


function getExpLevel

Gets the players current experience level.

virtual int endstone::Player::getExpLevel () const = 0

Returns:

Current experience level


function getExpProgress

Gets the players current experience progress towards the next level.

virtual float endstone::Player::getExpProgress () const = 0

This is a percentage value. 0.0 is "no progress" and 1.0 is "next level".

Returns:

Current experience points


function getFlySpeed

Gets the current allowed speed that a client can fly.

virtual float endstone::Player::getFlySpeed () const = 0

Returns:

The current allowed speed, default is 0.05.


function getGameMode

Gets this player's current GameMode.

virtual GameMode endstone::Player::getGameMode () const = 0

Returns:

Current game mode


function getGameVersion

Gets the player's current game version.

virtual std::string endstone::Player::getGameVersion () const = 0

Returns:

the player's game version


function getInventory

Get the player's inventory.

virtual PlayerInventory & endstone::Player::getInventory () const = 0

Returns:

The inventory of the player, this also contains the armor slots.


function getLocale

Gets the player's current locale.

virtual std::string endstone::Player::getLocale () const = 0

Returns:

the player's locale


function getPing

Gets the player's average ping.

virtual std::chrono::milliseconds endstone::Player::getPing () const = 0

Returns:

player ping


function getScoreboard

Gets the Scoreboard displayed to this player.

virtual Scoreboard & endstone::Player::getScoreboard () const = 0

Returns:

The current scoreboard seen by this player


function getSkin

Gets the player's skin.

virtual const Skin & endstone::Player::getSkin () const = 0

Returns:

the player's skin


function getTotalExp

Gets the players total experience points.

virtual int endstone::Player::getTotalExp () const = 0

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


function getUniqueId

Returns the UUID of this player.

virtual UUID endstone::Player::getUniqueId () const = 0

Returns:

Player UUID


function getWalkSpeed

Gets the current allowed speed that a client can walk.

virtual float endstone::Player::getWalkSpeed () const = 0

Returns:

The current allowed speed, default is 0.10.


function getXuid

Returns the Xbox User ID (XUID) of this player.

virtual std::string endstone::Player::getXuid () const = 0

Returns:

Player XUID


function giveExp

Gives the player the amount of experience specified.

virtual void endstone::Player::giveExp (
    int amount
) = 0

Parameters:

  • amount Exp amount to give

function giveExpLevels

Gives the player the amount of experience levels specified.

virtual void endstone::Player::giveExpLevels (
    int amount
) = 0

Parameters:

  • amount amount of experience levels to give or take

function isFlying

Checks to see if this player is currently flying or not.

virtual bool endstone::Player::isFlying () const = 0

Returns:

True if the player is flying, else false.


function kick

Kicks player with custom kick message.

virtual void endstone::Player::kick (
    std::string message
) const = 0

Parameters:

  • message kick message

function performCommand

Makes the player perform the given command.

virtual bool endstone::Player::performCommand (
    std::string command
) const = 0

Parameters:

Returns:

true if the command was successful, otherwise false


function resetTitle

virtual void endstone::Player::resetTitle () const = 0

function sendForm

Sends a form to the player.

virtual void endstone::Player::sendForm (
    FormVariant form
) = 0

Parameters:

  • form The form to send

function sendPacket

Sends a packet to the player.

virtual void endstone::Player::sendPacket (
    Packet & packet
) = 0

Parameters:

  • packet The packet to be sent.

function sendPopup

Sends this player a popup message.

virtual void endstone::Player::sendPopup (
    std::string message
) const = 0

Parameters:

  • message Message to be displayed

function sendTip

Sends this player a tip message.

virtual void endstone::Player::sendTip (
    std::string message
) const = 0

Parameters:

  • message Message to be displayed

function 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.

virtual void endstone::Player::sendTitle (
    std::string title,
    std::string subtitle
) const = 0

Parameters:

  • title Title text
  • subtitle Subtitle text

function sendTitle [2/2]

Sends a title and a subtitle message to the player. If they are empty strings, the display will be updated as such.

virtual void endstone::Player::sendTitle (
    std::string title,
    std::string subtitle,
    int fade_in,
    int stay,
    int fade_out
) const = 0

Parameters:

  • title Title text
  • subtitle Subtitle text
  • fade_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.

function sendToast

Sends this player a toast notification.

virtual void endstone::Player::sendToast (
    std::string title,
    std::string content
) const = 0

Parameters:

  • title The title of the toast notification.
  • content The content of the toast notification.

function setAllowFlight

Sets if the Player is allowed to fly via jump key double-tap.

virtual void endstone::Player::setAllowFlight (
    bool flight
) = 0

Parameters:

  • flight If flight should be allowed.

function setExpLevel

Sets the players current experience level.

virtual Result< void > endstone::Player::setExpLevel (
    int level
) = 0

Parameters:

  • level New experience level

function setExpProgress

Sets the players current experience progress towards the next level.

virtual Result< void > endstone::Player::setExpProgress (
    float progress
) = 0

This is a percentage value. 0.0 is "no progress" and 1.0 is "next level".

Parameters:

  • progress New experience progress

function setFlySpeed

virtual void endstone::Player::setFlySpeed (
    float value
) const = 0

Sets the speed at which a client will fly.

Parameters:

  • value The new speed.

function setFlying

Makes this player start or stop flying.

virtual Result< void > endstone::Player::setFlying (
    bool value
) = 0

Parameters:

  • value True to fly.

function setGameMode

Sets this player's current GameMode.

virtual void endstone::Player::setGameMode (
    GameMode mode
) = 0

Parameters:

  • mode New game mode

function setScoreboard

virtual void endstone::Player::setScoreboard (
    Scoreboard & scoreboard
) = 0

@breif Sets the player's visible Scoreboard.

Parameters:


function setWalkSpeed

virtual void endstone::Player::setWalkSpeed (
    float value
) const = 0

Sets the speed at which a client will walk.

Parameters:

  • value The new speed.

function transfer

Transfers the player to another server.

virtual void endstone::Player::transfer (
    std::string host,
    int port
) const = 0

Parameters:

  • host Server address to transfer the player to.
  • port Server port to transfer the player to

function updateCommands

Send the list of commands to the client.

virtual void endstone::Player::updateCommands () const = 0

Generally useful to ensure the client has a complete list of commands after permission changes are done.


Protected Types Documentation

typedef FormVariant

using endstone::Player::FormVariant =  std::variant<MessageForm, ActionForm, ModalForm>;


The documentation for this class was generated from the following file include/endstone/player.h