aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/Storage.java18
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt64
3 files changed, 34 insertions, 50 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt
index a290b9bf9..8bb3b7268 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt
@@ -9,7 +9,7 @@ import com.google.gson.JsonPrimitive
object ConfigUpdaterMigrator {
val logger = LorenzLogger("ConfigMigration")
- val configVersion = 7
+ val configVersion = 8
fun JsonElement.at(chain: List<String>, init: Boolean): JsonElement? {
if (chain.isEmpty()) return this
if (this !is JsonObject) return null
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
index 82aa9a4cb..247792fb4 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
@@ -12,7 +12,7 @@ import at.hannibal2.skyhanni.features.garden.farming.DicerDropTracker;
import at.hannibal2.skyhanni.features.garden.farming.FarmingArmorDrops;
import at.hannibal2.skyhanni.features.garden.fortuneguide.FarmingItems;
import at.hannibal2.skyhanni.features.garden.visitor.VisitorReward;
-import at.hannibal2.skyhanni.features.mining.powdertracker.PowderChestReward;
+import at.hannibal2.skyhanni.features.mining.powdertracker.PowderTracker;
import at.hannibal2.skyhanni.features.misc.trevor.TrevorTracker;
import at.hannibal2.skyhanni.features.misc.visualwords.VisualWord;
import at.hannibal2.skyhanni.features.rift.area.westvillage.KloonTerminal;
@@ -304,21 +304,7 @@ public class Storage {
}
@Expose
- public Map<Integer, PowderTracker> powderTracker = new HashMap<>();
-
- public static class PowderTracker extends TrackerData {
-
- public void reset() {
- rewards.clear();
- totalChestPicked = 0;
- }
-
- @Expose
- public int totalChestPicked = 0;
-
- @Expose
- public Map<PowderChestReward, Long> rewards = new HashMap<>();
- }
+ public PowderTracker.Data powderTracker = new PowderTracker.Data();
@Expose
public FrozenTreasureTracker frozenTreasureTracker = new FrozenTreasureTracker();
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 7269797cb..82e9e05b7 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
@@ -2,9 +2,7 @@ package at.hannibal2.skyhanni.features.mining.powdertracker
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
-import at.hannibal2.skyhanni.config.Storage
import at.hannibal2.skyhanni.data.IslandType
-import at.hannibal2.skyhanni.data.ProfileStorageData
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
@@ -18,10 +16,10 @@ import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.tracker.DisplayMode
-import at.hannibal2.skyhanni.utils.tracker.SharedTracker
+import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker
+import at.hannibal2.skyhanni.utils.tracker.TrackerData
import at.hannibal2.skyhanni.utils.tracker.TrackerUtils
-import at.hannibal2.skyhanni.utils.tracker.TrackerUtils.addDisplayModeToggle
-import at.hannibal2.skyhanni.utils.tracker.TrackerUtils.addSessionResetButton
+import com.google.gson.annotations.Expose
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiInventory
import net.minecraft.entity.boss.BossStatus
@@ -47,7 +45,6 @@ object PowderTracker {
private var doublePowder = false
private var powderTimer = ""
private var inventoryOpen = false
- private var currentSessionData = mutableMapOf<Int, Storage.ProfileSpecific.PowderTracker>()
private val gemstones = listOf(
"Ruby" to "§c",
"Sapphire" to "§b",
@@ -68,6 +65,21 @@ object PowderTracker {
}
}
+ private val tracker = SkyHanniTracker("Powder Tracker", Data(), { it.powderTracker }) { saveAndUpdate() }
+
+ class Data : TrackerData() {
+ override fun reset() {
+ rewards.clear()
+ totalChestPicked = 0
+ }
+
+ @Expose
+ var totalChestPicked = 0
+
+ @Expose
+ var rewards: MutableMap<PowderChestReward, Long> = mutableMapOf()
+ }
+
@SubscribeEvent
fun onRenderOverlay(event: GuiRenderEvent) {
if (!isEnabled()) return
@@ -90,11 +102,10 @@ object PowderTracker {
fun onChat(event: LorenzChatEvent) {
if (!isEnabled()) return
val msg = event.message
- val both = getSharedTracker() ?: return
if (config.greatExplorerMaxed) {
uncovered.matchMatcher(msg) {
- both.modify {
+ tracker.modify {
it.totalChestPicked += 1
}
isGrinding = true
@@ -103,7 +114,7 @@ object PowderTracker {
}
picked.matchMatcher(msg) {
- both.modify {
+ tracker.modify {
it.totalChestPicked += 1
}
isGrinding = true
@@ -115,7 +126,7 @@ object PowderTracker {
for (reward in PowderChestReward.entries) {
reward.pattern.matchMatcher(msg) {
- both.modify {
+ tracker.modify {
val count = it.rewards[reward] ?: 0
var amount = group("amount").formatNumber()
if ((reward == PowderChestReward.MITHRIL_POWDER || reward == PowderChestReward.GEMSTONE_POWDER) && doublePowder)
@@ -174,6 +185,10 @@ object PowderTracker {
@SubscribeEvent
fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
event.move(2, "misc.powderTrackerConfig", "mining.powderTracker")
+
+ event.move(8, "#profile.powderTracker", "#profile.powderTracker") { old ->
+ old.asJsonObject.get("0")
+ }
}
private fun saveAndUpdate() {
@@ -192,23 +207,19 @@ object PowderTracker {
}
if (inventoryOpen && TrackerUtils.currentDisplayMode == DisplayMode.CURRENT) {
- addSessionResetButton("Powder Tracker", getSharedTracker()) {
- saveAndUpdate()
- }
+ tracker.addSessionResetButton(this, inventoryOpen)
}
}
private fun drawDisplay() = buildList<List<Any>> {
addAsSingletonList("§b§lPowder Tracker")
if (inventoryOpen) {
- addDisplayModeToggle {
- saveAndUpdate()
- }
+ tracker.addDisplayModeToggle(this, inventoryOpen = true)
} else {
addAsSingletonList("")
}
- val display = currentDisplay() ?: return@buildList
+ val display = tracker.currentDisplay() ?: return@buildList
val chestPerHour = format(chestInfo.perHour)
addAsSingletonList("§d${display.totalChestPicked.addSeparators()} Total Chests Picked §7($chestPerHour/h)")
@@ -303,14 +314,14 @@ object PowderTracker {
}
private fun calculate(info: ResourceInfo, reward: PowderChestReward) {
- val display = currentDisplay() ?: return
+ val display = tracker.currentDisplay() ?: return
val rewards = display.rewards
info.estimated = 0
info.estimated += rewards.getOrDefault(reward, 0)
}
private fun calculateChest() {
- val display = currentDisplay() ?: return
+ val display = tracker.currentDisplay() ?: return
chestInfo.estimated = 0
chestInfo.estimated += display.totalChestPicked
}
@@ -342,23 +353,10 @@ object PowderTracker {
val perMin: MutableList<Long>
)
- private fun currentDisplay() = getSharedTracker()?.getCurrent()
-
- private fun getSharedTracker(): SharedTracker<Storage.ProfileSpecific.PowderTracker>? {
- val profileSpecific = ProfileStorageData.profileSpecific ?: return null
-
- return SharedTracker(
- profileSpecific.powderTracker.getOrPut(0) { Storage.ProfileSpecific.PowderTracker() },
- currentSessionData.getOrPut(0) { Storage.ProfileSpecific.PowderTracker() }
- )
- }
-
private fun isEnabled() =
LorenzUtils.inSkyBlock && LorenzUtils.skyBlockIsland == IslandType.CRYSTAL_HOLLOWS && config.enabled
fun resetCommand(args: Array<String>) {
- TrackerUtils.resetCommand("Powder Tracker", "shresetpowdertracker", args, getSharedTracker()) {
- saveAndUpdate()
- }
+ tracker.resetCommand(args, "shresetpowdertracker")
}
}