Added $uptime command, abstracted command registration into core

This commit is contained in:
DaMachinator 2018-02-15 08:30:36 -05:00
parent 1032ed1619
commit 56dd6556bd
5 changed files with 32 additions and 3 deletions

View File

@ -43,7 +43,7 @@ object MatterLink : IMatterLink() {
@Mod.EventHandler
fun init(event: FMLInitializationEvent) {
BridgeCommandRegistry.registerAll(PlayerListCommand, HelpCommand)
this.registerBridgeCommands()
}
@Mod.EventHandler

View File

@ -43,7 +43,7 @@ object MatterLink : IMatterLink() {
@Mod.EventHandler
fun init(event: FMLInitializationEvent) {
BridgeCommandRegistry.registerAll(PlayerListCommand, HelpCommand)
this.registerBridgeCommands()
}
@Mod.EventHandler

View File

@ -41,7 +41,7 @@ object MatterLink : IMatterLink() {
@Mod.EventHandler
fun init(event: FMLInitializationEvent) {
BridgeCommandRegistry.registerAll(PlayerListCommand, HelpCommand)
this.registerBridgeCommands()
}
@Mod.EventHandler

View File

@ -1,6 +1,10 @@
package matterlink
import matterlink.bridge.MessageHandler
import matterlink.bridge.command.BridgeCommandRegistry
import matterlink.bridge.command.HelpCommand
import matterlink.bridge.command.PlayerListCommand
import matterlink.bridge.command.UptimeCommand
import matterlink.config.cfg
lateinit var instance: IMatterLink
@ -53,4 +57,8 @@ abstract class IMatterLink {
return "${day}d${hr}hr${min}m${sec}s"
}
fun registerBridgeCommands() {
BridgeCommandRegistry.registerAll(HelpCommand,PlayerListCommand,UptimeCommand)
}
}

View File

@ -0,0 +1,21 @@
package matterlink.bridge.command
import matterlink.bridge.ApiMessage
import matterlink.bridge.MessageHandler
import matterlink.config.cfg
import matterlink.instance
object UptimeCommand : IBridgeCommand {
override val name: String = "uptime"
override val help: String = "Get server uptime."
override fun call(args: String): Boolean {
if (args.isNotBlank()) return false
MessageHandler.transmit(ApiMessage(
username = cfg!!.relay.systemUser,
text = instance.getUptimeAsString()
))
return true
}
}