aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorEmpa <42304516+ItsEmpa@users.noreply.github.com>2024-09-28 22:09:52 +0200
committerGitHub <noreply@github.com>2024-09-28 22:09:52 +0200
commitb86997bbd7223226609728fbe7b069650527aa44 (patch)
tree2b334f11f98918bba262be0876c20f71e0ef2b73 /src/main/java/at
parentc9938504234a1291ee53515bd296e75daeecbd3d (diff)
downloadskyhanni-b86997bbd7223226609728fbe7b069650527aa44.tar.gz
skyhanni-b86997bbd7223226609728fbe7b069650527aa44.tar.bz2
skyhanni-b86997bbd7223226609728fbe7b069650527aa44.zip
Fix: Powder Tracker (#2591)
Co-authored-by: ItsEmpa <itsempa@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt24
1 files changed, 20 insertions, 4 deletions
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 {