From 68abc8ade546de62aee76e0b786993fc59fbc3cc Mon Sep 17 00:00:00 2001 From: Walker Selby Date: Sat, 21 Oct 2023 07:31:19 +0100 Subject: Internal Change: Misc Refactoring (#551) Internal Change: Misc Refactoring #551 --- .../hannibal2/skyhanni/features/chat/ChatPeek.kt | 30 ++++++++++++++++++++ .../features/chat/CompactSplashPotionMessage.kt | 32 ++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/chat/ChatPeek.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt (limited to 'src/main/java/at/hannibal2/skyhanni/features/chat') diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatPeek.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatPeek.kt new file mode 100644 index 000000000..5d5580772 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatPeek.kt @@ -0,0 +1,30 @@ +package at.hannibal2.skyhanni.features.chat + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.GuiEditManager +import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld +import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI +import at.hannibal2.skyhanni.features.misc.visualwords.VisualWordGui +import at.hannibal2.skyhanni.utils.NEUItems +import io.github.moulberry.moulconfig.gui.GuiScreenElementWrapper +import net.minecraft.client.Minecraft +import net.minecraft.client.gui.inventory.GuiEditSign +import org.lwjgl.input.Keyboard + + +object ChatPeek { + @JvmStatic + fun peek(): Boolean { + val key = SkyHanniMod.feature.chat.peekChat + + if (Minecraft.getMinecraft().thePlayer == null) return false + if (key <= Keyboard.KEY_NONE) return false + if (Minecraft.getMinecraft().currentScreen is GuiEditSign) return false + if (Minecraft.getMinecraft().currentScreen is GuiScreenElementWrapper) return false + + if (NEUItems.neuHasFocus()) return false + if (GuiEditManager.isInGui() || FFGuideGUI.isInGui() || VisualWordGui.isInGui()) return false + + return key.isKeyHeld() + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt new file mode 100644 index 000000000..dfc0db3f9 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt @@ -0,0 +1,32 @@ +package at.hannibal2.skyhanni.features.chat + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import net.minecraft.util.ChatComponentText +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class CompactSplashPotionMessage { + private val potionEffectPattern = + "§a§lBUFF! §fYou have gained §r(?.*)§r§f! Press TAB or type /effects to view your active effects!".toPattern() + private val potionEffectOthersPattern = + "§a§lBUFF! §fYou were splashed by (?.*) §fwith §r(?.*)§r§f! Press TAB or type /effects to view your active effects!".toPattern() + + @SubscribeEvent + fun onChatMessage(event: LorenzChatEvent) { + if (!LorenzUtils.inSkyBlock || !SkyHanniMod.feature.chat.compactPotionMessage) return + + potionEffectPattern.matchMatcher(event.message) { + val name = group("name") + event.chatComponent = ChatComponentText("§a§lPotion Effect! §r$name") + } + + potionEffectOthersPattern.matchMatcher(event.message) { + val playerName = group("playerName").removeColor() + val effectName = group("effectName") + event.chatComponent = ChatComponentText("§a§lPotion Effect! §r$effectName by §b$playerName") + } + } +} \ No newline at end of file -- cgit