aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/dulkirfabric/features
diff options
context:
space:
mode:
authoringlettronald <inglettronald@gmail.com>2023-07-21 18:29:58 -0500
committeringlettronald <inglettronald@gmail.com>2023-07-21 18:29:58 -0500
commitc53d33258ac48cd89883d5f27f380a7d30e561cb (patch)
tree16d78404c95a0c0936c3789bd290f0aeb81c7ee9 /src/main/kotlin/com/dulkirfabric/features
parent6b44a6c4446588950865a6f9def26a5777bd63ba (diff)
downloadDulkirMod-Fabric-c53d33258ac48cd89883d5f27f380a7d30e561cb.tar.gz
DulkirMod-Fabric-c53d33258ac48cd89883d5f27f380a7d30e561cb.tar.bz2
DulkirMod-Fabric-c53d33258ac48cd89883d5f27f380a7d30e561cb.zip
Bridge Bot formatting and client side specification
Diffstat (limited to 'src/main/kotlin/com/dulkirfabric/features')
-rw-r--r--src/main/kotlin/com/dulkirfabric/features/chat/BridgeBotFormatter.kt35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/features/chat/BridgeBotFormatter.kt b/src/main/kotlin/com/dulkirfabric/features/chat/BridgeBotFormatter.kt
new file mode 100644
index 0000000..f956791
--- /dev/null
+++ b/src/main/kotlin/com/dulkirfabric/features/chat/BridgeBotFormatter.kt
@@ -0,0 +1,35 @@
+package com.dulkirfabric.features.chat
+
+import com.dulkirfabric.config.DulkirConfig
+import com.dulkirfabric.events.chat.ChatReceivedEvent
+import com.dulkirfabric.util.TextUtils
+import com.dulkirfabric.util.Utils
+import meteordevelopment.orbit.EventHandler
+import net.minecraft.text.Style
+import net.minecraft.text.Text
+import net.minecraft.util.Formatting
+
+object BridgeBotFormatter {
+ private val bridgeRegex: Regex = "^(§2Guild|§3Officer) > (?:\\S+ )?([\\w§]{3,18})(?: §[a-z0-9][[A-Z]+])?§f: ([^>]+)(?: >| »|:) (.+)".toRegex()
+
+ @EventHandler
+ fun onChat(event: ChatReceivedEvent) {
+ if (!DulkirConfig.configOptions.bridgeFormatter) return
+
+ val message = event.message.string
+ if (bridgeRegex matches message) {
+ val matchResult = bridgeRegex.find(message)
+ val (prefix, name, playerName) = matchResult!!.destructured
+ if (TextUtils.stripColorCodes(name).equals(DulkirConfig.configOptions.bridgeBotName, ignoreCase = true)) {
+ val newPrefix = if (prefix == "§2Guild") "§2Bridge" else "§3Bridge"
+ event.message.siblings[0] = Text.literal(
+ "$newPrefix > "
+ ).append(Text.literal(playerName).setStyle(Style.EMPTY.withColor(DulkirConfig.configOptions.bridgeNameColor)))
+ .append(": ")
+ event.message.siblings[1] = Text.literal(
+ event.message.siblings[1].string.replace("$playerName > ", "")
+ ).setStyle(event.message.siblings[1].style)
+ }
+ }
+ }
+} \ No newline at end of file