aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/dulkirmod
diff options
context:
space:
mode:
authorIlmarsXd <ilmars500@gmail.com>2023-02-08 16:21:53 +0200
committerIlmarsXd <ilmars500@gmail.com>2023-02-08 16:21:53 +0200
commit3985b5f7417571f4a1e90eefa287af053b740e69 (patch)
tree69abbc662cbb3a325f05aa4fbcd2f0fa0ff37cd6 /src/main/kotlin/dulkirmod
parent926f7f42da7853975eb75b33bdfc4ce5f5c2ea44 (diff)
downloadDulkirMod-3985b5f7417571f4a1e90eefa287af053b740e69.tar.gz
DulkirMod-3985b5f7417571f4a1e90eefa287af053b740e69.tar.bz2
DulkirMod-3985b5f7417571f4a1e90eefa287af053b740e69.zip
use TextUtils for messages, cleanup code
Diffstat (limited to 'src/main/kotlin/dulkirmod')
-rw-r--r--src/main/kotlin/dulkirmod/features/chat/FakeMsg.kt15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/main/kotlin/dulkirmod/features/chat/FakeMsg.kt b/src/main/kotlin/dulkirmod/features/chat/FakeMsg.kt
index f73572e..e1b618f 100644
--- a/src/main/kotlin/dulkirmod/features/chat/FakeMsg.kt
+++ b/src/main/kotlin/dulkirmod/features/chat/FakeMsg.kt
@@ -1,20 +1,15 @@
package dulkirmod.features.chat
-import net.minecraft.client.Minecraft
-import net.minecraft.util.ChatComponentText
+import dulkirmod.utils.TextUtils
import net.minecraftforge.client.event.ClientChatReceivedEvent
object FakeMsg {
+ private val dulkirRegex = "From \\[MVP(\\+|\\+\\+)] Dulkir: c:".toRegex()
fun handle(event: ClientChatReceivedEvent, unformatted: String) {
- if (unformatted.startsWith("From [MVP++] Dulkir: c:")) {
+ if (dulkirRegex.matches(unformatted)) {
event.isCanceled = true
- val newst = unformatted.substring("From [MVP++] Dulkir: c:".length)
- Minecraft.getMinecraft().thePlayer.addChatMessage(ChatComponentText(newst.replace("&", "§")))
- }
- if (unformatted.startsWith("From [MVP+] Dulkir: c:")) {
- event.isCanceled = true
- val newst = unformatted.substring("From [MVP+] Dulkir: c:".length)
- Minecraft.getMinecraft().thePlayer.addChatMessage(ChatComponentText(newst.replace("&", "§")))
+ val message = unformatted.replace(dulkirRegex, "").replace("&", "§")
+ TextUtils.info(message, false)
}
}
} \ No newline at end of file