aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorWalker Selby <git@walkerselby.com>2023-12-04 07:09:38 -0800
committerGitHub <noreply@github.com>2023-12-04 16:09:38 +0100
commit5a8d02dcd10015f310bab9d18558d2299c856dd1 (patch)
tree00ed1b7cc677dc8f38b540ea80424166752c5fc8 /src/main/java/at/hannibal2/skyhanni/features
parenta0b37ef8029ff0aecf890447e62e92bf2c28c304 (diff)
downloadskyhanni-5a8d02dcd10015f310bab9d18558d2299c856dd1.tar.gz
skyhanni-5a8d02dcd10015f310bab9d18558d2299c856dd1.tar.bz2
skyhanni-5a8d02dcd10015f310bab9d18558d2299c856dd1.zip
Fix: Fix Poison Candy I Compact Potion & Cleanup (#758)
changed CompactSplashPotionMessage, added compact potion message support for splash messages and for Poisoned Candy I. #758
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt65
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt2
2 files changed, 38 insertions, 29 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 c823d83f0..43ea37c16 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt
@@ -3,49 +3,56 @@ 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.LorenzUtils.groupOrNull
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
-import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class CompactSplashPotionMessage {
private val config get() = SkyHanniMod.feature.chat.compactPotionMessages
- 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 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()
+ private val potionEffectPatternList = listOf(
+ "§a§lBUFF! §fYou were splashed by (?<playerName>.*) §fwith §r(?<effectName>.*)§r§f! Press TAB or type /effects to view your active effects!".toPattern(),
+ "§a§lBUFF! §fYou have gained §r(?<effectName>.*)§r§f! Press TAB or type /effects to view your active effects!".toPattern(),
+ "§a§lBUFF! §fYou splashed yourself with §r(?<effectName>.*)§r§f! Press TAB or type /effects to view your active effects!".toPattern(),
+
+ // Fix for Hypixel having a different message for Poisoned Candy.
+ // Did not make the first pattern optional to prevent conflicts with Dungeon Buffs/other things
+ "§a§lBUFF! §fYou have gained §r(?<effectName>§2Poisoned Candy I)§r§f!§r".toPattern(),
+ "§a§lBUFF! §fYou splashed yourself with §r(?<effectName>§2Poisoned Candy I)§r§f!§r".toPattern(),
+ "§a§lBUFF! §fYou were splashed by (?<playerName>.*) §fwith §r(?<effectName>§2Poisoned Candy I)§r§f!§r".toPattern()
+ )
@SubscribeEvent
fun onChatMessage(event: LorenzChatEvent) {
- if (!LorenzUtils.inSkyBlock || !config.enabled) return
-
- potionEffectPattern.matchMatcher(event.message) {
- val name = group("name")
- sendMessage("§a§lPotion Effect! §r$name")
- event.blockedReason = "compact_potion_effect"
- }
-
- potionSplashEffectOthersPattern.matchMatcher(event.message) {
- val playerName = group("playerName").removeColor()
- val effectName = group("effectName")
- sendMessage("§a§lPotion Effect! §r$effectName by §b$playerName")
- event.blockedReason = "compact_potion_effect"
- }
-
- potionSplashEffectPattern.matchMatcher(event.message) {
- val name = group("name")
- sendMessage("§a§lPotion Effect! §r$name")
- event.blockedReason = "compact_potion_effect"
- }
+ if (!isEnabled()) return
+ if (!event.message.isPotionMessage()) return
+ event.blockedReason = "compact_potion_effect"
}
+
private fun sendMessage(message: String) {
if (config.clickableChatMessage) {
- LorenzUtils.hoverableChat(message, listOf("§eClick to view your potion effects."), "/effects")
+ LorenzUtils.hoverableChat(
+ message,
+ listOf("§eClick to view your potion effects."),
+ "/effects",
+ prefix = false
+ )
} else {
- LorenzUtils.chat(message)
+ LorenzUtils.chat(message, prefix = false)
+ }
+ }
+
+ private fun String.isPotionMessage(): Boolean {
+ return potionEffectPatternList.any {
+ it.matchMatcher(this) {
+ val effectName = group("effectName")
+ // If splashed by a player, append their name.
+ val byPlayer = groupOrNull("playerName")?.let { player -> " by $player" } ?: ""
+ sendMessage("§a§lPotion Effect! §r$effectName$byPlayer")
+ } != null
}
}
+
+ private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt
index 80c3b870d..d08dd888a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt
@@ -63,6 +63,7 @@ class NonGodPotEffectDisplay {
private var patternEffectsCount = "§7You have §e(?<name>\\d+) §7non-god effects\\.".toPattern()
private var totalEffectsCount = 0
+ // todo : cleanup and add support for poison candy I, and add support for splash / other formats
@SubscribeEvent
fun onChatMessage(event: LorenzChatEvent) {
if (event.message == "§aYou cleared all of your active effects!") {
@@ -95,6 +96,7 @@ class NonGodPotEffectDisplay {
effectDuration[NonGodPotEffect.GOBLIN] = Timer(20.minutes)
update()
}
+
if (event.message == "§cThe Goblin King's §r§afoul stench §r§chas dissipated!") {
effectDuration.remove(NonGodPotEffect.GOBLIN)
update()