From b86997bbd7223226609728fbe7b069650527aa44 Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Sat, 28 Sep 2024 22:09:52 +0200 Subject: Fix: Powder Tracker (#2591) Co-authored-by: ItsEmpa --- .../features/mining/powdertracker/PowderTracker.kt | 24 ++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt index a90b980d9..fcf876c21 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt @@ -1,6 +1,8 @@ package at.hannibal2.skyhanni.features.mining.powdertracker import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.HotmAPI +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.features.mining.PowderTrackerConfig.PowderDisplayEntry import at.hannibal2.skyhanni.data.BossbarData @@ -12,7 +14,9 @@ import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.events.mining.PowderGainEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.CollectionUtils.addSearchString import at.hannibal2.skyhanni.utils.ConditionalUtils.afterChange import at.hannibal2.skyhanni.utils.ConfigUtils @@ -33,6 +37,7 @@ import com.google.gson.annotations.Expose import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration import kotlin.time.Duration.Companion.minutes +import kotlin.time.Duration.Companion.seconds @SkyHanniModule object PowderTracker { @@ -193,13 +198,11 @@ object PowderTracker { } for (reward in PowderChestReward.entries) { + if (reward == PowderChestReward.MITHRIL_POWDER || reward == PowderChestReward.GEMSTONE_POWDER) return reward.chatPattern.matchMatcher(msg) { tracker.modify { val count = it.rewards[reward] ?: 0 - var amount = groupOrNull("amount")?.formatLong() ?: 1 - if ((reward == PowderChestReward.MITHRIL_POWDER || reward == PowderChestReward.GEMSTONE_POWDER) && doublePowder) { - amount *= 2 - } + val amount = groupOrNull("amount")?.formatLong() ?: 1 it.rewards[reward] = count + amount } } @@ -207,6 +210,19 @@ object PowderTracker { tracker.update() } + @HandleEvent(onlyOnIsland = IslandType.CRYSTAL_HOLLOWS) + fun onPowderGain(event: PowderGainEvent) { + if (lastChestPicked.passedSince() > 5.seconds) return + tracker.modify { + val reward = when (event.powder) { + HotmAPI.PowderType.GEMSTONE -> PowderChestReward.GEMSTONE_POWDER + HotmAPI.PowderType.MITHRIL -> PowderChestReward.MITHRIL_POWDER + else -> return@modify + } + it.rewards.addOrPut(reward, event.amount) + } + } + @SubscribeEvent fun onConfigLoad(event: ConfigLoadEvent) { config.textFormat.afterChange { -- cgit