aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-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
+}