diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-05 17:42:49 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-05 17:42:49 +0200 |
commit | 6af9397f43561548086b8ed7fcfb5690136278ea (patch) | |
tree | ca9630ac153dcab99ba22cd13633f41ddf1a6a7c /src/main/java/at/hannibal2/skyhanni | |
parent | 18856a631c55bbd25725c07a90b0bc2108f5e61f (diff) | |
download | skyhanni-6af9397f43561548086b8ed7fcfb5690136278ea.tar.gz skyhanni-6af9397f43561548086b8ed7fcfb5690136278ea.tar.bz2 skyhanni-6af9397f43561548086b8ed7fcfb5690136278ea.zip |
added safety check for ChatManager.retractMessage calls to prevent blocking all chat messages when hypixel changes the format
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/chat/CompactBestiaryChatMessage.kt | 11 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/chat/WatchdogHider.kt | 11 |
2 files changed, 14 insertions, 8 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/CompactBestiaryChatMessage.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/CompactBestiaryChatMessage.kt index 67c76617b..d36f8ba35 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/CompactBestiaryChatMessage.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/CompactBestiaryChatMessage.kt @@ -4,12 +4,8 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.ChatManager import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzUtils.makeAccessible -import net.minecraft.client.Minecraft -import net.minecraft.client.gui.ChatLine import net.minecraft.util.IChatComponent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.relauncher.ReflectionHelper class CompactBestiaryChatMessage { @@ -17,6 +13,7 @@ class CompactBestiaryChatMessage { var bestiaryDescription = mutableListOf<String>() var acceptMoreDescription = true var command = "" + private var blockedLines = 0 var lastBorder: IChatComponent? = null var lastEmpty: IChatComponent? = null @@ -54,9 +51,15 @@ class CompactBestiaryChatMessage { } } inBestiary = true + blockedLines = 0 bestiaryDescription.add(message.trim()) } else if (inBestiary) { event.blockedReason = "bestiary" + blockedLines++ + if (blockedLines > 10) { + blockedLines = 0 + inBestiary = false + } if (message == border) { inBestiary = false diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/WatchdogHider.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/WatchdogHider.kt index 60ad41e61..099d52067 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/WatchdogHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/WatchdogHider.kt @@ -4,16 +4,13 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.ChatManager import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzUtils.makeAccessible -import net.minecraft.client.Minecraft -import net.minecraft.client.gui.ChatLine import net.minecraft.util.IChatComponent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.relauncher.ReflectionHelper class WatchdogHider { private var inWatchdog = false + private var blockedLines = 0 private var startLineComponent: IChatComponent? = null @SubscribeEvent @@ -23,6 +20,7 @@ class WatchdogHider { when (event.message) { watchdogStartLine -> { startLineComponent = event.chatComponent + blockedLines = 0 } watchdogAnnouncementLine -> { ChatManager.retractMessage(startLineComponent, "watchdog") @@ -37,6 +35,11 @@ class WatchdogHider { if (inWatchdog) { event.blockedReason = "watchdog" + blockedLines++ + if (blockedLines > 10) { + blockedLines = 0 + inWatchdog = false + } } } |