Cuberite
A lightweight, fast and extensible game server for Minecraft
|
#include <Server.h>
Classes | |
class | cTickThread |
The server tick thread takes care of the players who aren't yet spawned in a world. More... | |
Public Member Functions | |
void | AuthenticateUser (int a_ClientID, AString &&a_Username, const cUUID &a_UUID, Json::Value &&a_Properties) |
Authenticates the specified user, called by cAuthenticator supplying player details from Mojang. More... | |
void | ClientMovedToWorld (const cClientHandle *a_Client) |
Don't tick a_Client anymore, it will be ticked from its cPlayer instead. More... | |
bool | Command (cClientHandle &a_Client, AString &a_Cmd) |
bool | DoesAllowMultiLogin (void) |
Can login more than once with same username. More... | |
std::string_view | GetCustomRedirectUrl (void) |
const AString & | GetDescription (void) const |
const AString & | GetFaviconData (void) const |
Returns base64 encoded favicon data (obtained from favicon.png) More... | |
size_t | GetMaxPlayers (void) const |
size_t | GetNumPlayers (void) const |
cRsaPrivateKey & | GetPrivateKey (void) |
const AString & | GetProxySharedSecret (void) const |
ContiguousByteBufferView | GetPublicKeyDER (void) const |
const AStringMap & | GetRegisteredForgeMods (const UInt32 a_Protocol) |
Get the Forge mods (map of ModName -> ModVersionString) registered for a given protocol. More... | |
const AString & | GetResourcePackUrl (void) |
const AString & | GetServerID (void) const |
const AString & | GetShutdownMessage (void) const |
bool | InitServer (cSettingsRepositoryInterface &a_Settings, bool a_ShouldAuth) |
bool | IsHardcore (void) const |
bool | IsPlayerInQueue (const AString &a_Username) |
Check if the player is queued to be transferred to a World. More... | |
void | KickUser (int a_ClientID, const AString &a_Reason) |
bool | OnlyAllowBungeeCord (void) const |
void | PlayerCreated () |
Notifies the server that a player was created; the server uses this to adjust the number of players. More... | |
void | PlayerDestroyed () |
Notifies the server that a player is being destroyed; the server uses this to adjust the number of players. More... | |
void | PrintHelp (const AStringVector &a_Split, cCommandOutputCallback &a_Output) |
Lists all available console commands and their helpstrings. More... | |
void | QueueExecuteConsoleCommand (const AString &a_Cmd, cCommandOutputCallback &a_Output) |
Queues a console command for execution through the cServer class. More... | |
bool | RegisterForgeMod (const AString &a_ModName, const AString &a_ModVersion, UInt32 a_ProtocolVersionNumber) |
Add a Forge mod to the server ping list. More... | |
void | ScheduleTask (cTickTime a_DelayTicks, std::function< void(class cServer &)> a_Task) |
Queues a lambda task onto the server tick thread, with the specified delay in ticks. More... | |
void | SetMaxPlayers (size_t a_MaxPlayers) |
bool | ShouldAllowBungeeCord (void) const |
Returns true if BungeeCord logins (that specify the player's UUID) are allowed. More... | |
bool | ShouldAllowMultiWorldTabCompletion (void) const |
Returns true if usernames should be completed across worlds. More... | |
bool | ShouldAuthenticate (void) const |
Returns true if authentication has been turned on in server settings. More... | |
bool | ShouldLimitPlayerBlockChanges (void) const |
Returns true if limit for number of block changes per tick by a player has been turned on in server settings. More... | |
bool | ShouldRequireResourcePack (void) |
Returns true if clients must accept resource pack. More... | |
void | Shutdown (void) |
bool | Start (void) |
void | UnregisterForgeMod (const AString &a_ModName, UInt32 a_ProtocolVersionNumber) |
Remove a Forge mod to the server ping list. More... | |
virtual | ~cServer () |
Static Public Member Functions | |
static void | BindBuiltInConsoleCommands (void) |
Binds the built-in console commands with the plugin manager. More... | |
Private Member Functions | |
cServer (void) | |
void | ExecuteConsoleCommand (const AString &a_Cmd, cCommandOutputCallback &a_Output) |
Executes the console command, sends output through the specified callback. More... | |
cTCPLink::cCallbacksPtr | OnConnectionAccepted (const AString &a_RemoteIPAddress) |
Creates a new cClientHandle instance and adds it to the list of clients. More... | |
void | PrepareKeys (void) |
Loads, or generates, if missing, RSA keys for protocol encryption. More... | |
AStringMap & | RegisteredForgeMods (const UInt32 a_Protocol) |
Get the Forge mods registered for a given protocol, for modification. More... | |
void | Tick (float a_Dt) |
void | TickClients (float a_Dt) |
Ticks the clients in m_Clients, manages the list in respect to removing clients. More... | |
void | TickCommands (void) |
Executes commands queued in the command queue. More... | |
void | TickQueuedTasks (void) |
Executes all tasks queued onto the tick thread. More... | |
Private Attributes | |
bool | m_bAllowMultiLogin |
True - allow same username to login more than once False - only once. More... | |
bool | m_bIsConnected |
bool | m_bIsHardcore |
cClientHandlePtrs | m_Clients |
Clients that are connected to the server and not yet assigned to a cWorld. More... | |
cClientHandles | m_ClientsToRemove |
Clients that have just been moved into a world and are to be removed from m_Clients in the next Tick(). More... | |
int | m_ClientViewDistance |
cCriticalSection | m_CSClients |
Protects m_Clients and m_ClientsToRemove against multithreaded access. More... | |
cCriticalSection | m_CSPendingCommands |
cCriticalSection | m_CSTasks |
Guards the m_Tasks. More... | |
AString | m_CustomRedirectUrl |
AString | m_Description |
AString | m_FaviconData |
std::map< UInt32, AStringMap > | m_ForgeModsByVersion |
Map of protocol version to Forge mods (map of ModName -> ModVersionString) More... | |
size_t | m_MaxPlayers |
bool | m_OnlyAllowBungeeCord |
True if BungeeCord handshake packets should be the only ones accepted. More... | |
std::vector< std::pair< AString, cCommandOutputCallback * > > | m_PendingCommands |
std::atomic_size_t | m_PlayerCount |
Number of players currently playing in the server. More... | |
AStringVector | m_Ports |
The list of ports on which the server should listen for connections. More... | |
cRsaPrivateKey | m_PrivateKey |
The private key used for the assymetric encryption start in the protocols. More... | |
AString | m_ProxySharedSecret |
Security string that the proxy server should send, compatible with BungeeGuard. More... | |
ContiguousByteBuffer | m_PublicKeyDER |
Public key for m_PrivateKey, ASN1-DER-encoded. More... | |
cRCONServer | m_RCONServer |
bool | m_RequireResourcePack |
AString | m_ResourcePackUrl |
cServerHandlePtrs | m_ServerHandles |
The network sockets listening for client connections. More... | |
AString | m_ServerID |
The server ID used for client authentication. More... | |
bool | m_ShouldAllowBungeeCord |
True if BungeeCord handshake packets (with player UUID) should be accepted. More... | |
bool | m_ShouldAllowMultiWorldTabCompletion |
True if usernames should be completed across worlds. More... | |
bool | m_ShouldAuthenticate |
If true, players will be online-authenticated agains Mojang servers. More... | |
bool | m_ShouldLimitPlayerBlockChanges |
True if limit for number of block changes per tick by a player should be enabled. More... | |
AString | m_ShutdownMessage |
std::vector< std::pair< std::chrono::milliseconds, std::function< void(class cServer &)> > > | m_Tasks |
Tasks that have been queued onto the tick thread, possibly to be executed at target tick in the future; guarded by m_CSTasks. More... | |
cTickThread | m_TickThread |
cTickTimeLong | m_UpTime |
Time, in ticks, since the server started Not persistent across server restarts. More... | |
Friends | |
class | cRoot |
class | cServerListenCallbacks |
|
private |
Definition at line 106 of file Server.cpp.
void cServer::AuthenticateUser | ( | int | a_ClientID, |
AString && | a_Username, | ||
const cUUID & | a_UUID, | ||
Json::Value && | a_Properties | ||
) |
Authenticates the specified user, called by cAuthenticator supplying player details from Mojang.
Definition at line 715 of file Server.cpp.
|
static |
Binds the built-in console commands with the plugin manager.
Definition at line 636 of file Server.cpp.
void cServer::ClientMovedToWorld | ( | const cClientHandle * | a_Client | ) |
Don't tick a_Client anymore, it will be ticked from its cPlayer instead.
Definition at line 125 of file Server.cpp.
bool cServer::Command | ( | cClientHandle & | a_Client, |
AString & | a_Cmd | ||
) |
Definition at line 429 of file Server.cpp.
|
inline |
|
private |
Executes the console command, sends output through the specified callback.
Definition at line 470 of file Server.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
const AStringMap & cServer::GetRegisteredForgeMods | ( | const UInt32 | a_Protocol | ) |
Get the Forge mods (map of ModName -> ModVersionString) registered for a given protocol.
Definition at line 282 of file Server.cpp.
|
inline |
bool cServer::InitServer | ( | cSettingsRepositoryInterface & | a_Settings, |
bool | a_ShouldAuth | ||
) |
Definition at line 153 of file Server.cpp.
bool cServer::IsPlayerInQueue | ( | const AString & | a_Username | ) |
Check if the player is queued to be transferred to a World.
Returns true is Player is found in queue.
Definition at line 291 of file Server.cpp.
void cServer::KickUser | ( | int | a_ClientID, |
const AString & | a_Reason | ||
) |
Definition at line 699 of file Server.cpp.
|
private |
Creates a new cClientHandle instance and adds it to the list of clients.
Returns the cClientHandle reinterpreted as cTCPLink callbacks.
Definition at line 319 of file Server.cpp.
void cServer::PlayerCreated | ( | ) |
Notifies the server that a player was created; the server uses this to adjust the number of players.
Definition at line 135 of file Server.cpp.
void cServer::PlayerDestroyed | ( | ) |
Notifies the server that a player is being destroyed; the server uses this to adjust the number of players.
Definition at line 144 of file Server.cpp.
|
private |
Loads, or generates, if missing, RSA keys for protocol encryption.
Definition at line 308 of file Server.cpp.
void cServer::PrintHelp | ( | const AStringVector & | a_Split, |
cCommandOutputCallback & | a_Output | ||
) |
Lists all available console commands and their helpstrings.
Definition at line 592 of file Server.cpp.
void cServer::QueueExecuteConsoleCommand | ( | const AString & | a_Cmd, |
cCommandOutputCallback & | a_Output | ||
) |
Queues a console command for execution through the cServer class.
The command will be executed in the server tick thread. The command's output will be written to the a_Output callback.
Definition at line 445 of file Server.cpp.
|
private |
Get the Forge mods registered for a given protocol, for modification.
Definition at line 264 of file Server.cpp.
bool cServer::RegisterForgeMod | ( | const AString & | a_ModName, |
const AString & | a_ModVersion, | ||
UInt32 | a_ProtocolVersionNumber | ||
) |
Add a Forge mod to the server ping list.
Definition at line 238 of file Server.cpp.
Queues a lambda task onto the server tick thread, with the specified delay in ticks.
Definition at line 456 of file Server.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void cServer::Shutdown | ( | void | ) |
Definition at line 671 of file Server.cpp.
bool cServer::Start | ( | void | ) |
Definition at line 400 of file Server.cpp.
|
private |
Definition at line 332 of file Server.cpp.
|
private |
Ticks the clients in m_Clients, manages the list in respect to removing clients.
Definition at line 354 of file Server.cpp.
|
private |
Executes commands queued in the command queue.
Definition at line 740 of file Server.cpp.
|
private |
Executes all tasks queued onto the tick thread.
Definition at line 759 of file Server.cpp.
Remove a Forge mod to the server ping list.
Definition at line 249 of file Server.cpp.
|
friend |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
The list of ports on which the server should listen for connections.
Initialized in InitServer(), used in Start().
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |