Manages all connected ServerPlayers on the server.
More...
#include <SDK.h>
|
| shared_ptr< ServerPlayer > | getPlayer (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< ServerPlayer > | getNearestPlayer (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< ServerPlayer > | respawn (shared_ptr< ServerPlayer > serverPlayer, int targetDimension, bool keepAllPlayerData) |
| | Respawn a server player (after death or dimension change).
|
|
|
vector< shared_ptr< ServerPlayer > > | players |
| | All currently connected players. Iterate this for all players.
|
Manages all connected ServerPlayers on the server.
Obtain via SDK::GetPlayerList() or MinecraftServer::getInstance()->getPlayers().
Definition at line 26 of file PlayerList.h.
◆ broadcastAll()
| void PlayerList::broadcastAll |
( |
shared_ptr< class Packet > | packet, |
|
|
int | dimension = 0 ) |
Broadcast a packet to all players in a dimension.
- Parameters
-
| packet | Packet to broadcast. |
| dimension | Target 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
-
| position | World position (Pos*). |
| range | Search 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
-
| name | Player's username (wide string). |
- Returns
- Shared pointer to ServerPlayer, or nullptr if not found.
- Example
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()
Check if a player is a server operator.
- Parameters
-
- Returns
- true if the player is op'd.
◆ kickPlayerByShortId()
| void PlayerList::kickPlayerByShortId |
( |
unsigned char | networkSmallId | ) |
|
Kick a player by their small network ID.
- Parameters
-
| networkSmallId | The 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
-
| serverPlayer | Player to respawn. |
| targetDimension | Target dimension. |
| keepAllPlayerData | True 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
-
| progressListener | Optional progress listener (can be nullptr). |
◆ sendMessage()
| void PlayerList::sendMessage |
( |
const wstring & | name, |
|
|
const wstring & | message ) |
Send a chat message to a specific player.
- Parameters
-
| name | Target player's username. |
| message | Message text. |
◆ setViewDistance()
| void PlayerList::setViewDistance |
( |
int | newViewDistance | ) |
|
Set the view distance for all players.
- Parameters
-
| newViewDistance | New view distance in chunks. |
The documentation for this class was generated from the following files: