Added method to get the uptime of the server in seconds. Implements #1650.
This commit is contained in:
parent
150024265e
commit
c3b872ad93
@ -2061,6 +2061,7 @@ a_Player:OpenWindow(Window);
|
||||
GetPrimaryServerVersion = { Params = "", Return = "number", Notes = "Returns the servers primary server version." },
|
||||
GetProtocolVersionTextFromInt = { Params = "Protocol Version", Return = "string", Notes = "Returns the Minecraft version from the given Protocol. If there is no version found, it returns 'Unknown protocol(Parameter)'" },
|
||||
GetServer = { Params = "", Return = "{{cServer|cServer}}", Notes = "Returns the cServer object." },
|
||||
GetServerUpTime = { Params = "", Return = "number", Notes = "Returns the uptime of the server in seconds." },
|
||||
GetTotalChunkCount = { Params = "", Return = "number", Notes = "Returns the amount of loaded chunks." },
|
||||
GetVirtualRAMUsage = { Params = "", Return = "number", Notes = "Returns the amount of virtual RAM that the entire MCServer process is using, in KiB. Negative if the OS doesn't support this query." },
|
||||
GetWebAdmin = { Params = "", Return = "{{cWebAdmin|cWebAdmin}}", Notes = "Returns the cWebAdmin object." },
|
||||
@ -3020,7 +3021,3 @@ end
|
||||
{ FileName = "WebWorldThreads.html", Title = "Webserver vs World threads" },
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -207,6 +207,10 @@ void cRoot::Start(std::unique_ptr<cSettingsRepositoryInterface> overridesRepo)
|
||||
#endif
|
||||
|
||||
LOG("Startup complete, took %ldms!", static_cast<long int>(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - BeginTime).count()));
|
||||
|
||||
// Save the current time
|
||||
m_StartTime = std::chrono::steady_clock::now();
|
||||
|
||||
#ifdef _WIN32
|
||||
EnableMenuItem(hmenu, SC_CLOSE, MF_ENABLED); // Re-enable close button
|
||||
#endif
|
||||
@ -850,7 +854,3 @@ int cRoot::GetFurnaceFuelBurnTime(const cItem & a_Fuel)
|
||||
cFurnaceRecipe * FR = Get()->GetFurnaceRecipe();
|
||||
return FR->GetBurnTime(a_Fuel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
13
src/Root.h
13
src/Root.h
@ -70,6 +70,12 @@ public:
|
||||
a_OverworldName should be set for non-overworld dimensions if one wishes that world to link back to an overworld via portals
|
||||
*/
|
||||
cWorld * CreateAndInitializeWorld(const AString & a_WorldName, eDimension a_Dimension = dimOverworld, const AString & a_OverworldName = "");
|
||||
|
||||
/** Returns the up time of the server in seconds */
|
||||
int GetServerUpTime(void)
|
||||
{
|
||||
return static_cast<int>(std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - m_StartTime).count());
|
||||
}
|
||||
// tolua_end
|
||||
|
||||
/// Calls the callback for each world; returns true if the callback didn't abort (return true)
|
||||
@ -86,6 +92,9 @@ public:
|
||||
/// Returns the number of ticks for how long the item would fuel a furnace. Returns zero if not a fuel
|
||||
static int GetFurnaceFuelBurnTime(const cItem & a_Fuel); // tolua_export
|
||||
|
||||
/** The current time where the startup of the server has been completed */
|
||||
std::chrono::steady_clock::time_point m_StartTime;
|
||||
|
||||
cWebAdmin * GetWebAdmin (void) { return m_WebAdmin; } // tolua_export
|
||||
cPluginManager * GetPluginManager (void) { return m_PluginManager; } // tolua_export
|
||||
cAuthenticator & GetAuthenticator (void) { return m_Authenticator; }
|
||||
@ -223,7 +232,3 @@ private:
|
||||
|
||||
static void InputThread(cRoot & a_Params);
|
||||
}; // tolua_export
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user