aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2022-12-27 18:13:37 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2022-12-27 18:13:37 +0100
commit31df4b31ded78db6714e8b859b073ad4dce3c470 (patch)
treeafa2690317dfc9d0b7175ced08fcd3281d0bf1b2 /src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt
parentdb3c0c3b85fd746be0c0e3e0a0cb8d9d21ba0229 (diff)
downloadskyhanni-31df4b31ded78db6714e8b859b073ad4dce3c470.tar.gz
skyhanni-31df4b31ded78db6714e8b859b073ad4dce3c470.tar.bz2
skyhanni-31df4b31ded78db6714e8b859b073ad4dce3c470.zip
moved to version 0.13 and implemented better chat prefix logic
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt
index 39459fe83..de0cafead 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt
@@ -12,9 +12,10 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class ChatManager {
- private val loggerAll = LorenzLogger("chat/filter_all")
- private val loggerFiltered = LorenzLogger("chat/filter_blocked")
- private val loggerAllowed = LorenzLogger("chat/filter_allowed")
+ private val loggerAll = LorenzLogger("chat/all")
+ private val loggerFiltered = LorenzLogger("chat/blocked")
+ private val loggerAllowed = LorenzLogger("chat/allowed")
+ private val loggerModified = LorenzLogger("chat/modified")
private val loggerFilteredTypes = mutableMapOf<String, LorenzLogger>()
@SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
@@ -34,10 +35,12 @@ class ChatManager {
fun onChatReceive(event: ClientChatReceivedEvent) {
if (event.type.toInt() == 2) return
- val messageComponent = event.message
- val message = LorenzUtils.stripVanillaMessage(messageComponent.formattedText)
+ val original = event.message
+ val message = LorenzUtils.stripVanillaMessage(original.formattedText)
+
+ if (message.startsWith("§f{\"server\":\"")) return
- val chatEvent = LorenzChatEvent(message, messageComponent)
+ val chatEvent = LorenzChatEvent(message, original)
chatEvent.postAndCatch()
val blockReason = chatEvent.blockedReason.uppercase()
@@ -50,9 +53,16 @@ class ChatManager {
return
}
- if (!message.startsWith("§f{\"server\":\"")) {
+ val modified = chatEvent.chatComponent
+ if (modified.formattedText == original.formattedText) {
loggerAllowed.log(message)
loggerAll.log("[allowed] $message")
+ } else {
+ event.message = chatEvent.chatComponent
+ loggerModified.log(" ")
+ loggerModified.log("[original] " + original.formattedText)
+ loggerModified.log("[modified] " + modified.formattedText)
+ loggerAll.log("[modified] " + modified.formattedText)
}
}
} \ No newline at end of file