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

Manages all connected ServerPlayers on the server. More...

#include <SDK.h>

Public Member Functions

shared_ptr< ServerPlayergetPlayer (const wstring &name)
 Find a player by username.
int getPlayerCount ()
 Get the number of currently connected players.
int getMaxPlayers ()
 Get the server's configured max players.
shared_ptr< ServerPlayergetNearestPlayer (class Pos *position, int range)
 Find the nearest player to a world position.
wstring getPlayerNames ()
 Get a comma-separated string of all online player names.
void sendMessage (const wstring &name, const wstring &message)
 Send a chat message to a specific player.
void broadcastAll (shared_ptr< class Packet > packet, int dimension=0)
 Broadcast a packet to all players in a dimension.
void saveAll (class ProgressListener *progressListener, bool bDeleteGuestMaps=false)
 Save all player data to disk.
bool isOp (shared_ptr< ServerPlayer > player)
 Check if a player is a server operator.
void kickPlayerByShortId (unsigned char networkSmallId)
 Kick a player by their small network ID.
void setViewDistance (int newViewDistance)
 Set the view distance for all players.
shared_ptr< ServerPlayerrespawn (shared_ptr< ServerPlayer > serverPlayer, int targetDimension, bool keepAllPlayerData)
 Respawn a server player (after death or dimension change).

Public Attributes

vector< shared_ptr< ServerPlayer > > players
 All currently connected players. Iterate this for all players.

Detailed Description

Manages all connected ServerPlayers on the server.

Obtain via SDK::GetPlayerList() or MinecraftServer::getInstance()->getPlayers().

Definition at line 26 of file PlayerList.h.

Member Function Documentation

◆ broadcastAll()

void PlayerList::broadcastAll ( shared_ptr< class Packet > packet,
int dimension = 0 )

Broadcast a packet to all players in a dimension.

Parameters
packetPacket to broadcast.
dimensionTarget dimension (0=Overworld, -1=Nether, 1=End).

◆ getMaxPlayers()

int PlayerList::getMaxPlayers ( )

Get the server's configured max players.

Returns
Max player count.

◆ getNearestPlayer()

shared_ptr< ServerPlayer > PlayerList::getNearestPlayer ( class Pos * position,
int range )

Find the nearest player to a world position.

Parameters
positionWorld position (Pos*).
rangeSearch radius in blocks.
Returns
Nearest ServerPlayer in range, or nullptr.

◆ getPlayer()

shared_ptr< ServerPlayer > PlayerList::getPlayer ( const wstring & name)

Find a player by username.

Parameters
namePlayer's username (wide string).
Returns
Shared pointer to ServerPlayer, or nullptr if not found.
Example
auto player = SDK::GetPlayerList()->getPlayer(L"Steve");
if (player) player->sendMessage(L"Hello Steve!");
PlayerList * GetPlayerList()
Get the PlayerList (all connected server players).

◆ getPlayerCount()

int PlayerList::getPlayerCount ( )

Get the number of currently connected players.

Returns
Connected player count.

◆ getPlayerNames()

wstring PlayerList::getPlayerNames ( )

Get a comma-separated string of all online player names.

Returns
Wide string of player names.

◆ isOp()

bool PlayerList::isOp ( shared_ptr< ServerPlayer > player)

Check if a player is a server operator.

Parameters
playerTarget player.
Returns
true if the player is op'd.

◆ kickPlayerByShortId()

void PlayerList::kickPlayerByShortId ( unsigned char networkSmallId)

Kick a player by their small network ID.

Parameters
networkSmallIdThe player's small network ID byte.

◆ respawn()

shared_ptr< ServerPlayer > PlayerList::respawn ( shared_ptr< ServerPlayer > serverPlayer,
int targetDimension,
bool keepAllPlayerData )

Respawn a server player (after death or dimension change).

Parameters
serverPlayerPlayer to respawn.
targetDimensionTarget dimension.
keepAllPlayerDataTrue to keep inventory/XP.
Returns
New ServerPlayer instance.

◆ saveAll()

void PlayerList::saveAll ( class ProgressListener * progressListener,
bool bDeleteGuestMaps = false )

Save all player data to disk.

Parameters
progressListenerOptional progress listener (can be nullptr).

◆ sendMessage()

void PlayerList::sendMessage ( const wstring & name,
const wstring & message )

Send a chat message to a specific player.

Parameters
nameTarget player's username.
messageMessage text.

◆ setViewDistance()

void PlayerList::setViewDistance ( int newViewDistance)

Set the view distance for all players.

Parameters
newViewDistanceNew view distance in chunks.

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