Refactor BaseConfig.reload()
This commit is contained in:
parent
7b20616e0b
commit
cf2e514843
|
@ -23,4 +23,8 @@ class MatterLinkConfig(file: File) : BaseConfig(file) {
|
|||
|
||||
cfg = this
|
||||
}
|
||||
|
||||
override fun reload(file: File) {
|
||||
MatterLinkConfig(file)
|
||||
}
|
||||
}
|
|
@ -23,4 +23,8 @@ class MatterLinkConfig(file: File) : BaseConfig(file) {
|
|||
|
||||
cfg = this
|
||||
}
|
||||
|
||||
override fun reload(file: File) {
|
||||
MatterLinkConfig(file)
|
||||
}
|
||||
}
|
|
@ -21,4 +21,8 @@ class MatterLinkConfig(file: File) : BaseConfig(file) {
|
|||
if (config.hasChanged()) config.save()
|
||||
cfg = this
|
||||
}
|
||||
|
||||
override fun reload(file: File) {
|
||||
MatterLinkConfig(file)
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package matterlink.command
|
|||
|
||||
import matterlink.bridge.MessageHandler
|
||||
import matterlink.config.BaseConfig
|
||||
import matterlink.config.cfg
|
||||
import matterlink.instance
|
||||
|
||||
object CommandCore {
|
||||
|
@ -23,7 +24,7 @@ object CommandCore {
|
|||
}
|
||||
"reload" -> {
|
||||
if (MessageHandler.connected) instance.disconnect()
|
||||
BaseConfig.reload()
|
||||
cfg!!.reload(cfg!!.file)
|
||||
if (!MessageHandler.connected) instance.connect()
|
||||
"Bridge config reloaded!"
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ abstract class BaseConfig(val file : File) {
|
|||
private val CATEGORY_COMMAND = "command"
|
||||
private val CATEGORY_DEATH = "death"
|
||||
|
||||
@Deprecated("Use BaseConfig.loadConfig(file : File) instead")
|
||||
fun reload() {
|
||||
cfg = cfg!!.javaClass.getConstructor(cfg!!.file.javaClass).newInstance(cfg!!.file)
|
||||
}
|
||||
|
@ -257,4 +258,6 @@ abstract class BaseConfig(val file : File) {
|
|||
}
|
||||
)
|
||||
}
|
||||
|
||||
abstract fun reload(file : File)
|
||||
}
|
Loading…
Reference in New Issue