diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-04-02 13:11:39 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-04-02 13:11:39 +0200 |
commit | 48972f7ac5f686fd93f17de3692f3e4888453ad7 (patch) | |
tree | 759ffec093e508682fd737a33f65ec98c91d9aea /src/main | |
parent | 265556b1c3aaff15a04a8cc1fb2eeb759f683742 (diff) | |
download | skyhanni-48972f7ac5f686fd93f17de3692f3e4888453ad7.tar.gz skyhanni-48972f7ac5f686fd93f17de3692f3e4888453ad7.tar.bz2 skyhanni-48972f7ac5f686fd93f17de3692f3e4888453ad7.zip |
Fixed soopy chat feature [hand] bypass again
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt index b55840b39..a21b9e133 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt @@ -7,7 +7,9 @@ import at.hannibal2.skyhanni.events.SeaCreatureFishEvent import at.hannibal2.skyhanni.features.fishing.SeaCreatureManager import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraft.event.HoverEvent import net.minecraft.network.play.server.S02PacketChat +import net.minecraft.util.IChatComponent import net.minecraftforge.client.event.ClientChatReceivedEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -43,7 +45,7 @@ class ChatManager { if (message.startsWith("§f{\"server\":\"")) return val chatEvent = LorenzChatEvent(message, original) - if (!event.message.toString().contains("(held item preview from soopy using [hand])")) { + if (!isSoopyMessage(event.message)) { chatEvent.postAndCatch() } @@ -68,6 +70,36 @@ class ChatManager { } } + private fun isSoopyMessage(message: IChatComponent): Boolean { + for (sibling in message.siblings) { + if (isSoopyMessage(sibling)) return true + } + + val style = message.chatStyle ?: return false + val hoverEvent = style.chatHoverEvent ?: return false + if (hoverEvent.action != HoverEvent.Action.SHOW_TEXT) return false + val text = hoverEvent.value?.formattedText ?: return false + + val lines = text.split("\n") + if (lines.isEmpty()) return false + + val last = lines.last() + if (last.startsWith("§f§lCOMMON")) return true + if (last.startsWith("§f§lCOMMON")) return true + if (last.startsWith("§a§lUNCOMMON")) return true + if (last.startsWith("§9§lRARE")) return true + if (last.startsWith("§5§lEPIC")) return true + if (last.startsWith("§6§lLEGENDARY")) return true + if (last.startsWith("§c§lSPECIAL")) return true + + // TODO confirm this format is correct + if (last.startsWith("§c§lVERY SPECIAL")) return true + + if (last.startsWith("§d§lMYTHIC")) return true + + return false + } + @SubscribeEvent fun onChatMessage(chatEvent: LorenzChatEvent) { if (!LorenzUtils.inSkyBlock) return |