diff --git a/1.10.2/src/main/kotlin/matterlink/MatterLink.kt b/1.10.2/src/main/kotlin/matterlink/MatterLink.kt index c3abf6a..6a703af 100644 --- a/1.10.2/src/main/kotlin/matterlink/MatterLink.kt +++ b/1.10.2/src/main/kotlin/matterlink/MatterLink.kt @@ -54,7 +54,7 @@ object MatterLink : IMatterLink() { fun serverStarting(event: FMLServerStartingEvent) { logger.debug("Registering server commands") event.registerServerCommand(CommandMatterlink()) - + serverStartTime = System.currentTimeMillis() connect() } diff --git a/1.11.2/src/main/kotlin/matterlink/MatterLink.kt b/1.11.2/src/main/kotlin/matterlink/MatterLink.kt index 6092e12..97f03c3 100644 --- a/1.11.2/src/main/kotlin/matterlink/MatterLink.kt +++ b/1.11.2/src/main/kotlin/matterlink/MatterLink.kt @@ -54,7 +54,7 @@ object MatterLink : IMatterLink() { fun serverStarting(event: FMLServerStartingEvent) { logger.debug("Registering server commands") event.registerServerCommand(CommandMatterlink()) - + serverStartTime = System.currentTimeMillis() connect() } diff --git a/1.12.2/src/main/kotlin/matterlink/MatterLink.kt b/1.12.2/src/main/kotlin/matterlink/MatterLink.kt index fdad07e..7f474c5 100644 --- a/1.12.2/src/main/kotlin/matterlink/MatterLink.kt +++ b/1.12.2/src/main/kotlin/matterlink/MatterLink.kt @@ -1,6 +1,5 @@ package matterlink -import matterlink.bridge.MessageHandler import matterlink.bridge.command.BridgeCommandRegistry import matterlink.bridge.command.HelpCommand import matterlink.bridge.command.PlayerListCommand @@ -53,7 +52,7 @@ object MatterLink : IMatterLink() { fun serverStarting(event: FMLServerStartingEvent) { logger.debug("Registering server commands") event.registerServerCommand(CommandMatterlink()) - + serverStartTime = System.currentTimeMillis() connect() } @@ -74,4 +73,5 @@ object MatterLink : IMatterLink() { override fun log(level: String, formatString: String, vararg data: Any) = logger.log(Level.toLevel(level, Level.INFO),formatString, *data) + } diff --git a/core/src/main/kotlin/matterlink/IMatterLink.kt b/core/src/main/kotlin/matterlink/IMatterLink.kt index 1908966..6575036 100644 --- a/core/src/main/kotlin/matterlink/IMatterLink.kt +++ b/core/src/main/kotlin/matterlink/IMatterLink.kt @@ -36,4 +36,21 @@ abstract class IMatterLink { log("INFO", "TRACE: " + formatString.replace("\n", "\nTRACE: "), *data) } + /** + * in milliseconds + */ + var serverStartTime : Long = 0 + fun getUptimeInSeconds() : Int { + return ((System.currentTimeMillis() - serverStartTime) / 1000).toInt() + } + + fun getUptimeAsString() : String { + val total = this.getUptimeInSeconds() + val sec = total % 60 + val min = (total/60)%60 + val hr = (total/3600)%24 + val day = total/86400 + + return "${day}d${hr}hr${min}m${sec}s" + } } \ No newline at end of file