diff options
2 files changed, 38 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/trophyfishing/ChatMessagesConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/trophyfishing/ChatMessagesConfig.java index 0fab86156..c5a4dc341 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/trophyfishing/ChatMessagesConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/trophyfishing/ChatMessagesConfig.java @@ -82,4 +82,19 @@ public class ChatMessagesConfig { @ConfigOption(name = "Silver Duplicates", desc = "Hide duplicate messages for silver Trophy Fishes from chat.") @ConfigEditorBoolean public boolean silverHider = false; + + @Expose + @ConfigOption(name = "Gold Alert", desc = "Send an alert upon catching a gold Trophy Fish.") + @ConfigEditorBoolean + public boolean goldAlert = false; + + @Expose + @ConfigOption(name = "Diamond Alert", desc = "Send an alert upon catching a diamond Trophy Fish.") + @ConfigEditorBoolean + public boolean diamondAlert = false; + + @Expose + @ConfigOption(name = "Play Sound Alert", desc = "Play a sound effect when rare trophy fishes are caught.") + @ConfigEditorBoolean + public boolean playSound = true; } 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) { |