diff options
author | ReyMaratov <77993433+ReyMaratov@users.noreply.github.com> | 2024-09-29 09:45:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-29 09:45:23 +0200 |
commit | b2adc637fc55355fb107b286c4fda2d9ef351851 (patch) | |
tree | 78e08c60b1cec7370320f2461d8d65662c09e8a4 /src/main/java/at/hannibal2/skyhanni/features/fishing | |
parent | c63224fc1185ba15be71289e92ff32ce2e6d7513 (diff) | |
download | skyhanni-b2adc637fc55355fb107b286c4fda2d9ef351851.tar.gz skyhanni-b2adc637fc55355fb107b286c4fda2d9ef351851.tar.bz2 skyhanni-b2adc637fc55355fb107b286c4fda2d9ef351851.zip |
Feature: Popup for Gold/Diamond Trophy Fishe Catches (#2615)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/fishing')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt index f97bd56c9..66ddde50b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt @@ -14,10 +14,12 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.ordinal import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.util.ChatComponentText import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds @SkyHanniModule object TrophyFishMessages { @@ -38,8 +40,7 @@ object TrophyFishMessages { } ?: return val internalName = getInternalName(displayName) - val rawRarity = displayRarity.lowercase().removeColor() - val rarity = TrophyRarity.getByName(rawRarity) ?: return + val rarity = TrophyRarity.getByName(displayRarity.lowercase().removeColor()) ?: return val trophyFishes = TrophyFishManager.fish ?: return val trophyFishCounts = trophyFishes.getOrPut(internalName) { mutableMapOf() } @@ -50,6 +51,15 @@ object TrophyFishMessages { event.blockedReason = "low_trophy_fish" return } + if (config.goldAlert && rarity == TrophyRarity.GOLD) { + sendTitle(displayName, displayRarity, amount) + if (config.playSound) SoundUtils.playBeepSound() + } + + if (config.diamondAlert && rarity == TrophyRarity.DIAMOND) { + sendTitle(displayName, displayRarity, amount) + if (config.playSound) SoundUtils.playBeepSound() + } val original = event.chatComponent var edited = original @@ -85,14 +95,23 @@ object TrophyFishMessages { } } + private fun sendTitle(displayName: String, displayRarity: String?, amount: Int) { + val text = "$displayName\n$displayRarity $amount!" + LorenzUtils.sendTitle(text, 3.seconds, 2.8, 7f) + } + fun getInternalName(displayName: String): String { return displayName.replace("Obfuscated", "Obfuscated Fish") .replace("[- ]".toRegex(), "").lowercase().removeColor() } private fun shouldBlockTrophyFish(rarity: TrophyRarity, amount: Int) = - config.bronzeHider && rarity == TrophyRarity.BRONZE && amount != 1 || - config.silverHider && rarity == TrophyRarity.SILVER && amount != 1 + config.bronzeHider && + rarity == TrophyRarity.BRONZE && + amount != 1 || + config.silverHider && + rarity == TrophyRarity.SILVER && + amount != 1 @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { |