diff options
6 files changed, 11 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt index d73123c23..802e593e9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt @@ -36,7 +36,7 @@ object EnderNodeTracker { private val enderNodeRegex = Regex("""ENDER NODE!.+You found (\d+x )?§r(.+)§r§f!""") private val endermanRegex = Regex("""(RARE|PET) DROP! §r(.+) §r§b\(""") - private val tracker = SkyHanniTracker("Ender Node Tracker", Data(), { it.enderNodeTracker }) { update() } + private val tracker = SkyHanniTracker("Ender Node Tracker", { Data() }, { it.enderNodeTracker }) { update() } class Data : TrackerData() { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/ArmorDropTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/ArmorDropTracker.kt index 0d5bcbf19..3825040d0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/ArmorDropTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/ArmorDropTracker.kt @@ -33,7 +33,7 @@ object ArmorDropTracker { private val armorPattern = "(FERMENTO|CROPIE|SQUASH|MELON)_(LEGGINGS|CHESTPLATE|BOOTS|HELMET)".toPattern() private val config get() = SkyHanniMod.feature.garden.farmingArmorDrop - private val tracker = SkyHanniTracker("Armor Drop Tracker", Data(), { it.garden.armorDropTracker }) { update() } + private val tracker = SkyHanniTracker("Armor Drop Tracker", { Data() }, { it.garden.armorDropTracker }) { update() } class Data : TrackerData() { override fun reset() { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerDropTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerDropTracker.kt index 659a6cc17..0d95ed0ca 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerDropTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerDropTracker.kt @@ -23,7 +23,7 @@ object DicerDropTracker { private var display = emptyList<List<Any>>() private val itemDrops = mutableListOf<ItemDrop>() private val config get() = SkyHanniMod.feature.garden.dicerCounters - private val tracker = SkyHanniTracker("Dicer Drop Tracker", Data(), { it.garden.dicerDropTracker }) { update() } + private val tracker = SkyHanniTracker("Dicer Drop Tracker", { Data() }, { it.garden.dicerDropTracker }) { update() } class Data : TrackerData() { override fun reset() { 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 d808566a0..fa2506069 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 @@ -59,7 +59,7 @@ object PowderTracker { } } - private val tracker = SkyHanniTracker("Powder Tracker", Data(), { it.powderTracker }) { saveAndUpdate() } + private val tracker = SkyHanniTracker("Powder Tracker", { Data() }, { it.powderTracker }) { saveAndUpdate() } class Data : TrackerData() { override fun reset() { diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt index b5848a2d6..7efaed3d3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt @@ -165,7 +165,7 @@ object SlayerProfitTracker { itemLogCategory ) { Data() } } - SkyHanniTracker("$itemLogCategory Profit Tracker", Data(), getStorage) { update() } + SkyHanniTracker("$itemLogCategory Profit Tracker", { Data() }, getStorage) { update() } } } 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 6d0fcedb6..8d5b723df 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt @@ -13,20 +13,24 @@ import net.minecraft.client.gui.inventory.GuiInventory class SkyHanniTracker<Data : TrackerData>( private val name: String, - private val currentSessionData: Data, + private val createNewSession: () -> Data, private val getStorage: (Storage.ProfileSpecific) -> Data, private val update: () -> Unit, ) { private var inventoryOpen = false private var displayMode = DisplayMode.TOTAL + private val currentSessions = mutableMapOf<Storage.ProfileSpecific, Data>() fun isInventoryOpen() = inventoryOpen private fun getSharedTracker(): SharedTracker<Data>? { val profileSpecific = ProfileStorageData.profileSpecific ?: return null - return SharedTracker(getStorage(profileSpecific), currentSessionData) + return SharedTracker(getStorage(profileSpecific), getCurrentSession(profileSpecific)) } + private fun getCurrentSession(profileSpecific: Storage.ProfileSpecific) = + currentSessions.getOrPut(profileSpecific) { createNewSession() } + fun addSessionResetButton(list: MutableList<List<Any>>) { if (!inventoryOpen || displayMode != DisplayMode.SESSION) return |