From 07df8a9cdc6fa9bbc4156c776e8863b1c1affbf1 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 21 Apr 2024 22:21:00 +0200 Subject: fix replacing too many chat messages. --- src/main/java/at/hannibal2/skyhanni/test/command/TestChatCommand.kt | 3 ++- src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/TestChatCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/TestChatCommand.kt index 6a1fb52f8..0e719c4e1 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/TestChatCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/TestChatCommand.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.test.command import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.OSUtils import kotlinx.coroutines.launch import net.minecraft.util.ChatComponentText @@ -41,7 +42,7 @@ object TestChatCommand { ChatUtils.chat("§cChat blocked: ${event.blockedReason}") } else { val finalMessage = event.chatComponent.formattedText - if (finalMessage != message) { + if (LorenzUtils.stripVanillaMessage(finalMessage) != LorenzUtils.stripVanillaMessage(message)) { ChatUtils.chat("§eChat modified!") } ChatUtils.chat(finalMessage, false) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt index 2682c2973..433078b5f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt @@ -335,7 +335,9 @@ object StringUtils { return null } - if (LorenzUtils.stripVanillaMessage(original.formattedText) == newText) return null + val originalText = LorenzUtils.stripVanillaMessage(original.formattedText) + val newTextt = LorenzUtils.stripVanillaMessage(newText) + if (originalText == newTextt) return null val text = ChatComponentText(newText) if (size == 1) { -- cgit