diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/config')
3 files changed, 72 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt index 69a77d6df..a290b9bf9 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 = 6 + val configVersion = 7 fun JsonElement.at(chain: List<String>, init: Boolean): JsonElement? { if (chain.isEmpty()) return this if (this !is JsonObject) return null @@ -26,7 +26,14 @@ object ConfigUpdaterMigrator { val new: JsonObject, val oldVersion: Int, var movesPerformed: Int, + val dynamicPrefix: Map<String, List<String>>, ) : LorenzEvent() { + init { + dynamicPrefix.entries.filter { it.value.isEmpty() }.forEach { + logger.log("Dynamic prefix ${it.key} does not resolve to anything.") + } + } + fun move(since: Int, oldPath: String, newPath: String, transform: (JsonElement) -> JsonElement = { it }) { if (since <= oldVersion) { logger.log("Skipping move from $oldPath to $newPath ($since <= $oldVersion)") @@ -41,6 +48,22 @@ object ConfigUpdaterMigrator { } val op = oldPath.split(".") val np = newPath.split(".") + if (op.first().startsWith("#")) { + require(np.first() == op.first()) + val realPrefixes = dynamicPrefix[op.first()] + if (realPrefixes == null) { + logger.log("Could not resolve dynamic prefix $oldPath") + return + } + for (realPrefix in realPrefixes) { + move( + since, + "$realPrefix.${oldPath.substringAfter('.')}", + "$realPrefix.${newPath.substringAfter('.')}", transform + ) + return + } + } val oldElem = old.at(op, false) if (oldElem == null) { logger.log("Skipping move from $oldPath to $newPath ($oldPath not present)") @@ -83,9 +106,23 @@ object ConfigUpdaterMigrator { if (lV == configVersion) return config return (lV until configVersion).fold(config) { acc, i -> logger.log("Starting config transformation from $i to ${i + 1}") + val storage = acc.get("storage")?.asJsonObject + val dynamicPrefix: Map<String, List<String>> = mapOf( + "#profile" to + (storage?.get("players")?.asJsonObject?.entrySet() + ?.flatMap { player -> + player.value.asJsonObject.get("profiles")?.asJsonObject?.entrySet()?.map { + "storage.players.${player.key}.profiles.${it.key}" + } ?: listOf() + } + ?: listOf()), + "#player" to + (storage?.get("players")?.asJsonObject?.entrySet()?.map { "storage.players.${it.key}" } + ?: listOf()), + ) val migration = ConfigFixEvent(acc, JsonObject().also { it.add("lastVersion", JsonPrimitive(i + 1)) - }, i, 0).also { it.postAndCatch() } + }, i, 0, dynamicPrefix).also { it.postAndCatch() } logger.log("Transformations scheduled: ${migration.new}") val mergesPerformed = merge(migration.old, migration.new) logger.log("Migration done with $mergesPerformed merges and ${migration.movesPerformed} moves performed") diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java index ad17625fd..5c4ef3c63 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java @@ -17,6 +17,7 @@ import at.hannibal2.skyhanni.features.misc.visualwords.VisualWord; import at.hannibal2.skyhanni.features.rift.area.westvillage.KloonTerminal; import at.hannibal2.skyhanni.utils.LorenzVec; import at.hannibal2.skyhanni.utils.NEUInternalName; +import at.hannibal2.skyhanni.utils.tracker.TrackerData; import com.google.gson.annotations.Expose; import net.minecraft.item.ItemStack; @@ -143,7 +144,18 @@ public class Storage { public CropAccessory savedCropAccessory = null; @Expose - public Map<String, Integer> dicerRngDrops = new HashMap<>(); + public DicerDropTracker dicerDropTracker = new DicerDropTracker(); + + public static class DicerDropTracker extends TrackerData { + + public void reset() { + drops.clear(); + } + + @Expose + public Map<CropType, Map<at.hannibal2.skyhanni.features.garden.farming.DicerDropTracker.DropRarity, Integer>> drops = new HashMap<>(); + + } @Expose public long informedAboutLowMatter = 0; @@ -304,7 +316,13 @@ public class Storage { @Expose public Map<Integer, PowderTracker> powderTracker = new HashMap<>(); - public static class PowderTracker { + public static class PowderTracker extends TrackerData { + + public void reset() { + rewards.clear(); + totalChestPicked = 0; + } + @Expose public int totalChestPicked = 0; @@ -353,7 +371,14 @@ public class Storage { @Expose public Map<String, SlayerProfitList> slayerProfitData = new HashMap<>(); - public static class SlayerProfitList { + public static class SlayerProfitList extends TrackerData { + + public void reset() { + items.clear(); + mobKillCoins = 0; + slayerSpawnCost = 0; + slayerCompletedCount = 0; + } @Expose public Map<NEUInternalName, SlayerItemProfit> items = new HashMap<>(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index cadd9fedc..c612a9742 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -20,11 +20,13 @@ import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest import at.hannibal2.skyhanni.features.garden.composter.ComposterOverlay import at.hannibal2.skyhanni.features.garden.farming.CropMoneyDisplay import at.hannibal2.skyhanni.features.garden.farming.CropSpeedMeter +import at.hannibal2.skyhanni.features.garden.farming.DicerDropTracker import at.hannibal2.skyhanni.features.garden.farming.FarmingWeightDisplay import at.hannibal2.skyhanni.features.garden.farming.GardenStartLocation import at.hannibal2.skyhanni.features.garden.fortuneguide.CaptureFarmingGear import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI import at.hannibal2.skyhanni.features.mining.KingTalismanHelper +import at.hannibal2.skyhanni.features.mining.powdertracker.PowderTracker import at.hannibal2.skyhanni.features.minion.MinionFeatures import at.hannibal2.skyhanni.features.misc.CollectionTracker import at.hannibal2.skyhanni.features.misc.LockMouseLook @@ -158,7 +160,9 @@ object Commands { "shclearfarmingitems", "Clear farming items saved for the Farming Fortune Guide" ) { clearFarmingItems() } - registerCommand("shresetghostcounter", "Resets the ghost counter stats") { GhostUtil.reset() } + registerCommand("shresetghostcounter", "Resets the ghost counter") { GhostUtil.reset() } + registerCommand("shresetpowdertracker", "Resets the powder tracker") { PowderTracker.resetCommand(it) } + registerCommand("shresetdicertracker", "Resets the dicer counter") { DicerDropTracker.resetCommand(it) } registerCommand("shbingotoggle", "Toggle the bingo card display mode") { BingoCardDisplay.toggleCommand() } registerCommand( "shfarmingprofile", |