18 #pragma warning(disable:4127)
19 #pragma warning(disable:4244)
20 #pragma warning(disable:4231)
21 #pragma warning(disable:4189)
22 #pragma warning(disable:4702)
189 virtual void Execute(
void)
override;
277 std::vector<std::pair<std::chrono::milliseconds, std::function<void(
class cServer &)>>>
m_Tasks;
295 void Tick(
float a_Dt);
std::chrono::duration< signed long long int, cTickTime::period > cTickTimeLong
std::basic_string_view< std::byte > ContiguousByteBufferView
std::chrono::duration< signed int, std::ratio_multiply< std::chrono::milliseconds::period, std::ratio< 50 > >> cTickTime
std::basic_string< std::byte > ContiguousByteBuffer
std::vector< cServerHandlePtr > cServerHandlePtrs
std::list< cClientHandle * > cClientHandles
std::shared_ptr< cClientHandle > cClientHandlePtr
std::list< cClientHandlePtr > cClientHandlePtrs
std::vector< AString > AStringVector
std::map< AString, AString > AStringMap
A string dictionary, used for key-value pairs.
Interface for a callback that receives command output The Out() function is called for any output the...
Encapsulates an RSA private key used in PKI cryptography.
cIsThread(AString &&a_ThreadName)
std::shared_ptr< cCallbacks > cCallbacksPtr
The root of the object hierarchy.
const AString & GetShutdownMessage(void) const
AString m_CustomRedirectUrl
void SetMaxPlayers(size_t a_MaxPlayers)
void TickClients(float a_Dt)
Ticks the clients in m_Clients, manages the list in respect to removing clients.
void PlayerCreated()
Notifies the server that a player was created; the server uses this to adjust the number of players.
ContiguousByteBufferView GetPublicKeyDER(void) const
void ExecuteConsoleCommand(const AString &a_Cmd, cCommandOutputCallback &a_Output)
Executes the console command, sends output through the specified callback.
bool m_ShouldLimitPlayerBlockChanges
True if limit for number of block changes per tick by a player should be enabled.
size_t GetMaxPlayers(void) const
void PrepareKeys(void)
Loads, or generates, if missing, RSA keys for protocol encryption.
const AString & GetProxySharedSecret(void) const
cTCPLink::cCallbacksPtr OnConnectionAccepted(const AString &a_RemoteIPAddress)
Creates a new cClientHandle instance and adds it to the list of clients.
void PrintHelp(const AStringVector &a_Split, cCommandOutputCallback &a_Output)
Lists all available console commands and their helpstrings.
bool m_bAllowMultiLogin
True - allow same username to login more than once False - only once.
const AString & GetDescription(void) const
void TickCommands(void)
Executes commands queued in the command queue.
void UnregisterForgeMod(const AString &a_ModName, UInt32 a_ProtocolVersionNumber)
Remove a Forge mod to the server ping list.
ContiguousByteBuffer m_PublicKeyDER
Public key for m_PrivateKey, ASN1-DER-encoded.
bool IsPlayerInQueue(const AString &a_Username)
Check if the player is queued to be transferred to a World.
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 futur...
bool m_ShouldAllowBungeeCord
True if BungeeCord handshake packets (with player UUID) should be accepted.
cServerHandlePtrs m_ServerHandles
The network sockets listening for client connections.
bool RegisterForgeMod(const AString &a_ModName, const AString &a_ModVersion, UInt32 a_ProtocolVersionNumber)
Add a Forge mod to the server ping list.
std::string_view GetCustomRedirectUrl(void)
const AStringMap & GetRegisteredForgeMods(const UInt32 a_Protocol)
Get the Forge mods (map of ModName -> ModVersionString) registered for a given protocol.
bool Command(cClientHandle &a_Client, AString &a_Cmd)
const AString & GetServerID(void) const
AString m_ServerID
The server ID used for client authentication.
std::atomic_size_t m_PlayerCount
Number of players currently playing in the server.
bool m_ShouldAuthenticate
If true, players will be online-authenticated agains Mojang servers.
cClientHandles m_ClientsToRemove
Clients that have just been moved into a world and are to be removed from m_Clients in the next Tick(...
bool ShouldAllowBungeeCord(void) const
Returns true if BungeeCord logins (that specify the player's UUID) are allowed.
void TickQueuedTasks(void)
Executes all tasks queued onto the tick thread.
AString m_ResourcePackUrl
cCriticalSection m_CSTasks
Guards the m_Tasks.
std::vector< std::pair< AString, cCommandOutputCallback * > > m_PendingCommands
void ClientMovedToWorld(const cClientHandle *a_Client)
Don't tick a_Client anymore, it will be ticked from its cPlayer instead.
cCriticalSection m_CSClients
Protects m_Clients and m_ClientsToRemove against multithreaded access.
bool InitServer(cSettingsRepositoryInterface &a_Settings, bool a_ShouldAuth)
const AString & GetResourcePackUrl(void)
static void BindBuiltInConsoleCommands(void)
Binds the built-in console commands with the plugin manager.
bool OnlyAllowBungeeCord(void) const
bool m_RequireResourcePack
void QueueExecuteConsoleCommand(const AString &a_Cmd, cCommandOutputCallback &a_Output)
Queues a console command for execution through the cServer class.
size_t GetNumPlayers(void) const
std::map< UInt32, AStringMap > m_ForgeModsByVersion
Map of protocol version to Forge mods (map of ModName -> ModVersionString)
bool m_ShouldAllowMultiWorldTabCompletion
True if usernames should be completed across worlds.
cRsaPrivateKey m_PrivateKey
The private key used for the assymetric encryption start in the protocols.
AStringVector m_Ports
The list of ports on which the server should listen for connections.
cRsaPrivateKey & GetPrivateKey(void)
bool IsHardcore(void) const
AString m_ProxySharedSecret
Security string that the proxy server should send, compatible with BungeeGuard.
void KickUser(int a_ClientID, const AString &a_Reason)
bool ShouldAllowMultiWorldTabCompletion(void) const
Returns true if usernames should be completed across worlds.
void PlayerDestroyed()
Notifies the server that a player is being destroyed; the server uses this to adjust the number of pl...
cClientHandlePtrs m_Clients
Clients that are connected to the server and not yet assigned to a cWorld.
AStringMap & RegisteredForgeMods(const UInt32 a_Protocol)
Get the Forge mods registered for a given protocol, for modification.
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.
cCriticalSection m_CSPendingCommands
bool ShouldRequireResourcePack(void)
Returns true if clients must accept resource pack.
bool ShouldAuthenticate(void) const
Returns true if authentication has been turned on in server settings.
AString m_ShutdownMessage
const AString & GetFaviconData(void) const
Returns base64 encoded favicon data (obtained from favicon.png)
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.
bool m_OnlyAllowBungeeCord
True if BungeeCord handshake packets should be the only ones accepted.
bool ShouldLimitPlayerBlockChanges(void) const
Returns true if limit for number of block changes per tick by a player has been turned on in server s...
cTickTimeLong m_UpTime
Time, in ticks, since the server started Not persistent across server restarts.
bool DoesAllowMultiLogin(void)
Can login more than once with same username.
The server tick thread takes care of the players who aren't yet spawned in a world.
cTickThread(cServer &a_Server)
virtual void Execute(void) override
This function, overloaded by the descendants, is called in the new thread.