Implement /reload
This commit is contained in:
parent
06957f07fb
commit
51b184266b
|
@ -5,7 +5,7 @@ import matterlink.config.cfg
|
|||
import net.minecraftforge.common.config.Configuration
|
||||
import java.io.File
|
||||
|
||||
class MatterLinkConfig(file: File) : BaseConfig() {
|
||||
class MatterLinkConfig(file: File) : BaseConfig(file) {
|
||||
init {
|
||||
logger.info("Reading bridge blueprints... from {}", file)
|
||||
val config = Configuration(file)
|
||||
|
|
|
@ -5,7 +5,7 @@ import matterlink.config.cfg
|
|||
import net.minecraftforge.common.config.Configuration
|
||||
import java.io.File
|
||||
|
||||
class MatterLinkConfig(file: File) : BaseConfig() {
|
||||
class MatterLinkConfig(file: File) : BaseConfig(file) {
|
||||
init {
|
||||
logger.info("Reading bridge blueprints... from {}", file)
|
||||
val config = Configuration(file)
|
||||
|
|
|
@ -5,7 +5,7 @@ import matterlink.config.cfg
|
|||
import net.minecraftforge.common.config.Configuration
|
||||
import java.io.File
|
||||
|
||||
class MatterLinkConfig(file: File) : BaseConfig() {
|
||||
class MatterLinkConfig(file: File) : BaseConfig(file) {
|
||||
init {
|
||||
logger.info("Reading bridge blueprints... from {}", file)
|
||||
val config = Configuration(file)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package matterlink.command
|
||||
|
||||
import matterlink.bridge.MessageHandler
|
||||
import matterlink.config.BaseConfig
|
||||
import matterlink.instance
|
||||
|
||||
object CommandCore {
|
||||
|
@ -10,7 +12,7 @@ object CommandCore {
|
|||
fun execute(args : Array<String>) : String {
|
||||
val cmd = args[0].toLowerCase()
|
||||
|
||||
val reply : String = when (cmd) {
|
||||
return when (cmd) {
|
||||
"connect" -> {
|
||||
instance.connect()
|
||||
"Bridge connected!"
|
||||
|
@ -20,15 +22,15 @@ object CommandCore {
|
|||
"Bridge disconnected!"
|
||||
}
|
||||
"reload" -> {
|
||||
|
||||
if (MessageHandler.connected) instance.disconnect()
|
||||
BaseConfig.reload()
|
||||
if (!MessageHandler.connected) instance.connect()
|
||||
"Bridge config reloaded!"
|
||||
}
|
||||
else -> {
|
||||
"Invalid arguments for command!"
|
||||
}
|
||||
}
|
||||
|
||||
return reply
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
package matterlink.config
|
||||
|
||||
import java.io.File
|
||||
import java.util.regex.Pattern
|
||||
|
||||
var cfg: BaseConfig? = null
|
||||
|
||||
|
||||
abstract class BaseConfig {
|
||||
abstract class BaseConfig(val file : File) {
|
||||
companion object {
|
||||
private val CATEGORY_RELAY_OPTIONS = "relay"
|
||||
private val CATEGORY_FORMATTING_INCOMING = "formatting"
|
||||
|
@ -13,6 +13,10 @@ abstract class BaseConfig {
|
|||
private val CATEGORY_CONNECTION = "connection"
|
||||
private val CATEGORY_COMMAND = "command"
|
||||
private val CATEGORY_DEATH = "death"
|
||||
|
||||
fun reload() {
|
||||
cfg = cfg!!.javaClass.getConstructor(cfg!!.file.javaClass).newInstance(cfg!!.file)
|
||||
}
|
||||
}
|
||||
|
||||
var relay: RelayOptions = RelayOptions()
|
||||
|
|
Loading…
Reference in New Issue