aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/chat
diff options
context:
space:
mode:
authorjani270 <69345714+jani270@users.noreply.github.com>2023-11-01 10:43:31 +0100
committerGitHub <noreply@github.com>2023-11-01 10:43:31 +0100
commit9dbc2ba9eb3a14a539523c90efea67cb09b944da (patch)
tree50f56f4db8891738a3094b29123c86f75ac351ee /src/main/java/at/hannibal2/skyhanni/features/chat
parent2efa126057236a912d5b413676f714545e661862 (diff)
downloadskyhanni-9dbc2ba9eb3a14a539523c90efea67cb09b944da.tar.gz
skyhanni-9dbc2ba9eb3a14a539523c90efea67cb09b944da.tar.bz2
skyhanni-9dbc2ba9eb3a14a539523c90efea67cb09b944da.zip
Feature: Makes potion effect messages clickable (#657)
Makes the Compact Potion message open the Potion effects menu on click. #657
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/chat')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt40
1 files changed, 33 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt
index dfc0db3f9..d9732079f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt
@@ -5,28 +5,54 @@ 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 config get() = SkyHanniMod.feature.chat
+
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 =
+ private val potionSplashEffectOthersPattern =
"§a§lBUFF! §fYou were splashed by (?<playerName>.*) §fwith §r(?<effectName>.*)§r§f! Press TAB or type /effects to view your active effects!".toPattern()
+ private val potionSplashEffectPattern =
+ "§a§lBUFF! §fYou splashed yourself with §r(?<name>.*)§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
+ if (!LorenzUtils.inSkyBlock || !config.compactPotionMessage) return
potionEffectPattern.matchMatcher(event.message) {
val name = group("name")
- event.chatComponent = ChatComponentText("§a§lPotion Effect! §r$name")
+ sendMessage("§a§lPotion Effect! §r$name")
+ event.blockedReason = "blocked"
}
- potionEffectOthersPattern.matchMatcher(event.message) {
+ potionSplashEffectOthersPattern.matchMatcher(event.message) {
val playerName = group("playerName").removeColor()
val effectName = group("effectName")
- event.chatComponent = ChatComponentText("§a§lPotion Effect! §r$effectName by §b$playerName")
+ sendMessage(
+ "§a§lPotion Effect! §r$effectName by §b$playerName",
+ )
+ event.blockedReason = "blocked"
+ }
+
+ potionSplashEffectPattern.matchMatcher(event.message) {
+ val name = group("name")
+ sendMessage("§a§lPotion Effect! §r$name")
+ event.blockedReason = "blocked"
+ }
+ }
+
+ private fun sendMessage(message: String) {
+ if (config.compactPotionClickableMessage) {
+ LorenzUtils.hoverableChat(
+ message,
+ listOf("§eClick to view your potion effects."),
+ "/effects"
+ )
+ } else {
+ LorenzUtils.chat(message)
+
}
}
-} \ No newline at end of file
+}