Merge remote-tracking branch 'origin/master'

This commit is contained in:
DaMachinator 2018-02-15 08:19:44 -05:00
commit 1032ed1619
8 changed files with 16 additions and 27 deletions

View File

@ -6,6 +6,7 @@ import matterlink.bridge.command.BridgeCommandRegistry
import matterlink.bridge.command.HelpCommand
import matterlink.bridge.command.PlayerListCommand
import matterlink.command.CommandMatterlink
import matterlink.config.cfg
import net.minecraft.util.text.TextComponentString
import net.minecraftforge.fml.common.FMLCommonHandler
import net.minecraftforge.fml.common.Mod
@ -37,7 +38,7 @@ object MatterLink : IMatterLink() {
logger = event.modLog
logger.info("Building bridge!")
MatterLinkConfig(event.suggestedConfigurationFile)
cfg = MatterLinkConfig(event.suggestedConfigurationFile)
}
@Mod.EventHandler

View File

@ -5,7 +5,7 @@ import matterlink.config.cfg
import net.minecraftforge.common.config.Configuration
import java.io.File
class MatterLinkConfig(file: File) : BaseConfig(file) {
class MatterLinkConfig(val file: File) : BaseConfig() {
init {
logger.info("Reading bridge blueprints... from {}", file)
val config = Configuration(file)
@ -20,11 +20,7 @@ class MatterLinkConfig(file: File) : BaseConfig(file) {
)
if (config.hasChanged()) config.save()
cfg = this
}
override fun reload(file: File) {
MatterLinkConfig(file)
}
override fun load() = MatterLinkConfig(file)
}

View File

@ -6,6 +6,7 @@ import matterlink.bridge.command.BridgeCommandRegistry
import matterlink.bridge.command.HelpCommand
import matterlink.bridge.command.PlayerListCommand
import matterlink.command.CommandMatterlink
import matterlink.config.cfg
import net.minecraft.util.text.TextComponentString
import net.minecraftforge.fml.common.FMLCommonHandler
import net.minecraftforge.fml.common.Mod
@ -37,7 +38,7 @@ object MatterLink : IMatterLink() {
logger = event.modLog
logger.info("Building bridge!")
MatterLinkConfig(event.suggestedConfigurationFile)
cfg = MatterLinkConfig(event.suggestedConfigurationFile)
}
@Mod.EventHandler

View File

@ -5,7 +5,7 @@ import matterlink.config.cfg
import net.minecraftforge.common.config.Configuration
import java.io.File
class MatterLinkConfig(file: File) : BaseConfig(file) {
class MatterLinkConfig(val file: File) : BaseConfig() {
init {
logger.info("Reading bridge blueprints... from {}", file)
val config = Configuration(file)
@ -20,11 +20,7 @@ class MatterLinkConfig(file: File) : BaseConfig(file) {
)
if (config.hasChanged()) config.save()
cfg = this
}
override fun reload(file: File) {
MatterLinkConfig(file)
}
override fun load() = MatterLinkConfig(file)
}

View File

@ -4,6 +4,7 @@ import matterlink.bridge.command.BridgeCommandRegistry
import matterlink.bridge.command.HelpCommand
import matterlink.bridge.command.PlayerListCommand
import matterlink.command.CommandMatterlink
import matterlink.config.cfg
import net.minecraft.util.text.TextComponentString
import net.minecraftforge.fml.common.FMLCommonHandler
import net.minecraftforge.fml.common.Mod
@ -35,7 +36,7 @@ object MatterLink : IMatterLink() {
logger = event.modLog
logger.info("Building bridge!")
MatterLinkConfig(event.suggestedConfigurationFile)
cfg = MatterLinkConfig(event.suggestedConfigurationFile)
}
@Mod.EventHandler

View File

@ -5,7 +5,7 @@ import matterlink.config.cfg
import net.minecraftforge.common.config.Configuration
import java.io.File
class MatterLinkConfig(file: File) : BaseConfig(file) {
class MatterLinkConfig(val file: File) : BaseConfig() {
init {
logger.info("Reading bridge blueprints... from {}", file)
val config = Configuration(file)
@ -19,10 +19,7 @@ class MatterLinkConfig(file: File) : BaseConfig(file) {
addCustomCategoryComment = config::addCustomCategoryComment
)
if (config.hasChanged()) config.save()
cfg = this
}
override fun reload(file: File) {
MatterLinkConfig(file)
}
override fun load() = MatterLinkConfig(file)
}

View File

@ -1,7 +1,6 @@
package matterlink.command
import matterlink.bridge.MessageHandler
import matterlink.config.BaseConfig
import matterlink.config.cfg
import matterlink.instance
@ -24,7 +23,7 @@ object CommandCore {
}
"reload" -> {
if (MessageHandler.connected) instance.disconnect()
cfg!!.reload(cfg!!.file)
cfg = cfg!!.load()
if (!MessageHandler.connected) instance.connect()
"Bridge config reloaded!"
}

View File

@ -1,11 +1,10 @@
package matterlink.config
import java.io.File
import java.util.regex.Pattern
var cfg: BaseConfig? = null
abstract class BaseConfig(val file : File) {
abstract class BaseConfig {
companion object {
private val CATEGORY_RELAY_OPTIONS = "relay"
private val CATEGORY_FORMATTING_INCOMING = "formatting"
@ -14,9 +13,8 @@ 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)
cfg = cfg!!.load()
}
}
@ -259,5 +257,5 @@ abstract class BaseConfig(val file : File) {
)
}
abstract fun reload(file : File)
abstract fun load(): BaseConfig
}