diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt | 24 |
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 |