switch main config to hjson
This commit is contained in:
parent
6af52cc58e
commit
5eb79935ba
|
@ -2,6 +2,7 @@ package matterlink
|
||||||
|
|
||||||
import matterlink.command.CommandMatterlink
|
import matterlink.command.CommandMatterlink
|
||||||
import matterlink.command.MatterLinkCommandSender
|
import matterlink.command.MatterLinkCommandSender
|
||||||
|
import matterlink.config.BaseConfig
|
||||||
import matterlink.config.cfg
|
import matterlink.config.cfg
|
||||||
import net.minecraft.util.text.TextComponentString
|
import net.minecraft.util.text.TextComponentString
|
||||||
import net.minecraftforge.common.ForgeVersion
|
import net.minecraftforge.common.ForgeVersion
|
||||||
|
@ -35,7 +36,7 @@ object MatterLink : IMatterLink() {
|
||||||
logger = event.modLog
|
logger = event.modLog
|
||||||
logger.info("Building bridge!")
|
logger.info("Building bridge!")
|
||||||
|
|
||||||
cfg = MatterLinkConfig(event.modConfigurationDirectory)
|
cfg = BaseConfig(event.modConfigurationDirectory).load()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
package matterlink
|
|
||||||
|
|
||||||
import matterlink.config.BaseConfig
|
|
||||||
import net.minecraftforge.common.config.Configuration
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
class MatterLinkConfig(val baseCfgDir: File) : BaseConfig(baseCfgDir) {
|
|
||||||
init {
|
|
||||||
logger.info("Reading bridge blueprints... from {}", cfgDirectory)
|
|
||||||
val config = Configuration(mainCfgFile)
|
|
||||||
|
|
||||||
load(
|
|
||||||
getBoolean = config::getBoolean,
|
|
||||||
getString = config::getString,
|
|
||||||
getStringValidated = config::getString,
|
|
||||||
getStringValidValues = config::getString,
|
|
||||||
getStringList = config::getStringList,
|
|
||||||
addCustomCategoryComment = config::addCustomCategoryComment
|
|
||||||
)
|
|
||||||
if (config.hasChanged()) config.save()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun load() = MatterLinkConfig(baseCfgDir)
|
|
||||||
}
|
|
|
@ -2,6 +2,7 @@ package matterlink
|
||||||
|
|
||||||
import matterlink.command.CommandMatterlink
|
import matterlink.command.CommandMatterlink
|
||||||
import matterlink.command.MatterLinkCommandSender
|
import matterlink.command.MatterLinkCommandSender
|
||||||
|
import matterlink.config.BaseConfig
|
||||||
import matterlink.config.cfg
|
import matterlink.config.cfg
|
||||||
import net.minecraft.util.text.TextComponentString
|
import net.minecraft.util.text.TextComponentString
|
||||||
import net.minecraftforge.common.ForgeVersion
|
import net.minecraftforge.common.ForgeVersion
|
||||||
|
@ -35,7 +36,7 @@ object MatterLink : IMatterLink() {
|
||||||
logger = event.modLog
|
logger = event.modLog
|
||||||
logger.info("Building bridge!")
|
logger.info("Building bridge!")
|
||||||
|
|
||||||
cfg = MatterLinkConfig(event.modConfigurationDirectory)
|
cfg = BaseConfig(event.modConfigurationDirectory).load()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
package matterlink
|
|
||||||
|
|
||||||
import matterlink.config.BaseConfig
|
|
||||||
import net.minecraftforge.common.config.Configuration
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
class MatterLinkConfig(val baseCfgDir: File) : BaseConfig(baseCfgDir) {
|
|
||||||
init {
|
|
||||||
logger.info("Reading bridge blueprints... from {}", cfgDirectory)
|
|
||||||
val config = Configuration(mainCfgFile)
|
|
||||||
|
|
||||||
load(
|
|
||||||
getBoolean = config::getBoolean,
|
|
||||||
getString = config::getString,
|
|
||||||
getStringValidated = config::getString,
|
|
||||||
getStringValidValues = config::getString,
|
|
||||||
getStringList = config::getStringList,
|
|
||||||
addCustomCategoryComment = config::addCustomCategoryComment
|
|
||||||
)
|
|
||||||
if (config.hasChanged()) config.save()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun load() = MatterLinkConfig(baseCfgDir)
|
|
||||||
}
|
|
|
@ -2,12 +2,16 @@ package matterlink
|
||||||
|
|
||||||
import matterlink.command.CommandMatterlink
|
import matterlink.command.CommandMatterlink
|
||||||
import matterlink.command.MatterLinkCommandSender
|
import matterlink.command.MatterLinkCommandSender
|
||||||
|
import matterlink.config.BaseConfig
|
||||||
import matterlink.config.cfg
|
import matterlink.config.cfg
|
||||||
import net.minecraft.util.text.TextComponentString
|
import net.minecraft.util.text.TextComponentString
|
||||||
import net.minecraftforge.common.ForgeVersion
|
import net.minecraftforge.common.ForgeVersion
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler
|
import net.minecraftforge.fml.common.FMLCommonHandler
|
||||||
import net.minecraftforge.fml.common.Mod
|
import net.minecraftforge.fml.common.Mod
|
||||||
import net.minecraftforge.fml.common.event.*
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent
|
||||||
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent
|
||||||
|
import net.minecraftforge.fml.common.event.FMLServerStartingEvent
|
||||||
|
import net.minecraftforge.fml.common.event.FMLServerStoppingEvent
|
||||||
import org.apache.logging.log4j.Level
|
import org.apache.logging.log4j.Level
|
||||||
import org.apache.logging.log4j.Logger
|
import org.apache.logging.log4j.Logger
|
||||||
|
|
||||||
|
@ -32,7 +36,7 @@ object MatterLink : IMatterLink() {
|
||||||
logger = event.modLog
|
logger = event.modLog
|
||||||
logger.info("Building bridge!")
|
logger.info("Building bridge!")
|
||||||
|
|
||||||
cfg = MatterLinkConfig(event.modConfigurationDirectory)
|
cfg = BaseConfig(event.modConfigurationDirectory).load()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
|
@ -40,11 +44,6 @@ object MatterLink : IMatterLink() {
|
||||||
this.registerBridgeCommands()
|
this.registerBridgeCommands()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
|
||||||
fun serverAboutToStart(event: FMLServerAboutToStartEvent) {
|
|
||||||
// MessageHandlerInst.start(clear = true)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
fun serverStarting(event: FMLServerStartingEvent) {
|
fun serverStarting(event: FMLServerStartingEvent) {
|
||||||
log("DEBUG", "Registering server commands")
|
log("DEBUG", "Registering server commands")
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
package matterlink
|
|
||||||
|
|
||||||
import matterlink.config.BaseConfig
|
|
||||||
import net.minecraftforge.common.config.Configuration
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
class MatterLinkConfig(val baseCfgDir: File) : BaseConfig(baseCfgDir) {
|
|
||||||
init {
|
|
||||||
logger.info("Reading bridge blueprints... from {}", cfgDirectory)
|
|
||||||
val config = Configuration(mainCfgFile)
|
|
||||||
|
|
||||||
load(
|
|
||||||
getBoolean = config::getBoolean,
|
|
||||||
getString = config::getString,
|
|
||||||
getStringValidated = config::getString,
|
|
||||||
getStringValidValues = config::getString,
|
|
||||||
getStringList = config::getStringList,
|
|
||||||
addCustomCategoryComment = config::addCustomCategoryComment
|
|
||||||
)
|
|
||||||
if (config.hasChanged()) config.save()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun load() = MatterLinkConfig(baseCfgDir)
|
|
||||||
}
|
|
|
@ -8,6 +8,7 @@ import cpw.mods.fml.common.event.FMLServerStartingEvent
|
||||||
import cpw.mods.fml.common.event.FMLServerStoppingEvent
|
import cpw.mods.fml.common.event.FMLServerStoppingEvent
|
||||||
import matterlink.command.CommandMatterlink
|
import matterlink.command.CommandMatterlink
|
||||||
import matterlink.command.MatterLinkCommandSender
|
import matterlink.command.MatterLinkCommandSender
|
||||||
|
import matterlink.config.BaseConfig
|
||||||
import matterlink.config.cfg
|
import matterlink.config.cfg
|
||||||
import net.minecraft.server.MinecraftServer
|
import net.minecraft.server.MinecraftServer
|
||||||
import net.minecraft.util.ChatComponentText
|
import net.minecraft.util.ChatComponentText
|
||||||
|
@ -37,7 +38,7 @@ class MatterLink : IMatterLink() {
|
||||||
logger = event.modLog
|
logger = event.modLog
|
||||||
logger.info("Building bridge!")
|
logger.info("Building bridge!")
|
||||||
|
|
||||||
cfg = MatterLinkConfig(event.modConfigurationDirectory)
|
cfg = BaseConfig(event.modConfigurationDirectory).load()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
package matterlink
|
|
||||||
|
|
||||||
import matterlink.config.BaseConfig
|
|
||||||
import net.minecraftforge.common.config.Configuration
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
class MatterLinkConfig(val baseCfgDir: File) : BaseConfig(baseCfgDir) {
|
|
||||||
init {
|
|
||||||
logger.info("Reading bridge blueprints... from {}", cfgDirectory)
|
|
||||||
val config = Configuration(mainCfgFile)
|
|
||||||
|
|
||||||
load(
|
|
||||||
getBoolean = config::getBoolean,
|
|
||||||
getString = config::getString,
|
|
||||||
getStringValidated = config::getString,
|
|
||||||
getStringValidValues = config::getString,
|
|
||||||
getStringList = config::getStringList,
|
|
||||||
addCustomCategoryComment = config::addCustomCategoryComment
|
|
||||||
)
|
|
||||||
if (config.hasChanged()) config.save()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun load() = MatterLinkConfig(baseCfgDir)
|
|
||||||
}
|
|
2
Jankson
2
Jankson
|
@ -1 +1 @@
|
||||||
Subproject commit ce97d00016a58a4402d919155efa0fccec5ea9e6
|
Subproject commit 90b600e2acdbba48a9a3c39d85a49a9ec24e8db1
|
|
@ -1,5 +1,6 @@
|
||||||
package matterlink
|
package matterlink
|
||||||
|
|
||||||
|
import blue.endless.jankson.JsonObject
|
||||||
import matterlink.config.cfg
|
import matterlink.config.cfg
|
||||||
import java.io.PrintWriter
|
import java.io.PrintWriter
|
||||||
import java.io.StringWriter
|
import java.io.StringWriter
|
||||||
|
@ -54,3 +55,8 @@ val Exception.stackTraceString: String
|
||||||
this.printStackTrace(PrintWriter(sw))
|
this.printStackTrace(PrintWriter(sw))
|
||||||
return sw.toString()
|
return sw.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline fun <reified T : Any> JsonObject.getOrDefault(key: String, default: T, comment: String? = null): T {
|
||||||
|
instance.info("type: ${T::class.java.name} key: $key default: $default")
|
||||||
|
return putDefault(key, default, comment)!!
|
||||||
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ object BridgeCommandRegistry {
|
||||||
fun handleCommand(input: ApiMessage): Boolean {
|
fun handleCommand(input: ApiMessage): Boolean {
|
||||||
if (!cfg.command.enable || input.text.isBlank()) return false
|
if (!cfg.command.enable || input.text.isBlank()) return false
|
||||||
|
|
||||||
if (input.text[0] != cfg.command.prefix[0] || input.text.length < 2) return false
|
if (input.text[0] != cfg.command.prefix || input.text.length < 2) return false
|
||||||
|
|
||||||
val cmd = input.text.substring(1).split(' ', ignoreCase = false, limit = 2)
|
val cmd = input.text.substring(1).split(' ', ignoreCase = false, limit = 2)
|
||||||
val args = if (cmd.size == 2) cmd[1] else ""
|
val args = if (cmd.size == 2) cmd[1] else ""
|
||||||
|
|
|
@ -2,6 +2,7 @@ package matterlink.command
|
||||||
|
|
||||||
import matterlink.bridge.MessageHandlerInst
|
import matterlink.bridge.MessageHandlerInst
|
||||||
import matterlink.bridge.command.BridgeCommandRegistry
|
import matterlink.bridge.command.BridgeCommandRegistry
|
||||||
|
import matterlink.config.baseCfg
|
||||||
import matterlink.config.cfg
|
import matterlink.config.cfg
|
||||||
|
|
||||||
object CommandCore {
|
object CommandCore {
|
||||||
|
@ -26,7 +27,7 @@ object CommandCore {
|
||||||
"reload" -> {
|
"reload" -> {
|
||||||
// if (MessageHandlerInst.connected)
|
// if (MessageHandlerInst.connected)
|
||||||
MessageHandlerInst.stop("Bridge restarting (reload command issued by console)")
|
MessageHandlerInst.stop("Bridge restarting (reload command issued by console)")
|
||||||
cfg = cfg.load()
|
cfg = baseCfg.load()
|
||||||
BridgeCommandRegistry.reloadCommands()
|
BridgeCommandRegistry.reloadCommands()
|
||||||
// if (!MessageHandlerInst.connected)
|
// if (!MessageHandlerInst.connected)
|
||||||
MessageHandlerInst.start("Bridge reconnected", false)
|
MessageHandlerInst.start("Bridge reconnected", false)
|
||||||
|
|
|
@ -1,26 +1,40 @@
|
||||||
package matterlink.config
|
package matterlink.config
|
||||||
|
|
||||||
|
import blue.endless.jankson.Jankson
|
||||||
|
import blue.endless.jankson.JsonObject
|
||||||
|
import blue.endless.jankson.impl.Marshaller
|
||||||
|
import blue.endless.jankson.impl.SyntaxError
|
||||||
import matterlink.bridge.MessageHandlerInst
|
import matterlink.bridge.MessageHandlerInst
|
||||||
|
import matterlink.getOrDefault
|
||||||
|
import matterlink.instance
|
||||||
|
import matterlink.stackTraceString
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.regex.Pattern
|
import java.io.FileNotFoundException
|
||||||
|
|
||||||
lateinit var cfg: BaseConfig
|
lateinit var cfg: BaseConfig.MatterLinkConfig
|
||||||
|
lateinit var baseCfg: BaseConfig
|
||||||
|
|
||||||
abstract class BaseConfig(rootDir: File) {
|
data class BaseConfig(val rootDir: File) {
|
||||||
val cfgDirectory: File = rootDir.resolve("matterlink")
|
val cfgDirectory: File = rootDir.resolve("matterlink")
|
||||||
val mainCfgFile: File = cfgDirectory.resolve("matterlink.cfg")
|
val configFile: File = cfgDirectory.resolve("matterlink.hjson")
|
||||||
|
|
||||||
|
init {
|
||||||
|
instance.info("Reading bridge blueprints... from {}", rootDir)
|
||||||
|
baseCfg = this
|
||||||
|
}
|
||||||
|
|
||||||
var connect = ConnectOptions()
|
data class MatterLinkConfig(
|
||||||
var debug = DebugOptions()
|
val connect: ConnectOptions = ConnectOptions(),
|
||||||
var incoming = IncomingOption()
|
val debug: DebugOptions = DebugOptions(),
|
||||||
var outgoing = OutgoingOptions()
|
val incoming: IncomingOptions = IncomingOptions(),
|
||||||
var command = CommandOptions()
|
val outgoing: OutgoingOptions = OutgoingOptions(),
|
||||||
var update = UpdateOptions()
|
val command: CommandOptions = CommandOptions(),
|
||||||
|
val update: UpdateOptions = UpdateOptions()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
data class CommandOptions(
|
data class CommandOptions(
|
||||||
val prefix: String = "!",
|
val prefix: Char = '!',
|
||||||
val enable: Boolean = true
|
val enable: Boolean = true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -36,10 +50,10 @@ abstract class BaseConfig(rootDir: File) {
|
||||||
var logLevel: String = "INFO"
|
var logLevel: String = "INFO"
|
||||||
)
|
)
|
||||||
|
|
||||||
data class IncomingOption(
|
data class IncomingOptions(
|
||||||
val chat: String = "<{username}> {text}",
|
val chat: String = "<{username}> {text}",
|
||||||
val joinPart: String = "§6-- {username} {text}",
|
val joinPart: String = "",//"§6-- {username} {text}",
|
||||||
val action: String = "§5* {username} {text}",
|
val action: String = "",//"§5* {username} {text}",
|
||||||
var stripColors: Boolean = true
|
var stripColors: Boolean = true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -58,36 +72,36 @@ abstract class BaseConfig(rootDir: File) {
|
||||||
data class DeathOptions(
|
data class DeathOptions(
|
||||||
val enable: Boolean = true,
|
val enable: Boolean = true,
|
||||||
val damageType: Boolean = true,
|
val damageType: Boolean = true,
|
||||||
val damageTypeMapping: Map<String, String> = mapOf(
|
val damageTypeMapping: Map<String, Array<String>> = mapOf(
|
||||||
"inFire" to "\uD83D\uDD25", //🔥
|
"inFire" to arrayOf("\uD83D\uDD25"), //🔥
|
||||||
"lightningBolt" to "\uD83C\uDF29", //🌩
|
"lightningBolt" to arrayOf("\uD83C\uDF29"), //🌩
|
||||||
"onFire" to "\uD83D\uDD25", //🔥
|
"onFire" to arrayOf("\uD83D\uDD25"), //🔥
|
||||||
"lava" to "\uD83D\uDD25", //🔥
|
"lava" to arrayOf("\uD83D\uDD25"), //🔥
|
||||||
"hotFloor" to "♨️",
|
"hotFloor" to arrayOf("♨️"),
|
||||||
"inWall" to "",
|
"inWall" to arrayOf(),
|
||||||
"cramming" to "",
|
"cramming" to arrayOf(),
|
||||||
"drown" to "\uD83C\uDF0A", //🌊
|
"drown" to arrayOf("\uD83C\uDF0A"), //🌊
|
||||||
"starve" to "\uD83D\uDC80", //💀
|
"starve" to arrayOf("\uD83D\uDC80"), //💀
|
||||||
"cactus" to "\uD83C\uDF35", //🌵
|
"cactus" to arrayOf("\uD83C\uDF35"), //🌵
|
||||||
"fall" to "\u2BEF️", //⯯️
|
"fall" to arrayOf("\u2BEF️"), //⯯️
|
||||||
"flyIntoWall" to "\uD83D\uDCA8", //💨
|
"flyIntoWall" to arrayOf("\uD83D\uDCA8"), //💨
|
||||||
"outOfWorld" to "\u2734", //✴
|
"outOfWorld" to arrayOf("\u2734"), //✴
|
||||||
"generic" to "\uD83D\uDC7B", //👻
|
"generic" to arrayOf("\uD83D\uDC7B"), //👻
|
||||||
"magic" to "✨ ⚚",
|
"magic" to arrayOf("✨ ⚚"),
|
||||||
"indirectMagic" to "✨ ⚚",
|
"indirectMagic" to arrayOf("✨ ⚚"),
|
||||||
"wither" to "\uD83D\uDD71", //🕱
|
"wither" to arrayOf("\uD83D\uDD71"), //🕱
|
||||||
"anvil" to "",
|
"anvil" to arrayOf(),
|
||||||
"fallingBlock" to "",
|
"fallingBlock" to arrayOf(),
|
||||||
"dragonBreath" to "\uD83D\uDC32", //🐲
|
"dragonBreath" to arrayOf("\uD83D\uDC32"), //🐲
|
||||||
"fireworks" to "\uD83C\uDF86", //🎆
|
"fireworks" to arrayOf("\uD83C\uDF86"), //🎆
|
||||||
|
|
||||||
"mob" to "\uD83D\uDC80", //💀
|
"mob" to arrayOf("\uD83D\uDC80"), //💀
|
||||||
"player" to "\uD83D\uDDE1", //🗡
|
"player" to arrayOf("\uD83D\uDDE1"), //🗡
|
||||||
"arrow" to "\uD83C\uDFF9", //🏹
|
"arrow" to arrayOf("\uD83C\uDFF9"), //🏹
|
||||||
"thrown" to "彡°",
|
"thrown" to arrayOf("彡°"),
|
||||||
"thorns" to "\uD83C\uDF39", //🌹
|
"thorns" to arrayOf("\uD83C\uDF39"), //🌹
|
||||||
"explosion" to "\uD83D\uDCA3 \uD83D\uDCA5", //💣 💥
|
"explosion" to arrayOf("\uD83D\uDCA3", "\uD83D\uDCA5"), //💣 💥
|
||||||
"explosion.player" to "\uD83D\uDCA3 \uD83D\uDCA5" //💣 💥
|
"explosion.player" to arrayOf("\uD83D\uDCA3", "\uD83D\uDCA5") //💣 💥
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -101,228 +115,279 @@ abstract class BaseConfig(rootDir: File) {
|
||||||
val enable: Boolean = true
|
val enable: Boolean = true
|
||||||
)
|
)
|
||||||
|
|
||||||
protected fun load(
|
companion object {
|
||||||
getBoolean: (key: String, category: String, default: Boolean, comment: String) -> Boolean,
|
val jankson = Jankson
|
||||||
getString: (key: String, category: String, default: String, comment: String) -> String,
|
.builder()
|
||||||
getStringValidated: (key: String, category: String, default: String, comment: String, pattern: Pattern) -> String,
|
.registerTypeAdapter(MatterLinkConfig::class.java) {
|
||||||
getStringValidValues: (key: String, category: String, default: String, comment: String, validValues: Array<String>) -> String,
|
MatterLinkConfig(
|
||||||
getStringList: (name: String, category: String, defaultValues: Array<String>, comment: String) -> Array<String>,
|
command = it.getOrDefault(
|
||||||
addCustomCategoryComment: (key: String, comment: String) -> Unit
|
"command",
|
||||||
) {
|
CommandOptions(),
|
||||||
|
"User commands"
|
||||||
var category = "commands"
|
),
|
||||||
|
connect = it.getOrDefault(
|
||||||
addCustomCategoryComment(category, "User commands")
|
"connect",
|
||||||
command = CommandOptions(
|
ConnectOptions(),
|
||||||
enable = getBoolean(
|
"Connection Settings"
|
||||||
|
),
|
||||||
|
debug = it.getOrDefault(
|
||||||
|
"debug",
|
||||||
|
DebugOptions(),
|
||||||
|
"Options to help you figure out what happens and why, because computers can be silly"
|
||||||
|
),
|
||||||
|
incoming = it.getOrDefault(
|
||||||
|
"incoming",
|
||||||
|
IncomingOptions(),
|
||||||
|
"""
|
||||||
|
Gateway -> Server
|
||||||
|
Options all about receiving messages from the API
|
||||||
|
Formatting options:
|
||||||
|
Available variables: {username}, {text}, {gateway}, {channel}, {protocol}, {username:antiping}
|
||||||
|
""".trimIndent()
|
||||||
|
),
|
||||||
|
outgoing = it.getOrDefault(
|
||||||
|
"outgoing",
|
||||||
|
OutgoingOptions(),
|
||||||
|
"""
|
||||||
|
Server -> Gateway
|
||||||
|
Options all about sending messages to the API
|
||||||
|
""".trimIndent()
|
||||||
|
),
|
||||||
|
update = it.getOrDefault(
|
||||||
|
"update",
|
||||||
|
UpdateOptions(),
|
||||||
|
"Update Settings"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
.registerTypeAdapter(CommandOptions::class.java) {
|
||||||
|
with(CommandOptions()) {
|
||||||
|
CommandOptions(
|
||||||
|
enable = it.getOrDefault(
|
||||||
"enable",
|
"enable",
|
||||||
category,
|
enable,
|
||||||
command.enable,
|
|
||||||
"Enable MC bridge commands"
|
"Enable MC bridge commands"
|
||||||
),
|
),
|
||||||
prefix = getStringValidated(
|
prefix = it.getOrDefault(
|
||||||
"prefix",
|
"prefix",
|
||||||
category,
|
prefix,
|
||||||
command.prefix,
|
"Prefix for MC bridge commands. Accepts a single character (not alphanumeric or /)"
|
||||||
"Prefix for MC bridge commands. Accepts a single character (not alphanumeric or /)",
|
|
||||||
Pattern.compile("^[^0-9A-Za-z/]$")
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
}
|
||||||
category = "connection"
|
}
|
||||||
addCustomCategoryComment(category, "Connection settings")
|
.registerTypeAdapter(ConnectOptions::class.java) {
|
||||||
connect = ConnectOptions(
|
with(ConnectOptions()) {
|
||||||
url = getString(
|
ConnectOptions(
|
||||||
"connectURL",
|
url = it.getOrDefault(
|
||||||
category,
|
"url",
|
||||||
connect.url,
|
url,
|
||||||
"The URL or IP address of the bridge server"
|
"The URL or IP address of the bridge server"
|
||||||
),
|
),
|
||||||
authToken = getString(
|
authToken = it.getOrDefault(
|
||||||
"authToken",
|
"authToken",
|
||||||
category,
|
authToken,
|
||||||
connect.authToken,
|
|
||||||
"Auth token used to connect to the bridge server"
|
"Auth token used to connect to the bridge server"
|
||||||
),
|
),
|
||||||
gateway = getString(
|
gateway = it.getOrDefault(
|
||||||
"gateway",
|
"gateway",
|
||||||
category,
|
gateway,
|
||||||
connect.gateway,
|
|
||||||
"MatterBridge gateway"
|
"MatterBridge gateway"
|
||||||
),
|
),
|
||||||
autoConnect = getBoolean(
|
autoConnect = it.getOrDefault(
|
||||||
"autoConnect",
|
"autoConnect",
|
||||||
category,
|
autoConnect,
|
||||||
connect.autoConnect,
|
|
||||||
"Connect the relay on startup"
|
"Connect the relay on startup"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
}
|
||||||
category = "debug"
|
}
|
||||||
addCustomCategoryComment(category, "Options to help you figure out what happens and why, because computers can be silly")
|
.registerTypeAdapter(DebugOptions::class.java) {
|
||||||
debug = DebugOptions(
|
with(DebugOptions()) {
|
||||||
logLevel = getStringValidValues(
|
DebugOptions(
|
||||||
"logLevel",
|
logLevel = it.getOrDefault("loglevel", logLevel, "MatterLink log level")
|
||||||
category,
|
|
||||||
debug.logLevel,
|
|
||||||
"MatterLink log level",
|
|
||||||
arrayOf("INFO", "DEBUG", "TRACE")
|
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
|
}
|
||||||
category = "incoming"
|
.registerTypeAdapter(IncomingOptions::class.java) {
|
||||||
addCustomCategoryComment(category, "Gateway -> Server" +
|
with(IncomingOptions()) {
|
||||||
"\nOptions all about receiving messages from the API" +
|
IncomingOptions(
|
||||||
"\nFormatting options: " +
|
chat = it.getOrDefault(
|
||||||
"\nAvailable variables: {username}, {text}, {gateway}, {channel}, {protocol}, {username:antiping}")
|
|
||||||
incoming = IncomingOption(
|
|
||||||
chat = getString(
|
|
||||||
"chat",
|
"chat",
|
||||||
category,
|
chat,
|
||||||
incoming.chat,
|
|
||||||
"Generic chat event, just talking"
|
"Generic chat event, just talking"
|
||||||
),
|
),
|
||||||
joinPart = getString(
|
joinPart = it.getOrDefault(
|
||||||
"joinPart",
|
"joinPart",
|
||||||
category,
|
joinPart,
|
||||||
incoming.joinPart,
|
|
||||||
"Join and part events from other gateways"
|
"Join and part events from other gateways"
|
||||||
),
|
),
|
||||||
action = getString(
|
action = it.getOrDefault(
|
||||||
"action",
|
"action",
|
||||||
category,
|
action,
|
||||||
incoming.action,
|
|
||||||
"User actions (/me) sent by users from other gateways"
|
"User actions (/me) sent by users from other gateways"
|
||||||
),
|
),
|
||||||
stripColors = getBoolean(
|
stripColors = it.getOrDefault(
|
||||||
"stripColors",
|
"stripColors",
|
||||||
category,
|
stripColors,
|
||||||
incoming.stripColors,
|
|
||||||
"strip colors from incoming text"
|
"strip colors from incoming text"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
}
|
||||||
category = "outgoing"
|
}
|
||||||
addCustomCategoryComment(category, "Server -> Gateway" +
|
.registerTypeAdapter(OutgoingOptions::class.java) {
|
||||||
"\nOptions all about sending messages to the API")
|
with(OutgoingOptions()) {
|
||||||
|
OutgoingOptions(
|
||||||
outgoing = OutgoingOptions(
|
systemUser = it.getOrDefault(
|
||||||
systemUser = getString(
|
|
||||||
"systemUser",
|
"systemUser",
|
||||||
category,
|
systemUser,
|
||||||
outgoing.systemUser,
|
|
||||||
"Name of the server user (used by death and advancement messages and the /say command)"
|
"Name of the server user (used by death and advancement messages and the /say command)"
|
||||||
),
|
),
|
||||||
//outgoing events toggle
|
advancements = it.getOrDefault(
|
||||||
advancements = getBoolean(
|
|
||||||
"advancements",
|
"advancements",
|
||||||
category,
|
advancements,
|
||||||
outgoing.advancements,
|
|
||||||
"Relay player achievements / advancements"
|
"Relay player achievements / advancements"
|
||||||
),
|
),
|
||||||
announceConnect = getBoolean(
|
announceConnect = it.getOrDefault(
|
||||||
"announceConnect",
|
"announceConnect",
|
||||||
category,
|
announceConnect,
|
||||||
outgoing.announceConnect,
|
|
||||||
"announce successful connection to the gateway"
|
"announce successful connection to the gateway"
|
||||||
),
|
),
|
||||||
announceDisconnect = getBoolean(
|
announceDisconnect = it.getOrDefault(
|
||||||
"announceDisconnect",
|
"announceDisconnect",
|
||||||
category,
|
announceConnect,
|
||||||
outgoing.announceConnect,
|
|
||||||
"announce intention to disconnect / reconnect"
|
"announce intention to disconnect / reconnect"
|
||||||
),
|
),
|
||||||
stripColors = getBoolean(
|
stripColors = it.getOrDefault(
|
||||||
"stripColors",
|
"stripColors",
|
||||||
category,
|
stripColors,
|
||||||
outgoing.stripColors,
|
|
||||||
"strip colors from nicknames and messages"
|
"strip colors from nicknames and messages"
|
||||||
|
),
|
||||||
|
death = it.getOrDefault(
|
||||||
|
"death",
|
||||||
|
DeathOptions(),
|
||||||
|
"Death messages settings"
|
||||||
|
),
|
||||||
|
joinPart = it.getOrDefault(
|
||||||
|
"joinPart",
|
||||||
|
JoinPartOptions(),
|
||||||
|
"relay join and part messages to the gatway"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
}
|
||||||
category = "outgoing.death"
|
}
|
||||||
addCustomCategoryComment(category, "Death messages settings")
|
.registerTypeAdapter(DeathOptions::class.java) { jsonObj ->
|
||||||
outgoing.death = DeathOptions(
|
with(DeathOptions()) {
|
||||||
|
DeathOptions(
|
||||||
enable = getBoolean(
|
enable = jsonObj.getOrDefault(
|
||||||
"enable",
|
"enable",
|
||||||
category,
|
enable,
|
||||||
outgoing.death.enable,
|
|
||||||
"Relay player death messages"
|
"Relay player death messages"
|
||||||
),
|
),
|
||||||
damageType = getBoolean(
|
damageType = jsonObj.getOrDefault(
|
||||||
"damageType",
|
"damageType",
|
||||||
category,
|
damageType,
|
||||||
outgoing.death.damageType,
|
|
||||||
"Enable Damage type symbols on death messages"
|
"Enable Damage type symbols on death messages"
|
||||||
),
|
),
|
||||||
damageTypeMapping = getStringList(
|
damageTypeMapping = (jsonObj.getObject("damageTypeMapping")
|
||||||
"damageTypeMapping",
|
?: Marshaller.getFallback().serialize(damageTypeMapping) as JsonObject)
|
||||||
category,
|
.let {
|
||||||
outgoing.death.damageTypeMapping.map { entry ->
|
jsonObj.setComment(
|
||||||
"${entry.key}=${entry.value}"
|
"damageTypMapping",
|
||||||
|
"Damage type mapping for death cause"
|
||||||
|
)
|
||||||
|
it.mapValues { (key, element) ->
|
||||||
|
it.getOrDefault(key, damageTypeMapping[key] ?: emptyArray(), key)
|
||||||
|
.apply { it[key] }.apply {
|
||||||
|
jsonObj["damageTypeMapping"] = it
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.toTypedArray(),
|
|
||||||
"Damage type mapping for death cause, " +
|
|
||||||
"\nseparate value and key with '=', " +
|
|
||||||
"\nseparate multiple values with spaces\n"
|
|
||||||
).associate {
|
|
||||||
val key = it.substringBefore('=')
|
|
||||||
val value = it.substringAfter('=')
|
|
||||||
Pair(key, value)
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
}
|
||||||
category = "outgoing.join&part"
|
}
|
||||||
addCustomCategoryComment(category, "relay join and part messages to the gatway" +
|
.registerTypeAdapter(JoinPartOptions::
|
||||||
"\nFormatting options: " +
|
class.java)
|
||||||
"\nAvailable variables: {username}, {username:antiping}")
|
{
|
||||||
outgoing.joinPart = JoinPartOptions(
|
with(JoinPartOptions()) {
|
||||||
enable = getBoolean(
|
JoinPartOptions(
|
||||||
|
enable = it.getOrDefault(
|
||||||
"enable",
|
"enable",
|
||||||
category,
|
enable,
|
||||||
outgoing.joinPart.enable,
|
|
||||||
"Relay when a player joins / parts the game" +
|
"Relay when a player joins / parts the game" +
|
||||||
"\nany receiving end still needs to be configured with showJoinPart = true" +
|
"\nany receiving end still needs to be configured with showJoinPart = true" +
|
||||||
"\nto display the messages"
|
"\nto display the messages"
|
||||||
),
|
),
|
||||||
joinServer = getString(
|
joinServer = it.getOrDefault(
|
||||||
"joinServer",
|
"joinServer",
|
||||||
category,
|
joinServer,
|
||||||
outgoing.joinPart.joinServer,
|
|
||||||
"user join message sent to other gateways, available variables: {username}, {username:antiping}"
|
"user join message sent to other gateways, available variables: {username}, {username:antiping}"
|
||||||
),
|
),
|
||||||
partServer = getString(
|
partServer = it.getOrDefault(
|
||||||
"partServer",
|
"partServer",
|
||||||
category,
|
partServer,
|
||||||
outgoing.joinPart.partServer,
|
|
||||||
"user part message sent to other gateways, available variables: {username}, {username:antiping}"
|
"user part message sent to other gateways, available variables: {username}, {username:antiping}"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.registerTypeAdapter(UpdateOptions::
|
||||||
category = "update"
|
class.java)
|
||||||
addCustomCategoryComment(category, "Update Settings")
|
{
|
||||||
update = UpdateOptions(
|
with(UpdateOptions()) {
|
||||||
enable = getBoolean(
|
UpdateOptions(
|
||||||
|
enable = it.getOrDefault(
|
||||||
"enable",
|
"enable",
|
||||||
category,
|
enable,
|
||||||
update.enable,
|
|
||||||
"Enable Update checking"
|
"Enable Update checking"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
MessageHandlerInst.config.url = connect.url
|
.build()
|
||||||
MessageHandlerInst.config.token = connect.authToken
|
|
||||||
MessageHandlerInst.config.gateway = connect.gateway
|
|
||||||
MessageHandlerInst.config.reconnectWait = connect.reconnectWait
|
|
||||||
|
|
||||||
MessageHandlerInst.config.systemUser = outgoing.systemUser
|
|
||||||
MessageHandlerInst.config.announceConnect = outgoing.announceConnect
|
|
||||||
MessageHandlerInst.config.announceDisconnect = outgoing.announceDisconnect
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract fun load(): BaseConfig
|
fun load(): MatterLinkConfig {
|
||||||
|
val jsonObject = try {
|
||||||
|
jankson.load(configFile)
|
||||||
|
} catch (e: SyntaxError) {
|
||||||
|
instance.error("error loading config: ${e.completeMessage}")
|
||||||
|
Marshaller.getFallback().serialize(MatterLinkConfig()) as JsonObject
|
||||||
|
} catch (e: FileNotFoundException) {
|
||||||
|
instance.error("creating config file $configFile")
|
||||||
|
configFile.createNewFile()
|
||||||
|
Marshaller.getFallback().serialize(MatterLinkConfig()) as JsonObject
|
||||||
|
}
|
||||||
|
instance.info("finished loading $jsonObject")
|
||||||
|
|
||||||
|
val tmpCfg = try {
|
||||||
|
cfgDirectory.resolve("debug.matterlink.hjson").writeText(jsonObject.toJson(false, true))
|
||||||
|
jankson.fromJson(jsonObject, MatterLinkConfig::class.java).apply {
|
||||||
|
configFile.writeText(jsonObject.toJson(true, true))
|
||||||
|
instance.info("loaded config: $this")
|
||||||
|
}
|
||||||
|
} catch (e: SyntaxError) {
|
||||||
|
instance.error("error parsing config: ${e.completeMessage} ${e.stackTraceString}")
|
||||||
|
MatterLinkConfig()
|
||||||
|
} catch (e: IllegalStateException) {
|
||||||
|
instance.error(e.stackTraceString)
|
||||||
|
MatterLinkConfig()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// val defaultJsonObject = jankson.load("{}")
|
||||||
|
// jankson.fromJson(defaultJsonObject, MatterLinkConfig::class.java)
|
||||||
|
// val nonDefault = jsonObject.getDelta(defaultJsonObject)
|
||||||
|
|
||||||
|
MessageHandlerInst.config.url = cfg.connect.url
|
||||||
|
MessageHandlerInst.config.token = cfg.connect.authToken
|
||||||
|
MessageHandlerInst.config.gateway = cfg.connect.gateway
|
||||||
|
MessageHandlerInst.config.reconnectWait = cfg.connect.reconnectWait
|
||||||
|
|
||||||
|
MessageHandlerInst.config.systemUser = cfg.outgoing.systemUser
|
||||||
|
MessageHandlerInst.config.announceConnect = cfg.outgoing.announceConnect
|
||||||
|
MessageHandlerInst.config.announceDisconnect = cfg.outgoing.announceDisconnect
|
||||||
|
|
||||||
|
return tmpCfg
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,6 @@ package matterlink.config
|
||||||
import blue.endless.jankson.Jankson
|
import blue.endless.jankson.Jankson
|
||||||
import blue.endless.jankson.JsonObject
|
import blue.endless.jankson.JsonObject
|
||||||
import blue.endless.jankson.JsonPrimitive
|
import blue.endless.jankson.JsonPrimitive
|
||||||
import blue.endless.jankson.impl.Marshaller
|
|
||||||
import blue.endless.jankson.impl.SyntaxError
|
import blue.endless.jankson.impl.SyntaxError
|
||||||
import matterlink.bridge.command.CommandType
|
import matterlink.bridge.command.CommandType
|
||||||
import matterlink.bridge.command.CustomCommand
|
import matterlink.bridge.command.CustomCommand
|
||||||
|
@ -15,7 +14,7 @@ typealias CommandMap = MutableMap<String, CustomCommand>
|
||||||
typealias DefaultCommands = Map<String, Pair<String, CustomCommand>>
|
typealias DefaultCommands = Map<String, Pair<String, CustomCommand>>
|
||||||
|
|
||||||
object CommandConfig {
|
object CommandConfig {
|
||||||
private val configFile: File = cfg.cfgDirectory.resolve("commands.json")
|
private val configFile: File = baseCfg.cfgDirectory.resolve("commands.hjson")
|
||||||
|
|
||||||
private val default: DefaultCommands = mapOf(
|
private val default: DefaultCommands = mapOf(
|
||||||
"tps" to ("""Your run off the mill tps commands, change it to /sampler tps or /cofh tps if you like
|
"tps" to ("""Your run off the mill tps commands, change it to /sampler tps or /cofh tps if you like
|
||||||
|
@ -89,20 +88,14 @@ object CommandConfig {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.registerPrimitiveTypeAdapter(CommandType::class.java) {jsonObj ->
|
.registerPrimitiveTypeAdapter(Regex::class.java) {
|
||||||
CommandType.valueOf(jsonObj.toString())
|
it.toString().toRegex()
|
||||||
}
|
|
||||||
.registerPrimitiveTypeAdapter(Regex::class.java) {jsonObj ->
|
|
||||||
jsonObj.toString().toRegex()
|
|
||||||
}
|
}
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
Marshaller.getFallback().registerSerializer(Regex::class.java) {
|
jankson.marshaller.registerSerializer(Regex::class.java) {
|
||||||
JsonPrimitive(it.pattern)
|
JsonPrimitive(it.pattern)
|
||||||
}
|
}
|
||||||
Marshaller.getFallback().registerSerializer(CommandType::class.java) {
|
|
||||||
JsonPrimitive(it.name)
|
|
||||||
}
|
|
||||||
|
|
||||||
val jsonObject = try {
|
val jsonObject = try {
|
||||||
jankson.load(configFile)
|
jankson.load(configFile)
|
||||||
|
@ -117,8 +110,13 @@ object CommandConfig {
|
||||||
commands.clear()
|
commands.clear()
|
||||||
jsonObject.forEach { key, element ->
|
jsonObject.forEach { key, element ->
|
||||||
instance.trace("loading command '$key'")
|
instance.trace("loading command '$key'")
|
||||||
val command = jankson.fromJson(element.toJson(), CustomCommand::class.java)
|
val command = jsonObject.get(CustomCommand::class.java, key)
|
||||||
|
if(command != null)
|
||||||
commands[key] = command
|
commands[key] = command
|
||||||
|
else {
|
||||||
|
instance.error("could not parse key: $key, value: '$element' as CustomCommand")
|
||||||
|
instance.error("skipping $key")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//apply defaults
|
//apply defaults
|
||||||
|
@ -126,7 +124,7 @@ object CommandConfig {
|
||||||
val command = commands[k]
|
val command = commands[k]
|
||||||
if (command == null || command.defaultCommand == true) {
|
if (command == null || command.defaultCommand == true) {
|
||||||
commands[k] = defCommand
|
commands[k] = defCommand
|
||||||
val element = Marshaller.getFallback().serialize(defCommand)
|
val element = jankson.marshaller.serialize(defCommand)
|
||||||
jsonObject.putDefault(k, element, comment)
|
jsonObject.putDefault(k, element, comment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,7 +132,9 @@ object CommandConfig {
|
||||||
instance.debug("loaded jsonObj: $jsonObject")
|
instance.debug("loaded jsonObj: $jsonObject")
|
||||||
instance.debug("loaded commandMap: $commands")
|
instance.debug("loaded commandMap: $commands")
|
||||||
|
|
||||||
configFile.writeText(jsonObject.toJson(true, true))
|
val nonDefaultJsonObj = jsonObject.getDelta(jankson.marshaller.serialize(default.mapValues { it.value.second }) as JsonObject)
|
||||||
|
|
||||||
|
configFile.writeText(nonDefaultJsonObj.toJson(true, true))
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ object PermissionConfig {
|
||||||
.builder()
|
.builder()
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
private val configFile: File = cfg.cfgDirectory.resolve("permissions.json")
|
private val configFile: File = baseCfg.cfgDirectory.resolve("permissions.hjson")
|
||||||
|
|
||||||
private val default = mapOf(
|
private val default = mapOf(
|
||||||
"irc.esper" to mapOf(
|
"irc.esper" to mapOf(
|
||||||
|
@ -42,13 +42,17 @@ object PermissionConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
default.forEach { platform, userMap ->
|
default.forEach { platform, userMap ->
|
||||||
val jsonUserMap = jsonObject.getOrDefault(platform, JsonObject()) as JsonObject
|
val jsonUserMap = jsonObject.getOrDefault(platform, JsonObject())
|
||||||
|
if(jsonUserMap is JsonObject) {
|
||||||
userMap.forEach { user, (powerlevel, comment) ->
|
userMap.forEach { user, (powerlevel, comment) ->
|
||||||
instance.trace("loading platform: $platform user: $user powwerlevel: $powerlevel")
|
instance.trace("loading platform: $platform user: $user powwerlevel: $powerlevel")
|
||||||
val element = Marshaller.getFallback().serialize(powerlevel)
|
val element = Marshaller.getFallback().serialize(powerlevel)
|
||||||
jsonUserMap.putDefault(user, element, comment.takeUnless { it.isBlank() })
|
jsonUserMap.putDefault(user, element, comment.takeUnless { it.isBlank() })
|
||||||
}
|
}
|
||||||
jsonObject[platform] = jsonUserMap
|
jsonObject[platform] = jsonUserMap
|
||||||
|
} else {
|
||||||
|
instance.error("cannot parse platform: $platform , value: '$jsonUserMap' as Map, skipping")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonObject.forEach { platform, jsonUserMap ->
|
jsonObject.forEach { platform, jsonUserMap ->
|
||||||
|
|
|
@ -18,8 +18,8 @@ object DeathHandler {
|
||||||
if (cfg.outgoing.death.enable) {
|
if (cfg.outgoing.death.enable) {
|
||||||
var msg = deathMessage.stripColorOut.replace(player, player.stripColorOut.antiping)
|
var msg = deathMessage.stripColorOut.replace(player, player.stripColorOut.antiping)
|
||||||
if (cfg.outgoing.death.damageType) {
|
if (cfg.outgoing.death.damageType) {
|
||||||
val emojis = cfg.outgoing.death.damageTypeMapping[damageType]?.split(' ')
|
val emojis = cfg.outgoing.death.damageTypeMapping[damageType]
|
||||||
?: listOf("\uD83D\uDC7B unknown type '$damageType'")
|
?: arrayOf("\uD83D\uDC7B unknown type '$damageType'")
|
||||||
val damageEmoji = emojis[random.nextInt(emojis.size)]
|
val damageEmoji = emojis[random.nextInt(emojis.size)]
|
||||||
msg += " $damageEmoji"
|
msg += " $damageEmoji"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue