diff options
| author | Walker Selby <git@walkerselby.com> | 2023-10-21 07:31:19 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-21 08:31:19 +0200 |
| commit | 68abc8ade546de62aee76e0b786993fc59fbc3cc (patch) | |
| tree | bfc1e6fe389c7daf5cbf2ca109be70233d014590 /src/main/java/at/hannibal2/skyhanni/features/chat | |
| parent | c5745ed4ee07759261da1dc9c0f654617276f163 (diff) | |
| download | skyhanni-68abc8ade546de62aee76e0b786993fc59fbc3cc.tar.gz skyhanni-68abc8ade546de62aee76e0b786993fc59fbc3cc.tar.bz2 skyhanni-68abc8ade546de62aee76e0b786993fc59fbc3cc.zip | |
Internal Change: Misc Refactoring (#551)
Internal Change: Misc Refactoring #551
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/chat')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/chat/ChatPeek.kt | 30 | ||||
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt | 32 |
2 files changed, 62 insertions, 0 deletions
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(?<name>.*)§r§f! Press TAB or type /effects to view your active effects!".toPattern() + private val potionEffectOthersPattern = + "§a§lBUFF! §fYou were splashed by (?<playerName>.*) §fwith §r(?<effectName>.*)§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 |
