Added $uptime command, abstracted command registration into core
This commit is contained in:
parent
1032ed1619
commit
56dd6556bd
|
@ -43,7 +43,7 @@ object MatterLink : IMatterLink() {
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
fun init(event: FMLInitializationEvent) {
|
fun init(event: FMLInitializationEvent) {
|
||||||
BridgeCommandRegistry.registerAll(PlayerListCommand, HelpCommand)
|
this.registerBridgeCommands()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
|
|
|
@ -43,7 +43,7 @@ object MatterLink : IMatterLink() {
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
fun init(event: FMLInitializationEvent) {
|
fun init(event: FMLInitializationEvent) {
|
||||||
BridgeCommandRegistry.registerAll(PlayerListCommand, HelpCommand)
|
this.registerBridgeCommands()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
|
|
|
@ -41,7 +41,7 @@ object MatterLink : IMatterLink() {
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
fun init(event: FMLInitializationEvent) {
|
fun init(event: FMLInitializationEvent) {
|
||||||
BridgeCommandRegistry.registerAll(PlayerListCommand, HelpCommand)
|
this.registerBridgeCommands()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package matterlink
|
package matterlink
|
||||||
|
|
||||||
import matterlink.bridge.MessageHandler
|
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
|
import matterlink.config.cfg
|
||||||
|
|
||||||
lateinit var instance: IMatterLink
|
lateinit var instance: IMatterLink
|
||||||
|
@ -53,4 +57,8 @@ abstract class IMatterLink {
|
||||||
|
|
||||||
return "${day}d${hr}hr${min}m${sec}s"
|
return "${day}d${hr}hr${min}m${sec}s"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun registerBridgeCommands() {
|
||||||
|
BridgeCommandRegistry.registerAll(HelpCommand,PlayerListCommand,UptimeCommand)
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue