aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/ChatConfig.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt40
2 files changed, 39 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/ChatConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/ChatConfig.java
index 309ce04a7..e2e67573f 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/ChatConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/ChatConfig.java
@@ -165,6 +165,12 @@ public class ChatConfig {
public boolean compactPotionMessage = true;
@Expose
+ @ConfigOption(name = "Clickable Potion Messages", desc = "Makes the Compact Potion message open the Potion effects menu on click.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean compactPotionClickableMessage = true;
+
+ @Expose
@ConfigOption(name = "Compact Bestiary Message", desc = "Shorten the Bestiary level up message, showing additional information when hovering.")
@ConfigEditorBoolean
@FeatureToggle
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
+}