Faucet Mod SDK 1.0.0
Modding API for Minecraft Legacy Console Edition
Loading...
Searching...
No Matches
ServerPlayer Class Reference

Server-side representation of a connected player. More...

#include <SDK.h>

Inheritance diagram for ServerPlayer:
Collaboration diagram for ServerPlayer:

Public Member Functions

void sendMessage (const wstring &message, int type=0, int customData=-1, const wstring &additionalMessage=L"")
 Send a chat message directly to this player's screen.
void disconnect ()
 Kick this player from the server. Calls disconnect() and closes the connection.
virtual void teleportTo (double x, double y, double z) override
 Teleport this player to a world position.
virtual bool hurt (DamageSource *source, float dmg) override
 Apply damage to this player from a damage source.
bool canHarmPlayer (shared_ptr< Player > target)
 Check if this player can harm another player (PvP check).
virtual void giveExperienceLevels (int amount) override
 Give XP levels to this player.
virtual void changeDimension (int i) override
 Change which dimension this player is in.
void setGameMode (GameType *mode)
 Set the game mode for this player.
ServerLevelgetLevel ()
 Get the ServerLevel this player is currently in.
bool hasPermission (class EGameCommand command)
 Check if this player has a server-side permission.
void resetLastActionTime ()
 Reset this player's last-action timer (anti-idle).
Public Member Functions inherited from Player
float getHealth () const
 Get the player's current health.
void setHealth (float health)
 Set the player's health directly.
float getMaxHealth () const
 Get the player's maximum health.
bool hurt (DamageSource *source, float amount)
 Apply damage from a damage source.
void heal (float amount)
 Heal the player by a given amount.
int getFoodLevel () const
 Get the player's current food level.
int getExperienceLevel () const
 Get the player's experience level.
void giveExperienceLevels (int amount)
 Give experience levels to the player.
wstring getName () const
 Get the player's username.
bool isSneaking () const
 Check if the player is currently sneaking.
bool isSprinting () const
 Check if the player is currently sprinting.
bool isFlying () const
 Check if the player is flying.
void setFlying (bool flying)
 Set the player's flying state.
double getX () const
 Get the player's current X position.
double getY () const
 Get the player's current Y position (feet level).
double getZ () const
 Get the player's current Z position.
void teleportTo (double x, double y, double z)
 Teleport the player to a world position.
virtual shared_ptr< ItemInstance > getCarriedItem ()
 Get the item currently held in the player's hand.
class Inventory * getInventory ()
 Add an item to the player's inventory.
virtual void respawn ()
 Trigger the player's respawn.
void kill ()
 Kill the player immediately. Triggers death screen.
virtual void playSound (int soundId, float volume, float pitch)
 Play a sound effect at the player's position.
bool hasPermission (class EGameCommand command)
 Check whether this player has a given game permission.

Public Attributes

int latency
 Network latency in milliseconds.
bool wonGame
 True if the player has won the game (defeated the Ender Dragon).
ServerPlayerGameModegameMode
 This player's server-side game mode instance.
Public Attributes inherited from Player
double x
 X coordinate (double precision).
double y
 Y coordinate (feet position).
double z
 Z coordinate.
float yRot
 Yaw rotation in degrees.
float xRot
 Pitch rotation in degrees.

Detailed Description

Server-side representation of a connected player.

Contains the player's server game mode, connection, and chunk state. Access via SDK::GetPlayerList()->players or PlayerList::getPlayer().

Definition at line 757 of file SDK.h.

Member Function Documentation

◆ canHarmPlayer()

bool ServerPlayer::canHarmPlayer ( shared_ptr< Player > target)

Check if this player can harm another player (PvP check).

Parameters
targetTarget player.
Returns
true if PvP is allowed and the player can attack.

◆ changeDimension()

virtual void ServerPlayer::changeDimension ( int i)
overridevirtual

Change which dimension this player is in.

Parameters
iTarget dimension.

◆ getLevel()

ServerLevel * ServerPlayer::getLevel ( )

Get the ServerLevel this player is currently in.

Returns
Pointer to the ServerLevel.

◆ giveExperienceLevels()

virtual void ServerPlayer::giveExperienceLevels ( int amount)
overridevirtual

Give XP levels to this player.

Parameters
amountLevels to add.

◆ hasPermission()

bool ServerPlayer::hasPermission ( class EGameCommand command)

Check if this player has a server-side permission.

Parameters
commandPermission to check.
Returns
true if allowed.

◆ hurt()

virtual bool ServerPlayer::hurt ( DamageSource * source,
float dmg )
overridevirtual

Apply damage to this player from a damage source.

Parameters
sourceDamage source.
dmgDamage in half-hearts.
Returns
true if damage was applied.

◆ sendMessage()

void ServerPlayer::sendMessage ( const wstring & message,
int type = 0,
int customData = -1,
const wstring & additionalMessage = L"" )

Send a chat message directly to this player's screen.

Parameters
messageMessage text.
typeMessage type (e_ChatCustom for mod messages).
customDataOptional custom data (use -1 for none).
additionalMsgOptional additional message text.
Example
serverPlayer->sendMessage(L"You have been warned!", ChatPacket::e_ChatCustom);

◆ setGameMode()

void ServerPlayer::setGameMode ( GameType * mode)

Set the game mode for this player.

Parameters
modeGameType to apply (Survival, Creative, Adventure, Spectator).

◆ teleportTo()

virtual void ServerPlayer::teleportTo ( double x,
double y,
double z )
overridevirtual

Teleport this player to a world position.

Parameters
x,y,zTarget coordinates.

The documentation for this class was generated from the following files: