diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-16 13:10:40 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-16 13:10:40 +0100 |
commit | e44edc3789f6610efa8eab07bc91b3aecc0bf7a6 (patch) | |
tree | 3d87450b63a9caa9578c76dc6452fc93ffa5fd87 /src/main/java/at | |
parent | bdbfcdc609a770f765f37d67c9d1e9757c83b7d4 (diff) | |
download | skyhanni-e44edc3789f6610efa8eab07bc91b3aecc0bf7a6.tar.gz skyhanni-e44edc3789f6610efa8eab07bc91b3aecc0bf7a6.tar.bz2 skyhanni-e44edc3789f6610efa8eab07bc91b3aecc0bf7a6.zip |
Only modifying the total session when opening Vermin Bin.
Diffstat (limited to 'src/main/java/at')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt | 7 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt | 16 |
2 files changed, 19 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt index 02644a370..1f2b38122 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt @@ -53,7 +53,8 @@ object VerminTracker { fun onChat(event: LorenzChatEvent) { VerminType.entries.forEach { verminType -> if (verminType.pattern.matches(event.message)) { - addVermin(verminType) + tracker.modify { it.count.addOrPut(verminType, 1) } + if (config.hideChat) { event.blockedReason = "vermin_vacuumed" } @@ -106,11 +107,11 @@ object VerminTracker { } private fun addVermin(vermin: VerminType, count: Int = 1) { - tracker.modify { it.count.addOrPut(vermin, count) } + tracker.modify(SkyHanniTracker.DisplayMode.TOTAL) { it.count.addOrPut(vermin, count) } } private fun setVermin(vermin: VerminType, count: Int) { - tracker.modify { it.count[vermin] = count } + tracker.modify(SkyHanniTracker.DisplayMode.TOTAL) { it.count[vermin] = count } } private fun drawDisplay(data: Data): List<List<Any>> = buildList { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt index 02ce5129a..ad3418ace 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt @@ -68,6 +68,16 @@ open class SkyHanniTracker<Data : TrackerData>( } } + fun modify(mode: DisplayMode, modifyFunction: (Data) -> Unit) { + val storage = ProfileStorageData.profileSpecific ?: return + val data: Data = when (mode) { + DisplayMode.TOTAL -> storage.getTotal() + DisplayMode.SESSION -> storage.getCurrentSession() + } + modifyFunction(data) + update() + } + fun renderDisplay(position: Position) { if (config.hideInEstimatedItemValue && EstimatedItemValue.isCurrentlyShowing()) return @@ -127,9 +137,13 @@ open class SkyHanniTracker<Data : TrackerData>( ) protected fun getSharedTracker() = ProfileStorageData.profileSpecific?.let { - SharedTracker(getStorage(it), currentSessions.getOrPut(it) { createNewSession() }) + SharedTracker(it.getTotal(), it.getCurrentSession()) } + private fun Storage.ProfileSpecific.getCurrentSession() = currentSessions.getOrPut(this) { createNewSession() } + + private fun Storage.ProfileSpecific.getTotal(): Data = getStorage(this) + private fun reset(displayMode: DisplayMode, message: String) { getSharedTracker()?.let { it.get(displayMode).reset() |