diff --git a/.gitignore b/.gitignore index 7b15802..d935fbf 100644 --- a/.gitignore +++ b/.gitignore @@ -96,4 +96,5 @@ gradle-app.setting ### MatterLink ### -run/ \ No newline at end of file +run/ +*.tmp diff --git a/1.10.2/src/main/kotlin/matterlink/EventWrapper.kt b/1.10.2/src/main/kotlin/matterlink/EventWrapper.kt index 4471a74..ccdf8cc 100644 --- a/1.10.2/src/main/kotlin/matterlink/EventWrapper.kt +++ b/1.10.2/src/main/kotlin/matterlink/EventWrapper.kt @@ -69,7 +69,8 @@ object EventWrapper { if (e.entityLiving is EntityPlayer) { DeathHandler.handleDeath( e.entityLiving.name, - e.entityLiving.combatTracker.deathMessage.unformattedText + e.entityLiving.combatTracker.deathMessage.unformattedText, + damageType = e.source.damageType ) } } diff --git a/1.10.2/src/main/kotlin/matterlink/MatterLinkConfig.kt b/1.10.2/src/main/kotlin/matterlink/MatterLinkConfig.kt index 24950b7..92522f7 100644 --- a/1.10.2/src/main/kotlin/matterlink/MatterLinkConfig.kt +++ b/1.10.2/src/main/kotlin/matterlink/MatterLinkConfig.kt @@ -14,6 +14,7 @@ class MatterLinkConfig(file: File) : BaseConfig() { getBoolean = config::getBoolean, getString = config::getString, getStringValidated = config::getString, + getStringList = config::getStringList, addCustomCategoryComment = config::addCustomCategoryComment ) diff --git a/1.11.2/src/main/kotlin/matterlink/EventWrapper.kt b/1.11.2/src/main/kotlin/matterlink/EventWrapper.kt index 4471a74..ccdf8cc 100644 --- a/1.11.2/src/main/kotlin/matterlink/EventWrapper.kt +++ b/1.11.2/src/main/kotlin/matterlink/EventWrapper.kt @@ -69,7 +69,8 @@ object EventWrapper { if (e.entityLiving is EntityPlayer) { DeathHandler.handleDeath( e.entityLiving.name, - e.entityLiving.combatTracker.deathMessage.unformattedText + e.entityLiving.combatTracker.deathMessage.unformattedText, + damageType = e.source.damageType ) } } diff --git a/1.11.2/src/main/kotlin/matterlink/MatterLinkConfig.kt b/1.11.2/src/main/kotlin/matterlink/MatterLinkConfig.kt index 24950b7..92522f7 100644 --- a/1.11.2/src/main/kotlin/matterlink/MatterLinkConfig.kt +++ b/1.11.2/src/main/kotlin/matterlink/MatterLinkConfig.kt @@ -14,6 +14,7 @@ class MatterLinkConfig(file: File) : BaseConfig() { getBoolean = config::getBoolean, getString = config::getString, getStringValidated = config::getString, + getStringList = config::getStringList, addCustomCategoryComment = config::addCustomCategoryComment ) diff --git a/1.12.2/src/main/kotlin/matterlink/EventWrapper.kt b/1.12.2/src/main/kotlin/matterlink/EventWrapper.kt index c987464..5619117 100644 --- a/1.12.2/src/main/kotlin/matterlink/EventWrapper.kt +++ b/1.12.2/src/main/kotlin/matterlink/EventWrapper.kt @@ -70,7 +70,8 @@ object EventWrapper { if (e.entityLiving is EntityPlayer) { DeathHandler.handleDeath( e.entityLiving.name, - e.entityLiving.combatTracker.deathMessage.unformattedText + e.entityLiving.combatTracker.deathMessage.unformattedText, + damageType = e.source.damageType ) } } diff --git a/1.12.2/src/main/kotlin/matterlink/MatterLinkConfig.kt b/1.12.2/src/main/kotlin/matterlink/MatterLinkConfig.kt index 24950b7..d91c708 100644 --- a/1.12.2/src/main/kotlin/matterlink/MatterLinkConfig.kt +++ b/1.12.2/src/main/kotlin/matterlink/MatterLinkConfig.kt @@ -14,11 +14,11 @@ class MatterLinkConfig(file: File) : BaseConfig() { getBoolean = config::getBoolean, getString = config::getString, getStringValidated = config::getString, + getStringList = config::getStringList, addCustomCategoryComment = config::addCustomCategoryComment ) if (config.hasChanged()) config.save() - cfg = this } } \ No newline at end of file diff --git a/build.gradle b/build.gradle index 9564e08..96614f8 100644 --- a/build.gradle +++ b/build.gradle @@ -42,9 +42,16 @@ subprojects { project { id = '287323' releaseType = 'beta' + if(project.hasProperty('changelog')) { + changelogType = "markdown" + changelog = File(changelog) + } relations { requiredLibrary 'shadowfacts-forgelin' } + mainArtifact(jar) { + displayName = "MatterLink $project.version" + } } } diff --git a/core/src/main/kotlin/matterlink/config/BaseConfig.kt b/core/src/main/kotlin/matterlink/config/BaseConfig.kt index 4b8435d..ba040b3 100644 --- a/core/src/main/kotlin/matterlink/config/BaseConfig.kt +++ b/core/src/main/kotlin/matterlink/config/BaseConfig.kt @@ -14,6 +14,7 @@ abstract class BaseConfig { private val CATEGORY_FORMATTING_JOIN_LEAVE = "formatting_join_leave" private val CATEGORY_CONNECTION = "connection" private val CATEGORY_COMMAND = "command" + private val CATEGORY_DEATH = "death" } var relay: RelayOptions = RelayOptions() @@ -21,6 +22,7 @@ abstract class BaseConfig { var formatting: FormattingOptions = FormattingOptions() var formattingJoinLeave: FormattingJoinLeave = FormattingJoinLeave() var command: CommandOptions = CommandOptions() + var death: DeathOptions = DeathOptions() data class RelayOptions( var systemUser: String = "Server", @@ -51,11 +53,50 @@ abstract class BaseConfig { var enable: Boolean = true ) + data class DeathOptions( + var showDamageType: Boolean = true, + var damageTypeMapping: Map = mapOf( + "inFire" to "\uD83D\uDD25", //🔥 + "lightningBolt" to "\uD83C\uDF29", //🌩 + "onFire" to "\uD83D\uDD25", //🔥 + "lava" to "\uD83D\uDD25", //🔥 + "hotFloor" to "♨️", + "inWall" to "", + "cramming" to "", + "drown" to "\uD83C\uDF0A", //🌊 + "starve" to "\uD83D\uDC80", //💀 + "cactus" to "\uD83C\uDF35", //🌵 + "fall" to "\u2BEF️", //⯯️ + "flyIntoWall" to "\uD83D\uDCA8", //💨 + "outOfWorld" to "\u2734", //✴ + "generic" to "\uD83D\uDC7B", //👻 + "magic" to "✨ ⚚", + "indirectMagic" to "✨ ⚚", + "wither" to "\uD83D\uDD71", //🕱 + "anvil" to "", + "fallingBlock" to "", + "dragonBreath" to "\uD83D\uDC32", //🐲 + "fireworks" to "\uD83C\uDF86", //🎆 + + "mob" to "\uD83D\uDC80", //💀 + "player" to "\uD83D\uDDE1", //🗡 + "arrow" to "\uD83C\uDFF9", //🏹 + "thrown" to "彡°", + "thorns" to "\uD83C\uDF39", //🌹 + "explosion" to "\uD83D\uDCA3 \uD83D\uDCA5", //💣 💥 + "explosion.player" to "\uD83D\uDCA3 \uD83D\uDCA5", //💣 💥 + + "electrocut" to "⚡", + "radiation" to "☢" + ) + ) + protected fun load( getBoolean: (key: String, category: String, default: Boolean, comment: String) -> Boolean, getString: (key: String, category: String, default: String, comment: String) -> String, getStringValidated: (key: String, category: String, default: String, comment: String, pattern: Pattern) -> String, - addCustomCategoryComment: (key: String, comment: String) -> Unit + addCustomCategoryComment: (key: String, comment: String) -> Unit, + getStringList: (name: String, category: String, defaultValues: Array, comment: String) -> Array ) { var category = CATEGORY_RELAY_OPTIONS addCustomCategoryComment(CATEGORY_RELAY_OPTIONS, "Relay options") @@ -170,5 +211,29 @@ abstract class BaseConfig { "MatterBridge gateway" ) ) + category = CATEGORY_DEATH + addCustomCategoryComment(category, "Death message settings") + death = DeathOptions( + showDamageType = getBoolean( + "showDamageType", + category, + death.showDamageType, + "Enable Damage type symbols on death messages" + ), + damageTypeMapping = getStringList( + "damageTypeMapping", + category, + death.damageTypeMapping.map { entry -> + "${entry.key}=${entry.value}" } + .toTypedArray(), + "Damage type mapping for everything else, " + + "\nseperate value and key with '=', " + + "\nseperate multiple values with spaces" + ).associate { + val key = it.substringBefore('=') + val value = it.substringAfter('=') + Pair(key, value) + } + ) } } \ No newline at end of file diff --git a/core/src/main/kotlin/matterlink/handlers/DeathHandler.kt b/core/src/main/kotlin/matterlink/handlers/DeathHandler.kt index 958b9c6..d0530ea 100644 --- a/core/src/main/kotlin/matterlink/handlers/DeathHandler.kt +++ b/core/src/main/kotlin/matterlink/handlers/DeathHandler.kt @@ -4,11 +4,23 @@ import matterlink.antiping import matterlink.bridge.ApiMessage import matterlink.bridge.MessageHandler import matterlink.config.cfg +import java.util.* object DeathHandler { - fun handleDeath(player: String, deathMessage: String) { + private val random = Random() + + fun handleDeath( + player: String, + deathMessage: String, + damageType: String + ) { if (cfg!!.relay.deathEvents) { - val msg = deathMessage.replace(player, player.antiping()) + var msg = deathMessage.replace(player, player.antiping()) + if(cfg!!.death.showDamageType) { + val emojis = cfg!!.death.damageTypeMapping[damageType]?.split(' ') ?: listOf("\uD83D\uDC7B unknown type '$damageType'") + val damageEmoji = emojis[random.nextInt(emojis.size)] + msg += " " + damageEmoji + } MessageHandler.transmit(ApiMessage( username = cfg!!.relay.systemUser, text = msg diff --git a/gradle.properties b/gradle.properties index b5752cc..ea62344 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -mod_version = 1.2.3 +mod_version = 1.2.4