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