diff --git a/1.10.2/src/main/kotlin/matterlink/MatterLink.kt b/1.10.2/src/main/kotlin/matterlink/MatterLink.kt index c3abf6a..0f6e40c 100644 --- a/1.10.2/src/main/kotlin/matterlink/MatterLink.kt +++ b/1.10.2/src/main/kotlin/matterlink/MatterLink.kt @@ -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 diff --git a/1.10.2/src/main/kotlin/matterlink/MatterLinkConfig.kt b/1.10.2/src/main/kotlin/matterlink/MatterLinkConfig.kt index 41dcc33..848ba57 100644 --- a/1.10.2/src/main/kotlin/matterlink/MatterLinkConfig.kt +++ b/1.10.2/src/main/kotlin/matterlink/MatterLinkConfig.kt @@ -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) } \ No newline at end of file diff --git a/1.11.2/src/main/kotlin/matterlink/MatterLink.kt b/1.11.2/src/main/kotlin/matterlink/MatterLink.kt index 6092e12..9ac2483 100644 --- a/1.11.2/src/main/kotlin/matterlink/MatterLink.kt +++ b/1.11.2/src/main/kotlin/matterlink/MatterLink.kt @@ -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 diff --git a/1.11.2/src/main/kotlin/matterlink/MatterLinkConfig.kt b/1.11.2/src/main/kotlin/matterlink/MatterLinkConfig.kt index 41dcc33..848ba57 100644 --- a/1.11.2/src/main/kotlin/matterlink/MatterLinkConfig.kt +++ b/1.11.2/src/main/kotlin/matterlink/MatterLinkConfig.kt @@ -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) } \ No newline at end of file diff --git a/1.12.2/src/main/kotlin/matterlink/MatterLink.kt b/1.12.2/src/main/kotlin/matterlink/MatterLink.kt index fdad07e..f1cb4e6 100644 --- a/1.12.2/src/main/kotlin/matterlink/MatterLink.kt +++ b/1.12.2/src/main/kotlin/matterlink/MatterLink.kt @@ -5,6 +5,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 @@ -36,7 +37,7 @@ object MatterLink : IMatterLink() { logger = event.modLog logger.info("Building bridge!") - MatterLinkConfig(event.suggestedConfigurationFile) + cfg = MatterLinkConfig(event.suggestedConfigurationFile) } @Mod.EventHandler diff --git a/1.12.2/src/main/kotlin/matterlink/MatterLinkConfig.kt b/1.12.2/src/main/kotlin/matterlink/MatterLinkConfig.kt index ea4525d..987b1cf 100644 --- a/1.12.2/src/main/kotlin/matterlink/MatterLinkConfig.kt +++ b/1.12.2/src/main/kotlin/matterlink/MatterLinkConfig.kt @@ -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) } \ No newline at end of file diff --git a/core/src/main/kotlin/matterlink/command/CommandCore.kt b/core/src/main/kotlin/matterlink/command/CommandCore.kt index 4c92b9a..e4e1406 100644 --- a/core/src/main/kotlin/matterlink/command/CommandCore.kt +++ b/core/src/main/kotlin/matterlink/command/CommandCore.kt @@ -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!" } diff --git a/core/src/main/kotlin/matterlink/config/BaseConfig.kt b/core/src/main/kotlin/matterlink/config/BaseConfig.kt index 47e269b..7775b5d 100644 --- a/core/src/main/kotlin/matterlink/config/BaseConfig.kt +++ b/core/src/main/kotlin/matterlink/config/BaseConfig.kt @@ -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 } \ No newline at end of file