From e70531a2090979d942b047be004b319869a6f220 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Mon, 25 Dec 2023 01:00:26 +0100 Subject: Fixed config migration errors --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 + .../skyhanni/config/ConfigUpdaterMigrator.kt | 2 +- .../features/rift/motes/InventoryValueConfig.java | 54 ---------------------- .../config/features/rift/motes/MotesConfig.java | 2 +- .../rift/motes/RiftInventoryValueConfig.java | 54 ++++++++++++++++++++++ .../java/at/hannibal2/skyhanni/data/RenderData.kt | 11 +++++ .../at/hannibal2/skyhanni/data/TrackerManager.kt | 10 ++++ .../skyhanni/features/chroma/ChromaShader.kt | 10 ---- .../features/garden/farming/GardenBestCropTime.kt | 2 +- .../skyhanni/features/inventory/ChestValue.kt | 2 +- .../rift/everywhere/motes/ShowMotesNpcSellPrice.kt | 2 +- .../skyhanni/utils/tracker/SkyHanniTracker.kt | 10 ---- 12 files changed, 82 insertions(+), 79 deletions(-) delete mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/rift/motes/InventoryValueConfig.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/rift/motes/RiftInventoryValueConfig.java diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 079565b39..7db58d21f 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -169,6 +169,7 @@ import at.hannibal2.skyhanni.features.garden.farming.CropMoneyDisplay import at.hannibal2.skyhanni.features.garden.farming.CropSpeedMeter import at.hannibal2.skyhanni.features.garden.farming.DicerRngDropTracker import at.hannibal2.skyhanni.features.garden.farming.FarmingWeightDisplay +import at.hannibal2.skyhanni.features.garden.farming.GardenBestCropTime import at.hannibal2.skyhanni.features.garden.farming.GardenBurrowingSporesNotifier import at.hannibal2.skyhanni.features.garden.farming.GardenCropMilestoneDisplay import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed @@ -416,6 +417,7 @@ class SkyHanniMod { loadModule(AdvancedPlayerList) loadModule(ItemAddManager()) loadModule(BingoCardReader()) + loadModule(GardenBestCropTime()) loadModule(TrackerManager) // APIs diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt index 581bf0f3a..f98373ea3 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") - const val CONFIG_VERSION = 16 + const val CONFIG_VERSION = 17 fun JsonElement.at(chain: List, init: Boolean): JsonElement? { if (chain.isEmpty()) return this if (this !is JsonObject) return null diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/rift/motes/InventoryValueConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/rift/motes/InventoryValueConfig.java deleted file mode 100644 index 50ec181e4..000000000 --- a/src/main/java/at/hannibal2/skyhanni/config/features/rift/motes/InventoryValueConfig.java +++ /dev/null @@ -1,54 +0,0 @@ -package at.hannibal2.skyhanni.config.features.rift.motes; - -import at.hannibal2.skyhanni.config.FeatureToggle; -import at.hannibal2.skyhanni.config.HasLegacyId; -import at.hannibal2.skyhanni.config.core.config.Position; -import com.google.gson.annotations.Expose; -import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; -import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; -import io.github.moulberry.moulconfig.annotations.ConfigOption; - -public class InventoryValueConfig { - @Expose - @ConfigOption(name = "Inventory Value", desc = "Show total Motes NPC price for the current opened inventory.") - @ConfigEditorBoolean - @FeatureToggle - public boolean enabled = true; - - @Expose - @ConfigOption(name = "Number Format Type", desc = "Short: 1.2M\n" + - "Long: 1,200,000") - @ConfigEditorDropdown() - public NumberFormatEntry formatType = NumberFormatEntry.SHORT; - - public enum NumberFormatEntry implements HasLegacyId { - SHORT("Short", 0), - LONG("Long", 1); - - private final String str; - private final int legacyId; - - NumberFormatEntry(String str, int legacyId) { - this.str = str; - this.legacyId = legacyId; - } - - // Constructor if new enum elements are added post-migration - NumberFormatEntry(String str) { - this(str, -1); - } - - @Override - public int getLegacyId() { - return legacyId; - } - - @Override - public String toString() { - return str; - } - } - - @Expose - public Position position = new Position(126, 156, false, true); -} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/rift/motes/MotesConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/rift/motes/MotesConfig.java index 2a65a6652..ef6c3a3e7 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/rift/motes/MotesConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/rift/motes/MotesConfig.java @@ -23,5 +23,5 @@ public class MotesConfig { @Expose @ConfigOption(name = "Inventory Value", desc = "") @Accordion - public InventoryValueConfig inventoryValue = new InventoryValueConfig(); + public RiftInventoryValueConfig inventoryValue = new RiftInventoryValueConfig(); } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/rift/motes/RiftInventoryValueConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/rift/motes/RiftInventoryValueConfig.java new file mode 100644 index 000000000..4b4fef21d --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/rift/motes/RiftInventoryValueConfig.java @@ -0,0 +1,54 @@ +package at.hannibal2.skyhanni.config.features.rift.motes; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import at.hannibal2.skyhanni.config.HasLegacyId; +import at.hannibal2.skyhanni.config.core.config.Position; +import com.google.gson.annotations.Expose; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigOption; + +public class RiftInventoryValueConfig { + @Expose + @ConfigOption(name = "Inventory Value", desc = "Show total Motes NPC price for the current opened inventory.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = true; + + @Expose + @ConfigOption(name = "Number Format Type", desc = "Short: 1.2M\n" + + "Long: 1,200,000") + @ConfigEditorDropdown() + public NumberFormatEntry formatType = NumberFormatEntry.SHORT; + + public enum NumberFormatEntry implements HasLegacyId { + SHORT("Short", 0), + LONG("Long", 1); + + private final String str; + private final int legacyId; + + NumberFormatEntry(String str, int legacyId) { + this.str = str; + this.legacyId = legacyId; + } + + // Constructor if new enum elements are added post-migration + NumberFormatEntry(String str) { + this(str, -1); + } + + @Override + public int getLegacyId() { + return legacyId; + } + + @Override + public String toString() { + return str; + } + } + + @Expose + public Position position = new Position(126, 156, false, true); +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/RenderData.kt b/src/main/java/at/hannibal2/skyhanni/data/RenderData.kt index 9a57f87cc..305088949 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/RenderData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/RenderData.kt @@ -1,9 +1,12 @@ package at.hannibal2.skyhanni.data +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.features.chroma.ChromaConfig import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.features.misc.visualwords.VisualWordGui import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests +import at.hannibal2.skyhanni.utils.ConfigUtils import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.client.gui.inventory.GuiInventory @@ -48,4 +51,12 @@ class RenderData { if (!SkyHanniDebugsAndTests.globalRender) return LorenzRenderWorldEvent(event.partialTicks).postAndCatch() } + + // TODO find better spot for this + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.transform(17, "chroma.chromaDirection") { element -> + ConfigUtils.migrateIntToEnum(element, ChromaConfig.Direction::class.java) + } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/TrackerManager.kt b/src/main/java/at/hannibal2/skyhanni/data/TrackerManager.kt index de9caa02e..cea3a5c2f 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/TrackerManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/TrackerManager.kt @@ -1,8 +1,11 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.features.misc.TrackerConfig.PriceFromEntry import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -34,4 +37,11 @@ object TrackerManager { hasChanged = false } } + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.transform(17, "misc.tracker.priceFrom") { element -> + ConfigUtils.migrateIntToEnum(element, PriceFromEntry::class.java) + } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShader.kt b/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShader.kt index e265d6525..902caadf0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShader.kt @@ -1,15 +1,12 @@ package at.hannibal2.skyhanni.features.chroma import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.features.chroma.ChromaConfig.Direction import at.hannibal2.skyhanni.data.MinecraftData import at.hannibal2.skyhanni.mixins.transformers.AccessorMinecraft -import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.shader.Shader import at.hannibal2.skyhanni.utils.shader.Uniform import net.minecraft.client.Minecraft -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent /** * Modified from SkyblockAddons @@ -50,11 +47,4 @@ object ChromaShader : Shader("chroma", "chroma") { } } } - - @SubscribeEvent - fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { - event.transform(15, "config.chromaDirection") { element -> - ConfigUtils.migrateIntToEnum(element, Direction::class.java) - } - } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt index 32dfd7759..4e820c245 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt @@ -140,7 +140,7 @@ class GardenBestCropTime { event.move(3, "garden.cropMilestoneBestCompact", "garden.cropMilestones.next.bestCompact") event.move(3, "garden.cropMilestoneBestHideTitle", "garden.cropMilestones.next.bestHideTitle") - event.transform(15, "garden.cropMilestones.next.bestType") { element -> + event.transform(17, "garden.cropMilestones.next.bestType") { element -> ConfigUtils.migrateIntToEnum(element, BestTypeEntry::class.java) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt index ca3ab6f21..f8b536bf4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt @@ -292,7 +292,7 @@ class ChestValue { @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { - event.transform(15, "inventory.chestValueConfig.numberFormat") { element -> + event.transform(17, "inventory.chestValueConfig.formatType") { element -> ConfigUtils.migrateIntToEnum(element, NumberFormatEntry::class.java) } event.transform(15, "inventory.chestValueConfig.sortingType") { element -> diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt index caca2b283..38077a538 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt @@ -1,7 +1,7 @@ package at.hannibal2.skyhanni.features.rift.everywhere.motes import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator -import at.hannibal2.skyhanni.config.features.rift.motes.InventoryValueConfig.NumberFormatEntry +import at.hannibal2.skyhanni.config.features.rift.motes.RiftInventoryValueConfig.NumberFormatEntry import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent 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 234902c10..4a78641ef 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt @@ -1,7 +1,6 @@ package at.hannibal2.skyhanni.utils.tracker import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.Storage import at.hannibal2.skyhanni.config.core.config.Position import at.hannibal2.skyhanni.config.features.misc.TrackerConfig.PriceFromEntry @@ -9,7 +8,6 @@ import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.data.TrackerManager import at.hannibal2.skyhanni.features.bazaar.BazaarApi.Companion.getBazaarData import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValue -import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.NEUInternalName @@ -20,7 +18,6 @@ import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.renderables.Renderable import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiInventory -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds open class SkyHanniTracker( @@ -191,11 +188,4 @@ open class SkyHanniTracker( override fun toString() = display } - - @SubscribeEvent - fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { - event.transform(15, "misc.tracker.priceFrom") { element -> - ConfigUtils.migrateIntToEnum(element, PriceFromEntry::class.java) - } - } } -- cgit