From d5b4a817e2b9e7e5c88eb0c8212b9a6e678bd92f Mon Sep 17 00:00:00 2001 From: Walker Selby Date: Mon, 11 Dec 2023 13:59:52 -0800 Subject: Internal: Migrate Deprecated Config Values to Enums (#790) Migrate Deprecated Config Values to Enums. #790 --- .../skyhanni/config/features/chat/ChatSymbols.java | 34 +++++- .../config/features/chroma/ChromaConfig.java | 37 +++++- .../config/features/combat/BestiaryConfig.java | 80 +++++++++++-- .../damageindicator/DamageIndicatorConfig.java | 72 +++++++---- .../crimsonisle/ReputationHelperConfig.java | 33 +++++- .../fishing/trophyfishing/ChatMessagesConfig.java | 33 +++++- .../features/garden/NextJacobContestConfig.java | 35 +++++- .../features/garden/TooltipTweaksConfig.java | 33 +++++- .../features/garden/composter/ComposterConfig.java | 65 +++++++++- .../features/garden/cropmilestones/NextConfig.java | 33 +++++- .../features/garden/pests/PestSpawnConfig.java | 33 +++++- .../features/garden/visitor/VisitorConfig.java | 34 +++++- .../features/inventory/ChestValueConfig.java | 65 +++++++++- .../features/inventory/SackDisplayConfig.java | 132 +++++++++++++++++++-- .../features/itemability/FireVeilWandConfig.java | 34 +++++- .../config/features/misc/HideArmorConfig.java | 34 +++++- .../config/features/misc/TrackerConfig.java | 33 +++++- .../compacttablist/AdvancedPlayerListConfig.java | 37 +++++- .../features/rift/motes/InventoryValueConfig.java | 33 +++++- .../features/slayer/blaze/BlazeHellionConfig.java | 33 +++++- .../java/at/hannibal2/skyhanni/data/SackAPI.kt | 6 +- .../skyhanni/features/chroma/ChromaShader.kt | 20 +++- .../skyhanni/features/combat/BestiaryData.kt | 58 +++++---- .../features/combat/damageindicator/BossType.kt | 4 +- .../damageindicator/DamageIndicatorManager.kt | 14 ++- .../features/fishing/trophy/TrophyFishMessages.kt | 11 +- .../features/garden/GardenNextJacobContest.kt | 14 ++- .../skyhanni/features/garden/ToolTooltipTweaks.kt | 9 +- .../features/garden/composter/ComposterOverlay.kt | 14 ++- .../features/garden/farming/GardenBestCropTime.kt | 8 +- .../skyhanni/features/garden/pests/PestSpawn.kt | 15 ++- .../garden/visitor/GardenVisitorFeatures.kt | 12 +- .../features/garden/visitor/VisitorListener.kt | 5 +- .../skyhanni/features/inventory/ChestValue.kt | 35 ++++-- .../skyhanni/features/inventory/SackDisplay.kt | 63 +++++++--- .../itemabilities/FireVeilWandParticles.kt | 9 +- .../hannibal2/skyhanni/features/misc/HideArmor.kt | 18 ++- .../skyhanni/features/misc/PlayerChatSymbols.kt | 15 ++- .../misc/compacttablist/AdvancedPlayerList.kt | 27 ++++- .../CrimsonIsleReputationHelper.kt | 11 +- .../rift/everywhere/motes/ShowMotesNpcSellPrice.kt | 20 +++- .../slayer/blaze/BlazeSlayerDaggerHelper.kt | 7 +- .../skyhanni/utils/tracker/SkyHanniItemTracker.kt | 5 +- .../skyhanni/utils/tracker/SkyHanniTracker.kt | 15 ++- 44 files changed, 1149 insertions(+), 189 deletions(-) (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/chat/ChatSymbols.java b/src/main/java/at/hannibal2/skyhanni/config/features/chat/ChatSymbols.java index c8ea29aee..0ea1b9688 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/chat/ChatSymbols.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/chat/ChatSymbols.java @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.config.features.chat; import at.hannibal2.skyhanni.config.FeatureToggle; +import at.hannibal2.skyhanni.config.HasLegacyId; import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; @@ -19,6 +20,35 @@ public class ChatSymbols { @Expose @ConfigOption(name = "Chat Symbol Location", desc = "Determines where the symbols should go in chat in relation to the " + "player's name. Hidden will hide all emblems from the chat. §eRequires above setting to be on to hide the symbols.") - @ConfigEditorDropdown(values = {"Left", "Right", "Hidden"}) - public int symbolLocation = 0; + @ConfigEditorDropdown() + public SymbolLocationEntry symbolLocation = SymbolLocationEntry.LEFT; + + public enum SymbolLocationEntry implements HasLegacyId { + LEFT("Left", 0), + RIGHT("Right", 1), + HIDDEN("Hidden)", 2); + + private final String str; + private final int legacyId; + + SymbolLocationEntry(String str, int legacyId) { + this.str = str; + this.legacyId = legacyId; + } + + // Constructor if new enum elements are added post-migration + SymbolLocationEntry(String str) { + this(str, -1); + } + + @Override + public int getLegacyId() { + return legacyId; + } + + @Override + public String toString() { + return str; + } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/chroma/ChromaConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/chroma/ChromaConfig.java index 81e3b26df..7446063ba 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/chroma/ChromaConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/chroma/ChromaConfig.java @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.config.features.chroma; import at.hannibal2.skyhanni.SkyHanniMod; import at.hannibal2.skyhanni.config.FeatureToggle; +import at.hannibal2.skyhanni.config.HasLegacyId; import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; import io.github.moulberry.moulconfig.annotations.ConfigEditorButton; @@ -40,8 +41,38 @@ public class ChromaConfig { @Expose @ConfigOption(name = "Chroma Direction", desc = "Change the slant and direction of the chroma.") - @ConfigEditorDropdown(values = {"Forward + Right", "Forward + Left", "Backward + Right", "Backward + Left"}) - public int chromaDirection = 0; + @ConfigEditorDropdown() + public Direction chromaDirection = Direction.FORWARD_RIGHT; + + public enum Direction implements HasLegacyId { + FORWARD_RIGHT("Forward + Right", 0), + FORWARD_LEFT("Forward + Left", 1), + BACKWARD_RIGHT("Backward + Right", 2), + BACKWARD_LEFT("Backward + Left", 3); + + private final String str; + private final int legacyId; + + Direction(String str, int legacyId) { + this.str = str; + this.legacyId = legacyId; + } + + // Constructor if new enum elements are added post-migration + Direction(String str) { + this(str, -1); + } + + @Override + public int getLegacyId() { + return legacyId; + } + + @Override + public String toString() { + return str; + } + } @ConfigOption(name = "Reset to Default", desc = "Resets all chroma settings to the default.") @ConfigEditorButton(buttonText = "Reset") @@ -57,6 +88,6 @@ public class ChromaConfig { SkyHanniMod.getFeature().chroma.chromaSpeed = 6f; SkyHanniMod.getFeature().chroma.chromaSaturation = 0.75f; SkyHanniMod.getFeature().chroma.allChroma = false; - SkyHanniMod.getFeature().chroma.chromaDirection = 0; + SkyHanniMod.getFeature().chroma.chromaDirection = Direction.FORWARD_RIGHT; } } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/combat/BestiaryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/combat/BestiaryConfig.java index 97c41da3d..1e9c7f4a6 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/combat/BestiaryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/combat/BestiaryConfig.java @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.config.features.combat; 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; @@ -16,22 +17,75 @@ public class BestiaryConfig { @Expose @ConfigOption(name = "Number format", desc = "Short: 1.1k\nLong: 1.100") - @ConfigEditorDropdown(values = {"Short", "Long"}) - public int numberFormat = 0; + @ConfigEditorDropdown() + public NumberFormatEntry numberFormat = 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 @ConfigOption(name = "Display type", desc = "Choose what the display should show") - @ConfigEditorDropdown(values = { - "Global to max", - "Global to next tier", - "Lowest total kills", - "Highest total kills", - "Lowest kills needed to max", - "Highest kills needed to max", - "Lowest kills needed to next tier", - "Highest kills needed to next tier" - }) - public int displayType = 0; + @ConfigEditorDropdown() + public DisplayTypeEntry displayType = DisplayTypeEntry.GLOBAL_MAX; + + public enum DisplayTypeEntry implements HasLegacyId { + GLOBAL_MAX("Global to max", 0), + GLOBAL_NEXT("Global to next tier", 1), + LOWEST_TOTAL("Lowest total kills", 2), + HIGHEST_TOTAL("Highest total kills", 3), + LOWEST_MAX("Lowest kills needed to max", 4), + HIGHEST_MAX("Highest kills needed to max", 5), + LOWEST_NEXT("Lowest kills needed to next tier", 6), + HIGHEST_NEXT("Highest kills needed to next tier", 7); + + private final String str; + private final int legacyId; + + DisplayTypeEntry(String str, int legacyId) { + this.str = str; + this.legacyId = legacyId; + } + + // Constructor if new enum elements are added post-migration + DisplayTypeEntry(String str) { + this(str, -1); + } + + @Override + public int getLegacyId() { + return legacyId; + } + + @Override + public String toString() { + return str; + } + } @Expose @ConfigOption(name = "Hide maxed", desc = "Hide maxed mobs.") diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/combat/damageindicator/DamageIndicatorConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/combat/damageindicator/DamageIndicatorConfig.java index 6986d706c..69cae8a78 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/combat/damageindicator/DamageIndicatorConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/combat/damageindicator/DamageIndicatorConfig.java @@ -13,21 +13,21 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.DamageIndicatorBossEntry.ARACHNE; -import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.DamageIndicatorBossEntry.DIANA_MOBS; -import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.DamageIndicatorBossEntry.DUNGEON_ALL; -import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.DamageIndicatorBossEntry.GARDEN_PESTS; -import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.DamageIndicatorBossEntry.INFERNO_DEMONLORD; -import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.DamageIndicatorBossEntry.NETHER_MINI_BOSSES; -import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.DamageIndicatorBossEntry.REINDRAKE; -import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.DamageIndicatorBossEntry.REVENANT_HORROR; -import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.DamageIndicatorBossEntry.RIFTSTALKER_BLOODFIEND; -import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.DamageIndicatorBossEntry.SEA_CREATURES; -import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.DamageIndicatorBossEntry.SVEN_PACKMASTER; -import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.DamageIndicatorBossEntry.TARANTULA_BROODFATHER; -import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.DamageIndicatorBossEntry.THE_RIFT_BOSSES; -import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.DamageIndicatorBossEntry.VANQUISHER; -import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.DamageIndicatorBossEntry.VOIDGLOOM_SERAPH; +import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.BossCategory.ARACHNE; +import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.BossCategory.DIANA_MOBS; +import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.BossCategory.DUNGEON_ALL; +import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.BossCategory.GARDEN_PESTS; +import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.BossCategory.INFERNO_DEMONLORD; +import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.BossCategory.NETHER_MINI_BOSSES; +import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.BossCategory.REINDRAKE; +import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.BossCategory.REVENANT_HORROR; +import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.BossCategory.RIFTSTALKER_BLOODFIEND; +import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.BossCategory.SEA_CREATURES; +import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.BossCategory.SVEN_PACKMASTER; +import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.BossCategory.TARANTULA_BROODFATHER; +import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.BossCategory.THE_RIFT_BOSSES; +import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.BossCategory.VANQUISHER; +import static at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.BossCategory.VOIDGLOOM_SERAPH; public class DamageIndicatorConfig { @@ -46,8 +46,38 @@ public class DamageIndicatorConfig { @ConfigOption( name = "Boss Name", desc = "Change how the boss name should be displayed.") - @ConfigEditorDropdown(values = {"Hidden", "Full Name", "Short Name"}) - public int bossName = 1; + @ConfigEditorDropdown() + public NameVisibility bossName = NameVisibility.FULL_NAME; + + public enum NameVisibility implements HasLegacyId { + HIDDEN("Hidden", 0), + FULL_NAME("Full Name", 1), + SHORT_NAME("Short Name", 2), + ; + + private final String str; + private final int legacyId; + + NameVisibility(String str, int legacyId) { + this.str = str; + this.legacyId = legacyId; + } + + // Constructor if new enum elements are added post-migration + NameVisibility(String str) { + this(str, -1); + } + + @Override + public int getLegacyId() { + return legacyId; + } + + @Override + public String toString() { + return str; + } + } @Expose @ConfigOption( @@ -56,7 +86,7 @@ public class DamageIndicatorConfig { ) @ConfigEditorDraggableList() //TODO only show currently working and tested features - public List bossesToShow = new ArrayList<>(Arrays.asList( + public List bossesToShow = new ArrayList<>(Arrays.asList( DUNGEON_ALL, NETHER_MINI_BOSSES, VANQUISHER, @@ -75,7 +105,7 @@ public class DamageIndicatorConfig { )); - public enum DamageIndicatorBossEntry implements HasLegacyId { + public enum BossCategory implements HasLegacyId { DUNGEON_ALL("§bDungeon All", 0), NETHER_MINI_BOSSES("§bNether Mini Bosses", 1), VANQUISHER("§bVanquisher", 2), @@ -107,13 +137,13 @@ public class DamageIndicatorConfig { private final String str; private final int legacyId; - DamageIndicatorBossEntry(String str, int legacyId) { + BossCategory(String str, int legacyId) { this.str = str; this.legacyId = legacyId; } // Constructor if new enum elements are added post-migration - DamageIndicatorBossEntry(String str) { + BossCategory(String str) { this(str, -1); } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/crimsonisle/ReputationHelperConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/crimsonisle/ReputationHelperConfig.java index cddce2228..0fb516858 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/crimsonisle/ReputationHelperConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/crimsonisle/ReputationHelperConfig.java @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.config.features.crimsonisle; 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; @@ -33,6 +34,34 @@ public class ReputationHelperConfig { @Expose @ConfigOption(name = "Show Locations", desc = "Crimson Isles waypoints for locations to get reputation.") - @ConfigEditorDropdown(values = {"Always", "Only With Hotkey", "Never"}) - public int showLocation = 1; + @ConfigEditorDropdown() + public ShowLocationEntry showLocation = ShowLocationEntry.ONLY_HOTKEY; + + public enum ShowLocationEntry implements HasLegacyId { + ALWAYS("Always", 0), + ONLY_HOTKEY("Only With Hotkey", 1), + NEVER("Never", 2); + private final String str; + private final int legacyId; + + ShowLocationEntry(String str, int legacyId) { + this.str = str; + this.legacyId = legacyId; + } + + // Constructor if new enum elements are added post-migration + ShowLocationEntry(String str) { + this(str, -1); + } + + @Override + public int getLegacyId() { + return legacyId; + } + + @Override + public String toString() { + return str; + } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/trophyfishing/ChatMessagesConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/trophyfishing/ChatMessagesConfig.java index f19fc0d86..3cba03d78 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/trophyfishing/ChatMessagesConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/trophyfishing/ChatMessagesConfig.java @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.config.features.fishing.trophyfishing; import at.hannibal2.skyhanni.config.FeatureToggle; +import at.hannibal2.skyhanni.config.HasLegacyId; import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; @@ -24,8 +25,36 @@ public class ChatMessagesConfig { "§fStyle 2: §bYou caught a §5Moldfin §6§lGOLD§b. §7(2)\n" + "§fStyle 3: §bYou caught your 2nd §6§lGOLD §5Moldfin§b." ) - @ConfigEditorDropdown(values = {"Style 1", "Style 2", "Style 3"}) - public int design = 0; + @ConfigEditorDropdown() + public DesignFormat design = DesignFormat.STYLE_1; + + public enum DesignFormat implements HasLegacyId { + STYLE_1("Style 1", 0), + STYLE_2("Style 2", 1), + STYLE_3("Style 3", 2); + private final String str; + private final int legacyId; + + DesignFormat(String str, int legacyId) { + this.str = str; + this.legacyId = legacyId; + } + + // Constructor if new enum elements are added post-migration + DesignFormat(String str) { + this(str, -1); + } + + @Override + public int getLegacyId() { + return legacyId; + } + + @Override + public String toString() { + return str; + } + } @Expose @ConfigOption(name = "Show Total Amount", desc = "Show total amount of all rarities at the end of the chat message.") diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/NextJacobContestConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/NextJacobContestConfig.java index 2da4b7c42..d3162185a 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/NextJacobContestConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/NextJacobContestConfig.java @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.config.features.garden; import at.hannibal2.skyhanni.config.FeatureToggle; +import at.hannibal2.skyhanni.config.HasLegacyId; import at.hannibal2.skyhanni.config.core.config.Position; import at.hannibal2.skyhanni.features.garden.CropType; import com.google.gson.annotations.Expose; @@ -37,8 +38,38 @@ public class NextJacobContestConfig { @Expose @ConfigOption(name = "Share Contests", desc = "Share the list of upcoming Contests to elitebot.dev for everyone else to then fetch automatically.") - @ConfigEditorDropdown(values = {"Ask When Needed", "Share Automatically", "Disabled"}) - public int shareAutomatically = 0; + @ConfigEditorDropdown() + public ShareContestsEntry shareAutomatically = ShareContestsEntry.ASK; + + public enum ShareContestsEntry implements HasLegacyId { + ASK("Ask When Needed", 0), + AUTO("Share Automatically", 1), + DISABLED("Disabled", 2), + ; + + private final String str; + private final int legacyId; + + ShareContestsEntry(String str, int legacyId) { + this.str = str; + this.legacyId = legacyId; + } + + // Constructor if new enum elements are added post-migration + ShareContestsEntry(String str) { + this(str, -1); + } + + @Override + public int getLegacyId() { + return legacyId; + } + + @Override + public String toString() { + return str; + } + } @Expose @ConfigOption(name = "Warning", desc = "Show a warning shortly before a new Jacob's Contest starts.") diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/TooltipTweaksConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/TooltipTweaksConfig.java index 560fcaaa7..511e15759 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/TooltipTweaksConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/TooltipTweaksConfig.java @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.config.features.garden; import at.hannibal2.skyhanni.config.FeatureToggle; +import at.hannibal2.skyhanni.config.HasLegacyId; import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; @@ -33,8 +34,36 @@ public class TooltipTweaksConfig { "§fShow: §7Crop-specific Fortune indicated as §6[+196]\n" + "§fReplace: §7Edits the total Fortune to include crop-specific Fortune." ) - @ConfigEditorDropdown(values = {"Default", "Show", "Replace"}) - public int cropTooltipFortune = 1; + @ConfigEditorDropdown() + public CropTooltipFortuneEntry cropTooltipFortune = CropTooltipFortuneEntry.SHOW; + + public enum CropTooltipFortuneEntry implements HasLegacyId { + DEFAULT("Default", 0), + SHOW("Show", 1), + REPLACE("Replace", 2); + private final String str; + private final int legacyId; + + CropTooltipFortuneEntry(String str, int legacyId) { + this.str = str; + this.legacyId = legacyId; + } + + // Constructor if new enum elements are added post-migration + CropTooltipFortuneEntry(String str) { + this(str, -1); + } + + @Override + public int getLegacyId() { + return legacyId; + } + + @Override + public String toString() { + return str; + } + } @Expose @ConfigOption( diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/composter/ComposterConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/composter/ComposterConfig.java index 700c4fc49..42137eed5 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/composter/ComposterConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/composter/ComposterConfig.java @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.config.features.garden.composter; 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.Accordion; @@ -20,13 +21,69 @@ public class ComposterConfig { @Expose @ConfigOption(name = "Overlay Price", desc = "Toggle for Bazaar 'buy order' vs 'instant buy' price in composter overlay.") - @ConfigEditorDropdown(values = {"Instant Buy", "Buy Order"}) - public int overlayPriceType = 0; + @ConfigEditorDropdown() + public OverlayPriceTypeEntry overlayPriceType = OverlayPriceTypeEntry.INSTANT_BUY; + + public enum OverlayPriceTypeEntry implements HasLegacyId { + INSTANT_BUY("Instant Buy", 0), + BUY_ORDER("Buy Order", 1), + ; + private final String str; + private final int legacyId; + + OverlayPriceTypeEntry(String str, int legacyId) { + this.str = str; + this.legacyId = legacyId; + } + + // Constructor if new enum elements are added post-migration + OverlayPriceTypeEntry(String str) { + this(str, -1); + } + + @Override + public int getLegacyId() { + return legacyId; + } + + @Override + public String toString() { + return str; + } + } @Expose @ConfigOption(name = "Retrieve From", desc = "Change where to retrieve the materials from in the composter overlay: The Bazaar or Sacks.") - @ConfigEditorDropdown(values = {"Bazaar", "Sacks"}) - public int retrieveFrom = 0; + @ConfigEditorDropdown() + public RetrieveFromEntry retrieveFrom = RetrieveFromEntry.BAZAAR; + + public enum RetrieveFromEntry implements HasLegacyId { + BAZAAR("Bazaar", 0), + SACKS("Sacks", 1), + ; + private final String str; + private final int legacyId; + + RetrieveFromEntry(String str, int legacyId) { + this.str = str; + this.legacyId = legacyId; + } + + // Constructor if new enum elements are added post-migration + RetrieveFromEntry(String str) { + this(str, -1); + } + + @Override + public int getLegacyId() { + return legacyId; + } + + @Override + public String toString() { + return str; + } + } @Expose public Position overlayOrganicMatterPos = new Position(140, 152, false, true); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/cropmilestones/NextConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/cropmilestones/NextConfig.java index 188848e48..d11117624 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/cropmilestones/NextConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/cropmilestones/NextConfig.java @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.config.features.garden.cropmilestones; 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; @@ -21,8 +22,36 @@ public class NextConfig { // TODO moulconfig runnable support @Expose @ConfigOption(name = "Sort Type", desc = "Sort the crops by either garden or SkyBlock EXP.") - @ConfigEditorDropdown(values = {"Garden Exp", "SkyBlock Exp"}) - public int bestType = 0; + @ConfigEditorDropdown() + public BestTypeEntry bestType = BestTypeEntry.GARDEN_EXP; + + public enum BestTypeEntry implements HasLegacyId { + GARDEN_EXP("Garden Exp", 0), + SKYBLOCK_EXP("SkyBlock Exp", 1), + ; + private final String str; + private final int legacyId; + + BestTypeEntry(String str, int legacyId) { + this.str = str; + this.legacyId = legacyId; + } + + // Constructor if new enum elements are added post-migration + BestTypeEntry(String str) { + this(str, -1); + } + + @Override + public int getLegacyId() { + return legacyId; + } + + @Override + public String toString() { + return str; + } + } // TODO moulconfig runnable support @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/PestSpawnConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/PestSpawnConfig.java index ba723acfa..a12f885c3 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/PestSpawnConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/PestSpawnConfig.java @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.config.features.garden.pests; import at.hannibal2.skyhanni.config.FeatureToggle; +import at.hannibal2.skyhanni.config.HasLegacyId; import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; @@ -12,8 +13,36 @@ public class PestSpawnConfig { @ConfigOption( name = "Chat Message Format", desc = "Change how the pest spawn chat message should be formatted.") - @ConfigEditorDropdown(values = {"Hypixel Style", "Compact", "Disabled"}) - public int chatMessageFormat = 0; + @ConfigEditorDropdown() + public ChatMessageFormatEntry chatMessageFormat = ChatMessageFormatEntry.HYPIXEL; + + public enum ChatMessageFormatEntry implements HasLegacyId { + HYPIXEL("Hypixel Style", 0), + COMPACT("Compact", 1), + DISABLED("Disabled", 2); + private final String str; + private final int legacyId; + + ChatMessageFormatEntry(String str, int legacyId) { + this.str = str; + this.legacyId = legacyId; + } + + // Constructor if new enum elements are added post-migration + ChatMessageFormatEntry(String str) { + this(str, -1); + } + + @Override + public int getLegacyId() { + return legacyId; + } + + @Override + public String toString() { + return str; + } + } @Expose @ConfigOption( diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/visitor/VisitorConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/visitor/VisitorConfig.java index ff8e09432..7aca44b89 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/visitor/VisitorConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/visitor/VisitorConfig.java @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.config.features.garden.visitor; import at.hannibal2.skyhanni.config.FeatureToggle; +import at.hannibal2.skyhanni.config.HasLegacyId; import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.Accordion; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; @@ -44,8 +45,37 @@ public class VisitorConfig { @Expose @ConfigOption(name = "Highlight Status", desc = "Highlight the status for visitors with a text above or with color.") - @ConfigEditorDropdown(values = {"Color Only", "Name Only", "Both", "Disabled"}) - public int highlightStatus = 2; + @ConfigEditorDropdown() + public HighlightMode highlightStatus = HighlightMode.BOTH; + + public enum HighlightMode implements HasLegacyId { + COLOR("Color Only", 0), + NAME("Name Only", 1), + BOTH("Both", 2), + DISABLED("Disabled", 3); + private final String str; + private final int legacyId; + + HighlightMode(String str, int legacyId) { + this.str = str; + this.legacyId = legacyId; + } + + // Constructor if new enum elements are added post-migration + HighlightMode(String str) { + this(str, -1); + } + + @Override + public int getLegacyId() { + return legacyId; + } + + @Override + public String toString() { + return str; + } + } @Expose @ConfigOption(name = "Colored Name", desc = "Show the visitor name in the color of the rarity.") diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/ChestValueConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/ChestValueConfig.java index 62eb30385..c9f3e1bd2 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/ChestValueConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/ChestValueConfig.java @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.config.features.inventory; 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; @@ -54,13 +55,69 @@ public class ChestValueConfig { @Expose @ConfigOption(name = "Sorting Type", desc = "Price sorting type.") - @ConfigEditorDropdown(values = {"Descending", "Ascending"}) - public int sortingType = 0; + @ConfigEditorDropdown() + public SortingTypeEntry sortingType = SortingTypeEntry.DESCENDING; + + public enum SortingTypeEntry implements HasLegacyId { + DESCENDING("Descending", 0), + ASCENDING("Ascending", 1), + ; + private final String str; + private final int legacyId; + + SortingTypeEntry(String str, int legacyId) { + this.str = str; + this.legacyId = legacyId; + } + + // Constructor if new enum elements are added post-migration + SortingTypeEntry(String str) { + this(str, -1); + } + + @Override + public int getLegacyId() { + return legacyId; + } + + @Override + public String toString() { + return str; + } + } @Expose @ConfigOption(name = "Value formatting Type", desc = "Format of the price.") - @ConfigEditorDropdown(values = {"Short", "Long"}) - public int formatType = 0; + @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 @ConfigOption(name = "Item To Show", desc = "Choose how many items are displayed.\n" + diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/SackDisplayConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/SackDisplayConfig.java index 37eab2be3..91579ac4f 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/SackDisplayConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/SackDisplayConfig.java @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.config.features.inventory; 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; @@ -31,8 +32,37 @@ public class SackDisplayConfig { "§eDefault: §72,240/2.2k\n" + "§eFormatted: §72.2k/2.2k\n" + "§eUnformatted: §72,240/2,200") - @ConfigEditorDropdown(values = {"Default", "Formatted", "Unformatted"}) - public int numberFormat = 1; + @ConfigEditorDropdown() + public NumberFormatEntry numberFormat = NumberFormatEntry.FORMATTED; + + public enum NumberFormatEntry implements HasLegacyId { + DEFAULT("Default", 0), + FORMATTED("Formatted", 1), + UNFORMATTED("Unformatted", 2); + + 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 @ConfigOption(name = "Extra space", desc = "Space between each line of text.") @@ -44,8 +74,38 @@ public class SackDisplayConfig { @Expose @ConfigOption(name = "Sorting Type", desc = "Sorting type of items in sack.") - @ConfigEditorDropdown(values = {"Descending (Stored)", "Ascending (Stored)", "Descending (Price)", "Ascending (Price)"}) - public int sortingType = 0; + @ConfigEditorDropdown() + public SortingTypeEntry sortingType = SortingTypeEntry.DESC_STORED; + + public enum SortingTypeEntry implements HasLegacyId { + DESC_STORED("Descending (Stored)", 0), + ASC_STORED("Ascending (Stored)", 1), + DESC_PRICE("Descending (Price)", 2), + ASC_PRICE("Ascending (Price)", 3); + + private final String str; + private final int legacyId; + + SortingTypeEntry(String str, int legacyId) { + this.str = str; + this.legacyId = legacyId; + } + + // Constructor if new enum elements are added post-migration + SortingTypeEntry(String str) { + this(str, -1); + } + + @Override + public int getLegacyId() { + return legacyId; + } + + @Override + public String toString() { + return str; + } + } @Expose @ConfigOption(name = "Item To Show", desc = "Choose how many items are displayed. (Some sacks have too many items to fit\n" + @@ -71,13 +131,69 @@ public class SackDisplayConfig { @ConfigOption(name = "Price Format", desc = "Format of the price displayed.\n" + "§eFormatted: §7(12k)\n" + "§eUnformatted: §7(12,421)") - @ConfigEditorDropdown(values = {"Formatted", "Unformatted"}) - public int priceFormat = 0; + @ConfigEditorDropdown() + public PriceFormatEntry priceFormat = PriceFormatEntry.FORMATTED; + + public enum PriceFormatEntry implements HasLegacyId { + FORMATTED("Formatted", 0), + UNFORMATTED("Unformatted", 1); + + private final String str; + private final int legacyId; + + PriceFormatEntry(String str, int legacyId) { + this.str = str; + this.legacyId = legacyId; + } + + // Constructor if new enum elements are added post-migration + PriceFormatEntry(String str) { + this(str, -1); + } + + @Override + public int getLegacyId() { + return legacyId; + } + + @Override + public String toString() { + return str; + } + } @Expose @ConfigOption(name = "Show Price From", desc = "Show price from Bazaar or NPC.") - @ConfigEditorDropdown(values = {"Bazaar", "NPC"}) - public int priceFrom = 0; + @ConfigEditorDropdown() + public PriceFrom priceFrom = PriceFrom.BAZAAR; + + public enum PriceFrom implements HasLegacyId { + BAZAAR("Bazaar", 0), + NPC("NPC", 1); + + private final String str; + private final int legacyId; + + PriceFrom(String str, int legacyId) { + this.str = str; + this.legacyId = legacyId; + } + + // Constructor if new enum elements are added post-migration + PriceFrom(String str) { + this(str, -1); + } + + @Override + public int getLegacyId() { + return legacyId; + } + + @Override + public String toString() { + return str; + } + } @Expose public Position position = new Position(144, 139, false, true); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/itemability/FireVeilWandConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/itemability/FireVeilWandConfig.java index a05558d94..9cd157a4f 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/itemability/FireVeilWandConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/itemability/FireVeilWandConfig.java @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.config.features.itemability; +import at.hannibal2.skyhanni.config.HasLegacyId; import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.ConfigEditorColour; import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; @@ -8,8 +9,37 @@ import io.github.moulberry.moulconfig.annotations.ConfigOption; public class FireVeilWandConfig { @Expose @ConfigOption(name = "Fire Veil Design", desc = "Changes the flame particles of the Fire Veil Wand ability.") - @ConfigEditorDropdown(values = {"Particles", "Line", "Off"}) - public int display = 0; + @ConfigEditorDropdown() + public DisplayEntry display = DisplayEntry.PARTICLES; + + public enum DisplayEntry implements HasLegacyId { + PARTICLES("Particles", 0), + LINE("Line", 1), + OFF("Off", 2), + ; + private final String str; + private final int legacyId; + + DisplayEntry(String str, int legacyId) { + this.str = str; + this.legacyId = legacyId; + } + + // Constructor if new enum elements are added post-migration + DisplayEntry(String str) { + this(str, -1); + } + + @Override + public int getLegacyId() { + return legacyId; + } + + @Override + public String toString() { + return str; + } + } @Expose @ConfigOption( diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/HideArmorConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/HideArmorConfig.java index 286249061..cc1939fbf 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/HideArmorConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/HideArmorConfig.java @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.config.features.misc; +import at.hannibal2.skyhanni.config.HasLegacyId; import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; @@ -9,8 +10,37 @@ public class HideArmorConfig { @Expose @ConfigOption(name = "Mode", desc = "Hide the armor of players.") - @ConfigEditorDropdown(values = {"All", "Own Armor", "Other's Armor", "Off"}) - public int mode = 3; + @ConfigEditorDropdown() + public ModeEntry mode = ModeEntry.OFF; + + public enum ModeEntry implements HasLegacyId { + ALL("All", 0), + OWN("Own Armor", 1), + OTHERS("Other's Armor", 2), + OFF("Off", 3); + private final String str; + private final int legacyId; + + ModeEntry(String str, int legacyId) { + this.str = str; + this.legacyId = legacyId; + } + + // Constructor if new enum elements are added post-migration + ModeEntry(String str) { + this(str, -1); + } + + @Override + public int getLegacyId() { + return legacyId; + } + + @Override + public String toString() { + return str; + } + } @Expose @ConfigOption(name = "Only Helmet", desc = "Only hide the helmet.") diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/TrackerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/TrackerConfig.java index 613adde60..d3a257dc3 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/TrackerConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/TrackerConfig.java @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.config.features.misc; +import at.hannibal2.skyhanni.config.HasLegacyId; import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker; import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; @@ -16,8 +17,36 @@ public class TrackerConfig { @Expose @ConfigOption(name = "Show Price From", desc = "Show price from Bazaar or NPC.") - @ConfigEditorDropdown(values = {"Instant Sell", "Sell Offer", "NPC"}) - public int priceFrom = 1; + @ConfigEditorDropdown() + public PriceFromEntry priceFrom = PriceFromEntry.SELL_OFFER; + + public enum PriceFromEntry implements HasLegacyId { + INSTANT_SELL("Instant Sell", 0), + SELL_OFFER("Sell Offer", 1), + NPC("NPC", 2); + private final String str; + private final int legacyId; + + PriceFromEntry(String str, int legacyId) { + this.str = str; + this.legacyId = legacyId; + } + + // Constructor if new enum elements are added post-migration + PriceFromEntry(String str) { + this(str, -1); + } + + @Override + public int getLegacyId() { + return legacyId; + } + + @Override + public String toString() { + return str; + } + } @Expose @ConfigOption(name = "Default Display Mode", desc = "Change the display mode that gets shown on default.") diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/compacttablist/AdvancedPlayerListConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/compacttablist/AdvancedPlayerListConfig.java index 0bd6360d6..c677fb1db 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/compacttablist/AdvancedPlayerListConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/compacttablist/AdvancedPlayerListConfig.java @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.config.features.misc.compacttablist; +import at.hannibal2.skyhanni.config.HasLegacyId; import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; @@ -9,8 +10,40 @@ public class AdvancedPlayerListConfig { @Expose @ConfigOption(name = "Player Sort", desc = "Change the sort order of player names in the tab list.") - @ConfigEditorDropdown(values = {"Rank (Default)", "SB Level", "Name (Abc)", "Ironman/Bingo", "Party/Friends/Guild", "Random"}) - public int playerSortOrder = 0; + @ConfigEditorDropdown() + public PlayerSortEntry playerSortOrder = PlayerSortEntry.RANK; + + public enum PlayerSortEntry implements HasLegacyId { + RANK("Rank (Default)", 0), + SB_LEVEL("SB Level", 1), + NAME("Name (Abc)", 2), + PROFILE_TYPE("Ironman/Bingo", 3), + SOCIAL_STATUS("Party/Friends/Guild", 4), + RANDOM("Random", 5); + + private final String str; + private final int legacyId; + + PlayerSortEntry(String str, int legacyId) { + this.str = str; + this.legacyId = legacyId; + } + + // Constructor if new enum elements are added post-migration + PlayerSortEntry(String str) { + this(str, -1); + } + + @Override + public int getLegacyId() { + return legacyId; + } + + @Override + public String toString() { + return str; + } + } @Expose @ConfigOption(name = "Invert Sort", desc = "Flip the player list order on its head (also works with default rank).") 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 index 297a83a1c..50ec181e4 100644 --- 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 @@ -1,6 +1,7 @@ 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; @@ -17,8 +18,36 @@ public class InventoryValueConfig { @Expose @ConfigOption(name = "Number Format Type", desc = "Short: 1.2M\n" + "Long: 1,200,000") - @ConfigEditorDropdown(values = {"Short", "Long"}) - public int formatType = 0; + @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/slayer/blaze/BlazeHellionConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/slayer/blaze/BlazeHellionConfig.java index 4a5e4af8c..08153da05 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/slayer/blaze/BlazeHellionConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/slayer/blaze/BlazeHellionConfig.java @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.config.features.slayer.blaze; 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; @@ -28,8 +29,36 @@ public class BlazeHellionConfig { @Expose @ConfigOption(name = "First Dagger", desc = "Select the first, left sided dagger for the display.") - @ConfigEditorDropdown(values = {"Spirit/Crystal", "Ashen/Auric"}) - public int firstDagger = 0; + @ConfigEditorDropdown() + public FirstDaggerEntry firstDagger = FirstDaggerEntry.SPIRIT_OR_CRYSTAL; + + public enum FirstDaggerEntry implements HasLegacyId { + SPIRIT_OR_CRYSTAL("Spirit/Crystal", 0), + ASHEN_OR_AURIC("Ashen/Auric", 1), + ; + private final String str; + private final int legacyId; + + FirstDaggerEntry(String str, int legacyId) { + this.str = str; + this.legacyId = legacyId; + } + + // Constructor if new enum elements are added post-migration + FirstDaggerEntry(String str) { + this(str, -1); + } + + @Override + public int getLegacyId() { + return legacyId; + } + + @Override + public String toString() { + return str; + } + } @Expose @ConfigOption(name = "Hide Chat", desc = "Remove the wrong Blaze Slayer dagger messages from chat.") diff --git a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt index 3694bf672..8a2c511b3 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigFileType +import at.hannibal2.skyhanni.config.features.inventory.SackDisplayConfig.PriceFrom import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent @@ -89,9 +90,10 @@ object SackAPI { } private fun NEUInternalName.sackPrice(stored: String) = when (sackDisplayConfig.priceFrom) { - 0 -> (getPrice(true) * stored.formatNumber()).toLong().let { if (it < 0) 0L else it } + PriceFrom.BAZAAR -> (getPrice(true) * stored.formatNumber()).toLong() + .let { if (it < 0) 0L else it } - 1 -> try { + PriceFrom.NPC -> try { val npcPrice = getNpcPriceOrNull() ?: 0.0 (npcPrice * stored.formatNumber()).toLong() } catch (e: Exception) { 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 8afd758a7..dfa187c0d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShader.kt @@ -1,17 +1,22 @@ 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 * * Credit: [ChromaShader.java](https://github.com/BiscuitDevelopment/SkyblockAddons/blob/main/src/main/java/codes/biscuit/skyblockaddons/shader/chroma/ChromaShader.java) */ + object ChromaShader : Shader("chroma", "chroma") { val config get() = SkyHanniMod.feature.chroma val INSTANCE: ChromaShader @@ -26,8 +31,8 @@ object ChromaShader : Shader("chroma", "chroma") { (MinecraftData.totalTicks / 2) + (Minecraft.getMinecraft() as AccessorMinecraft).timer.renderPartialTicks ticks = when (config.chromaDirection) { - 0, 2 -> ticks - 1, 3 -> -ticks + Direction.FORWARD_RIGHT, Direction.BACKWARD_RIGHT -> ticks + Direction.FORWARD_LEFT, Direction.BACKWARD_LEFT -> -ticks else -> ticks } @@ -39,10 +44,17 @@ object ChromaShader : Shader("chroma", "chroma") { } registerUniform(Uniform.UniformType.BOOL, "forwardDirection") { when (config.chromaDirection) { - 0, 1 -> true - 2, 3 -> false + Direction.FORWARD_RIGHT, Direction.FORWARD_LEFT -> true + Direction.BACKWARD_RIGHT, Direction.BACKWARD_LEFT -> false else -> true } } } + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.transform(14, "config.chromaDirection") { element -> + ConfigUtils.migrateIntToEnum(element, Direction::class.java) + } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt index daf5caddd..b7d3718c7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt @@ -2,10 +2,14 @@ package at.hannibal2.skyhanni.features.combat import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.features.combat.BestiaryConfig +import at.hannibal2.skyhanni.config.features.combat.BestiaryConfig.DisplayTypeEntry +import at.hannibal2.skyhanni.config.features.combat.BestiaryConfig.NumberFormatEntry import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzColor @@ -99,6 +103,12 @@ object BestiaryData { @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { event.move(2, "misc.bestiaryData", "combat.bestiary") + event.transform(14, "combat.bestiary.numberFormat") { element -> + ConfigUtils.migrateIntToEnum(element, NumberFormatEntry::class.java) + } + event.transform(14, "combat.bestiary.displayType") { element -> + ConfigUtils.migrateIntToEnum(element, DisplayTypeEntry::class.java) + } } private fun update() { @@ -209,14 +219,14 @@ object BestiaryData { private fun sortMobList(): MutableList { val sortedMobList = when (config.displayType) { - 0 -> mobList.sortedBy { it.percentToMax() } - 1 -> mobList.sortedBy { it.percentToTier() } - 2 -> mobList.sortedBy { it.totalKills } - 3 -> mobList.sortedByDescending { it.totalKills } - 4 -> mobList.sortedBy { it.killNeededToMax() } - 5 -> mobList.sortedByDescending { it.killNeededToMax() } - 6 -> mobList.sortedBy { it.killNeededToNextLevel() } - 7 -> mobList.sortedByDescending { it.killNeededToNextLevel() } + DisplayTypeEntry.GLOBAL_MAX -> mobList.sortedBy { it.percentToMax() } + DisplayTypeEntry.GLOBAL_NEXT -> mobList.sortedBy { it.percentToTier() } + DisplayTypeEntry.LOWEST_TOTAL -> mobList.sortedBy { it.totalKills } + DisplayTypeEntry.HIGHEST_TOTAL -> mobList.sortedByDescending { it.totalKills } + DisplayTypeEntry.LOWEST_MAX -> mobList.sortedBy { it.killNeededToMax() } + DisplayTypeEntry.HIGHEST_MAX -> mobList.sortedByDescending { it.killNeededToMax() } + DisplayTypeEntry.LOWEST_NEXT -> mobList.sortedBy { it.killNeededToNextLevel() } + DisplayTypeEntry.HIGHEST_NEXT -> mobList.sortedByDescending { it.killNeededToNextLevel() } else -> mobList.sortedBy { it.totalKills } }.toMutableList() return sortedMobList @@ -270,34 +280,34 @@ object BestiaryData { "§c§lMAXED! §7(§b${mob.actualRealTotalKill.formatNumber()}§7 kills)" } else { when (displayType) { - 0, 1 -> { + DisplayTypeEntry.GLOBAL_MAX, DisplayTypeEntry.GLOBAL_NEXT -> { val currentKill = when (displayType) { - 0 -> mob.totalKills - 1 -> mob.currentKillToNextLevel + DisplayTypeEntry.GLOBAL_MAX -> mob.totalKills + DisplayTypeEntry.GLOBAL_NEXT -> mob.currentKillToNextLevel else -> 0 } val killNeeded = when (displayType) { - 0 -> mob.killToMax - 1 -> mob.killNeededForNextLevel + DisplayTypeEntry.GLOBAL_MAX -> mob.killToMax + DisplayTypeEntry.GLOBAL_NEXT -> mob.killNeededForNextLevel else -> 0 } "§7(§b${currentKill.formatNumber()}§7/§b${killNeeded.formatNumber()}§7) §a${ ((currentKill.toDouble() / killNeeded) * 100).roundToPrecision( 2 ) - }§6% ${if (displayType == 1) "§ato level ${mob.getNextLevel()}" else ""}" + }§6% ${if (displayType == DisplayTypeEntry.GLOBAL_NEXT) "§ato level ${mob.getNextLevel()}" else ""}" } - 2, 3 -> { + DisplayTypeEntry.LOWEST_TOTAL, DisplayTypeEntry.HIGHEST_TOTAL -> { "§6${mob.totalKills.formatNumber()} §7total kills" } - 4, 5 -> { + DisplayTypeEntry.LOWEST_MAX, DisplayTypeEntry.HIGHEST_MAX -> { "§6${mob.killNeededToMax().formatNumber()} §7kills needed" } - 6, 7 -> { + DisplayTypeEntry.LOWEST_NEXT, DisplayTypeEntry.HIGHEST_NEXT -> { "§6${mob.killNeededToNextLevel().formatNumber()} §7kills needed" } @@ -310,17 +320,19 @@ object BestiaryData { private fun addButtons(newDisplay: MutableList>) { newDisplay.addButton( prefix = "§7Number Format: ", - getName = FormatType.entries[config.numberFormat].type, + getName = FormatType.entries[config.numberFormat.ordinal].type, // todo: avoid ordinal onChange = { - config.numberFormat = (config.numberFormat + 1) % 2 + // todo: avoid ordinal + config.numberFormat = BestiaryConfig.NumberFormatEntry.entries[(config.numberFormat.ordinal + 1) % 2] update() }) newDisplay.addButton( prefix = "§7Display Type: ", - getName = DisplayType.entries[config.displayType].type, + getName = DisplayType.entries[config.displayType.ordinal].type, // todo: avoid ordinal onChange = { - config.displayType = (config.displayType + 1) % 8 + // todo: avoid ordinal + config.displayType = DisplayTypeEntry.entries[(config.displayType.ordinal + 1) % 8] update() }) @@ -417,8 +429,8 @@ object BestiaryData { } private fun Long.formatNumber(): String = when (config.numberFormat) { - 0 -> NumberUtil.format(this) - 1 -> this.addSeparators() + BestiaryConfig.NumberFormatEntry.SHORT -> NumberUtil.format(this) + BestiaryConfig.NumberFormatEntry.LONG -> this.addSeparators() else -> "0" } diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/BossType.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/BossType.kt index 045eaaa78..11f16ae7f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/BossType.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/BossType.kt @@ -1,8 +1,8 @@ package at.hannibal2.skyhanni.features.combat.damageindicator -import at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.DamageIndicatorBossEntry +import at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.BossCategory -typealias Type = DamageIndicatorBossEntry +typealias Type = BossCategory enum class BossType( val fullName: String, diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt index 42fee548c..6228ff5aa 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt @@ -2,7 +2,8 @@ package at.hannibal2.skyhanni.features.combat.damageindicator import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator -import at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.DamageIndicatorBossEntry +import at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.BossCategory +import at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.NameVisibility import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.events.BossHealthChangeEvent import at.hannibal2.skyhanni.events.DamageIndicatorDeathEvent @@ -196,9 +197,9 @@ class DamageIndicatorManager { } var bossName = when (config.bossName) { - 0 -> "" - 1 -> data.bossType.fullName - 2 -> data.bossType.shortName + NameVisibility.HIDDEN -> "" + NameVisibility.FULL_NAME -> data.bossType.fullName + NameVisibility.SHORT_NAME -> data.bossType.shortName else -> data.bossType.fullName } @@ -873,7 +874,10 @@ class DamageIndicatorManager { event.move(3, "slayer.endermanPhaseDisplay", "slayer.endermen.phaseDisplay") event.move(3, "slayer.blazePhaseDisplay", "slayer.blazes.phaseDisplay") event.transform(11, "combat.damageIndicator.bossesToShow") { element -> - ConfigUtils.migrateIntArrayListToEnumArrayList(element, DamageIndicatorBossEntry::class.java) + ConfigUtils.migrateIntArrayListToEnumArrayList(element, BossCategory::class.java) + } + event.transform(14, "combat.damageIndicator.bossName") { element -> + ConfigUtils.migrateIntToEnum(element, NameVisibility::class.java) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt index b1abdc2d5..cd3af1f77 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt @@ -2,9 +2,11 @@ package at.hannibal2.skyhanni.features.fishing.trophy import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.features.fishing.trophyfishing.ChatMessagesConfig.DesignFormat import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager.fishes import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager.getTooltip +import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addOrPut import at.hannibal2.skyhanni.utils.LorenzUtils.sumAllValues @@ -42,7 +44,7 @@ class TrophyFishMessages { val amount = trophyFishCounts.addOrPut(rarity, 1) event.blockedReason = "trophy_fish" - if (config.enabled && config.design == 0 && amount == 1) { + if (config.enabled && config.design == DesignFormat.STYLE_1 && amount == 1) { LorenzUtils.chat("§6§lTROPHY FISH! §c§lFIRST §r$displayRarity $displayName", prefix = false) return } @@ -57,8 +59,8 @@ class TrophyFishMessages { val component = ChatComponentText( if (config.enabled) { "§6§lTROPHY FISH! " + when (config.design) { - 0 -> "§7$amount. §r$displayRarity $displayName$totalText" - 1 -> "§bYou caught a $displayName $displayRarity§b. §7(${amount.addSeparators()})$totalText" + DesignFormat.STYLE_1 -> "§7$amount. §r$displayRarity $displayName$totalText" + DesignFormat.STYLE_2 -> "§bYou caught a $displayName $displayRarity§b. §7(${amount.addSeparators()})$totalText" else -> "§bYou caught your ${amount.addSeparators()}${amount.ordinal()} $displayRarity $displayName§b.$totalText" } } else event.message @@ -84,5 +86,8 @@ class TrophyFishMessages { event.move(2, "fishing.trophyFishDuplicateHider", "fishing.trophyFishing.chatMessages.duplicateHider") event.move(2, "fishing.trophyFishBronzeHider", "fishing.trophyFishing.chatMessages.bronzeHider") event.move(2, "fishing.trophyFishSilverHider", "fishing.trophyFishing.chatMessages.silverHider") + event.transform(14, "fishing.trophyFishing.chatMessages.design") { element -> + ConfigUtils.migrateIntToEnum(element, DesignFormat::class.java) + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt index f86c3d23c..8faf2a5b6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigFileType import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.features.garden.NextJacobContestConfig.ShareContestsEntry import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent @@ -11,6 +12,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIcon import at.hannibal2.skyhanni.utils.APIUtil +import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils @@ -238,7 +240,7 @@ object GardenNextJacobContest { fun shareContestConfirmed(array: Array) { if (array.size == 1) { if (array[0] == "enable") { - config.shareAutomatically = 1 + config.shareAutomatically = ShareContestsEntry.AUTO SkyHanniMod.feature.storage.contestSendingAsked = true LorenzUtils.chat("§2Enabled automatic sharing of future contests!") } @@ -247,7 +249,7 @@ object GardenNextJacobContest { if (contests.size == maxContestsPerYear) { sendContests() } - if (!SkyHanniMod.feature.storage.contestSendingAsked && config.shareAutomatically == 0) { + if (!SkyHanniMod.feature.storage.contestSendingAsked && config.shareAutomatically == ShareContestsEntry.ASK) { LorenzUtils.clickableChat( "§2Click here to automatically share future contests!", "shsendcontests enable" @@ -451,9 +453,10 @@ object GardenNextJacobContest { && (GardenAPI.inGarden() || config.everywhere) private fun isFetchEnabled() = isEnabled() && config.fetchAutomatically - private fun isSendEnabled() = isFetchEnabled() && config.shareAutomatically != 2 // 2 = Disabled + private fun isSendEnabled() = + isFetchEnabled() && config.shareAutomatically != ShareContestsEntry.DISABLED private fun askToSendContests() = - config.shareAutomatically == 0 // 0 = Ask, 1 = Send (Only call if isSendEnabled()) + config.shareAutomatically == ShareContestsEntry.ASK // (Only call if isSendEnabled()) private fun fetchContestsIfAble() { if (isFetchingContests || contests.size == maxContestsPerYear || !isFetchEnabled()) return @@ -564,5 +567,8 @@ object GardenNextJacobContest { event.move(3, "garden.nextJacobContestWarnTime", "garden.nextJacobContests.warnTime") event.move(3, "garden.nextJacobContestWarnPopup", "garden.nextJacobContests.warnPopup") event.move(3, "garden.nextJacobContestPos", "garden.nextJacobContests.pos") + event.transform(14, "garden.nextJacobContests.shareAutomatically") { element -> + ConfigUtils.migrateIntToEnum(element, ShareContestsEntry::class.java) + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt index bebeb71f8..186f3d34f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt @@ -1,10 +1,12 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.features.garden.TooltipTweaksConfig.CropTooltipFortuneEntry import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay.Companion.getAbilityFortune import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI +import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld @@ -79,8 +81,8 @@ class ToolTooltipTweaks { val cropString = if (hiddenFortune != 0.0) " §6[+${hiddenFortune.roundToInt()}]" else "" val fortuneLine = when (config.cropTooltipFortune) { - 0 -> "§7Farming Fortune: §a+${displayedFortune.formatStat()}$ffdString$reforgeString" - 1 -> "§7Farming Fortune: §a+${displayedFortune.formatStat()}$ffdString$reforgeString$cropString" + CropTooltipFortuneEntry.DEFAULT -> "§7Farming Fortune: §a+${displayedFortune.formatStat()}$ffdString$reforgeString" + CropTooltipFortuneEntry.SHOW -> "§7Farming Fortune: §a+${displayedFortune.formatStat()}$ffdString$reforgeString$cropString" else -> "§7Farming Fortune: §a+${totalFortune.formatStat()}$ffdString$reforgeString$cropString" } iterator.set(fortuneLine) @@ -158,5 +160,8 @@ class ToolTooltipTweaks { event.move(3, "garden.compactToolTooltips", "garden.tooltipTweak.compactToolTooltips") event.move(3, "garden.fortuneTooltipKeybind", "garden.tooltipTweak.fortuneTooltipKeybind") event.move(3, "garden.cropTooltipFortune", "garden.tooltipTweak.cropTooltipFortune") + event.transform(14, "garden.tooltipTweak.cropTooltipFortune") { element -> + ConfigUtils.migrateIntToEnum(element, CropTooltipFortuneEntry::class.java) + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt index 5d14fc142..9e6e83d1f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt @@ -1,6 +1,9 @@ package at.hannibal2.skyhanni.features.garden.composter import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.features.garden.composter.ComposterConfig +import at.hannibal2.skyhanni.config.features.garden.composter.ComposterConfig.OverlayPriceTypeEntry +import at.hannibal2.skyhanni.config.features.garden.composter.ComposterConfig.RetrieveFromEntry import at.hannibal2.skyhanni.data.SackAPI import at.hannibal2.skyhanni.data.SackStatus import at.hannibal2.skyhanni.data.jsonobjects.repo.GardenJson @@ -16,6 +19,7 @@ import at.hannibal2.skyhanni.features.bazaar.BazaarApi import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.composter.ComposterAPI.getLevel import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValue +import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_old import at.hannibal2.skyhanni.utils.ItemUtils.name @@ -443,7 +447,7 @@ object ComposterOverlay { private fun retrieveMaterials(internalName: String, itemName: String, itemsNeeded: Int) { if (itemsNeeded == 0 || internalName == "BIOFUEL") return - if (config.retrieveFrom == 0 && !LorenzUtils.noTradeMode) { + if (config.retrieveFrom == ComposterConfig.RetrieveFromEntry.BAZAAR && !LorenzUtils.noTradeMode) { BazaarApi.searchForBazaarItem(itemName, itemsNeeded) return } @@ -492,7 +496,7 @@ object ComposterOverlay { } private fun getPrice(internalName: String): Double { - val useSellPrice = config.overlayPriceType == 1 + val useSellPrice = config.overlayPriceType == ComposterConfig.OverlayPriceTypeEntry.BUY_ORDER val price = NEUItems.getPrice(internalName, useSellPrice) if (internalName == "BIOFUEL" && price > 20_000) return 20_000.0 @@ -578,5 +582,11 @@ object ComposterOverlay { event.move(3, "garden.composterOverlayOrganicMatterPos", "garden.composters.overlayOrganicMatterPos") event.move(3, "garden.composterOverlayFuelExtrasPos", "garden.composters.overlayFuelExtrasPos") event.move(3, "garden.composterRoundDown", "garden.composters.roundDown") + event.transform(14, "garden.composters.overlayPriceType") { element -> + ConfigUtils.migrateIntToEnum(element, OverlayPriceTypeEntry::class.java) + } + event.transform(14, "garden.composters.retrieveFrom") { element -> + ConfigUtils.migrateIntToEnum(element, RetrieveFromEntry::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 6190bc27b..2072010c9 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 @@ -1,6 +1,8 @@ package at.hannibal2.skyhanni.features.garden.farming import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.features.garden.cropmilestones.NextConfig +import at.hannibal2.skyhanni.config.features.garden.cropmilestones.NextConfig.BestTypeEntry import at.hannibal2.skyhanni.data.GardenCropMilestones import at.hannibal2.skyhanni.data.GardenCropMilestones.getCounter import at.hannibal2.skyhanni.data.GardenCropMilestones.isMaxed @@ -9,6 +11,7 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIcon import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed +import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.LorenzUtils.sorted import at.hannibal2.skyhanni.utils.TimeUnit @@ -56,7 +59,7 @@ class GardenBestCropTime { updateTimeTillNextCrop() } - val gardenExp = config.next.bestType == 0 + val gardenExp = config.next.bestType == NextConfig.BestTypeEntry.GARDEN_EXP val sorted = if (gardenExp) { val helpMap = mutableMapOf() for ((crop, time) in timeTillNextCrop) { @@ -136,5 +139,8 @@ class GardenBestCropTime { event.move(3, "garden.cropMilestoneShowCurrent", "garden.cropMilestones.next.showCurrent") event.move(3, "garden.cropMilestoneBestCompact", "garden.cropMilestones.next.bestCompact") event.move(3, "garden.cropMilestoneBestHideTitle", "garden.cropMilestones.next.bestHideTitle") + event.transform(14, "garden.cropMilestones.next.bestType") { element -> + ConfigUtils.migrateIntToEnum(element, BestTypeEntry::class.java) + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestSpawn.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestSpawn.kt index 934a73ef2..6a411e064 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestSpawn.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestSpawn.kt @@ -1,8 +1,12 @@ package at.hannibal2.skyhanni.features.garden.pests +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.features.garden.pests.PestSpawnConfig +import at.hannibal2.skyhanni.config.features.garden.pests.PestSpawnConfig.ChatMessageFormatEntry import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.garden.pests.PestSpawnEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -35,7 +39,7 @@ class PestSpawn { } } - if (blocked && config.chatMessageFormat != 0) { + if (blocked && config.chatMessageFormat != PestSpawnConfig.ChatMessageFormatEntry.HYPIXEL) { event.blockedReason = "pests_spawn" } } @@ -47,11 +51,18 @@ class PestSpawn { LorenzUtils.sendTitle("§aPest Spawn! §e$amount §ain §b$plotName§a!", 7.seconds) } - if (config.chatMessageFormat == 1) { + if (config.chatMessageFormat == PestSpawnConfig.ChatMessageFormatEntry.COMPACT) { LorenzUtils.clickableChat( "§aPest Spawn! §e$amount §ain §b$plotName§a!", "tptoplot $plotName" ) } } + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.transform(14, "garden.pests.pestSpawn.chatMessageFormat") { element -> + ConfigUtils.migrateIntToEnum(element, ChatMessageFormatEntry::class.java) + } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt index 6e24bee4b..86aad2468 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.garden.visitor import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.features.garden.visitor.VisitorConfig.HighlightMode import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent @@ -386,10 +387,10 @@ class GardenVisitorFeatures { @SubscribeEvent fun onTick(event: LorenzTickEvent) { if (!GardenAPI.inGarden()) return - if (!config.needs.display && config.highlightStatus == 3) return + if (!config.needs.display && config.highlightStatus == HighlightMode.DISABLED) return if (!event.isMod(10)) return - if (GardenAPI.onBarnPlot && config.highlightStatus != 3) { + if (GardenAPI.onBarnPlot && config.highlightStatus != HighlightMode.DISABLED) { checkVisitorsReady() } } @@ -467,13 +468,13 @@ class GardenVisitorFeatures { } } - if ((config.highlightStatus == 0 || config.highlightStatus == 2) && entity is EntityLivingBase) { + if ((config.highlightStatus == HighlightMode.COLOR || config.highlightStatus == HighlightMode.BOTH) && entity is EntityLivingBase) { val color = visitor.status.color if (color != -1) { RenderLivingEntityHelper.setEntityColor( entity, color - ) { config.highlightStatus == 0 || config.highlightStatus == 2 } + ) { config.highlightStatus == HighlightMode.COLOR || config.highlightStatus == HighlightMode.BOTH } } // Haven't gotten either of the known effected visitors (Vex and Leo) so can't test for sure if (color == -1 || !GardenAPI.inGarden()) RenderLivingEntityHelper.removeEntityColor(entity) @@ -624,6 +625,9 @@ class GardenVisitorFeatures { drops } + event.transform(14, "garden.visitors.highlightStatus") { element -> + ConfigUtils.migrateIntToEnum(element, HighlightMode::class.java) + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt index 55323ef57..c71cf1c86 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.garden.visitor +import at.hannibal2.skyhanni.config.features.garden.visitor.VisitorConfig import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent @@ -177,7 +178,7 @@ class VisitorListener { fun onCheckRender(event: CheckRenderEntityEvent<*>) { if (!GardenAPI.inGarden()) return if (!GardenAPI.onBarnPlot) return - if (config.highlightStatus != 1 && config.highlightStatus != 2) return + if (config.highlightStatus != VisitorConfig.HighlightMode.NAME && config.highlightStatus != VisitorConfig.HighlightMode.BOTH) return val entity = event.entity if (entity is EntityArmorStand && entity.name == "§e§lCLICK") { @@ -189,7 +190,7 @@ class VisitorListener { fun onRenderWorld(event: LorenzRenderWorldEvent) { if (!GardenAPI.inGarden()) return if (!GardenAPI.onBarnPlot) return - if (config.highlightStatus != 1 && config.highlightStatus != 2) return + if (config.highlightStatus != VisitorConfig.HighlightMode.NAME && config.highlightStatus != VisitorConfig.HighlightMode.BOTH) return for (visitor in VisitorAPI.getVisitors()) { visitor.getNameTagEntity()?.let { 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 f8817b43b..1ff5ec828 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt @@ -1,6 +1,9 @@ package at.hannibal2.skyhanni.features.inventory import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.features.inventory.ChestValueConfig.NumberFormatEntry +import at.hannibal2.skyhanni.config.features.inventory.ChestValueConfig.SortingTypeEntry import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderEvent @@ -9,6 +12,7 @@ import at.hannibal2.skyhanni.events.InventoryOpenEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValue import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValueCalculator +import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull import at.hannibal2.skyhanni.utils.LorenzUtils @@ -148,23 +152,25 @@ class ChestValue { } private fun sortedList() = when (config.sortingType) { - 0 -> chestItems.values.sortedByDescending { it.total } - 1 -> chestItems.values.sortedBy { it.total } + SortingTypeEntry.DESCENDING -> chestItems.values.sortedByDescending { it.total } + SortingTypeEntry.ASCENDING -> chestItems.values.sortedBy { it.total } else -> chestItems.values.sortedByDescending { it.total } }.toMutableList() private fun addButton(newDisplay: MutableList>) { newDisplay.addButton("§7Sorted By: ", - getName = SortType.entries[config.sortingType].longName, + getName = SortType.entries[config.sortingType.ordinal].longName, // todo avoid ordinal onChange = { - config.sortingType = (config.sortingType + 1) % 2 + // todo avoid ordinals + config.sortingType = SortingTypeEntry.entries[(config.sortingType.ordinal + 1) % 2] update() }) newDisplay.addButton("§7Value format: ", - getName = FormatType.entries[config.formatType].type, + getName = FormatType.entries[config.formatType.ordinal].type, // todo avoid ordinal onChange = { - config.formatType = (config.formatType + 1) % 2 + // todo avoid ordinal + config.formatType = NumberFormatEntry.entries[(config.formatType.ordinal + 1) % 2] update() }) @@ -211,8 +217,11 @@ class ChestValue { private fun Double.formatPrice(): String { return when (config.formatType) { - 0 -> if (this > 1_000_000_000) NumberUtil.format(this, true) else NumberUtil.format(this) - 1 -> this.addSeparators() + NumberFormatEntry.SHORT -> if (this > 1_000_000_000) NumberUtil.format(this, true) else NumberUtil.format( + this + ) + + NumberFormatEntry.LONG -> this.addSeparators() else -> "0" } } @@ -280,4 +289,14 @@ class ChestValue { ) private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.transform(14, "inventory.chestValueConfig.numberFormat") { element -> + ConfigUtils.migrateIntToEnum(element, NumberFormatEntry::class.java) + } + event.transform(14, "inventory.chestValueConfig.sortingType") { element -> + ConfigUtils.migrateIntToEnum(element, SortingTypeEntry::class.java) + } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt index 23365d2c9..49cc14c15 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt @@ -1,10 +1,16 @@ package at.hannibal2.skyhanni.features.inventory import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.features.inventory.SackDisplayConfig +import at.hannibal2.skyhanni.config.features.inventory.SackDisplayConfig.NumberFormatEntry +import at.hannibal2.skyhanni.config.features.inventory.SackDisplayConfig.PriceFormatEntry +import at.hannibal2.skyhanni.config.features.inventory.SackDisplayConfig.SortingTypeEntry import at.hannibal2.skyhanni.data.SackAPI import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.features.bazaar.BazaarApi +import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzColor @@ -63,10 +69,10 @@ object SackDisplay { val sackItems = SackAPI.sackItem.toList() if (sackItems.isNotEmpty()) { val sortedPairs: MutableMap = when (config.sortingType) { - 0 -> sackItems.sortedByDescending { it.second.stored.formatNumber() } - 1 -> sackItems.sortedBy { it.second.stored.formatNumber() } - 2 -> sackItems.sortedByDescending { it.second.price } - 3 -> sackItems.sortedBy { it.second.price } + SortingTypeEntry.DESC_STORED -> sackItems.sortedByDescending { it.second.stored.formatNumber() } + SortingTypeEntry.ASC_STORED -> sackItems.sortedBy { it.second.stored.formatNumber() } + SortingTypeEntry.DESC_PRICE -> sackItems.sortedByDescending { it.second.price } + SortingTypeEntry.ASC_PRICE -> sackItems.sortedBy { it.second.price } else -> sackItems.sortedByDescending { it.second.stored.formatNumber() } }.toMap().toMutableMap() @@ -95,9 +101,11 @@ object SackDisplay { add( when (config.numberFormat) { - 0 -> "$colorCode${stored}§7/§b${total}" - 1 -> "$colorCode${NumberUtil.format(stored.formatNumber())}§7/§b${total}" - 2 -> "$colorCode${stored}§7/§b${total.formatNumber().addSeparators()}" + NumberFormatEntry.DEFAULT -> "$colorCode${stored}§7/§b${total}" + NumberFormatEntry.FORMATTED -> "$colorCode${NumberUtil.format(stored.formatNumber())}§7/§b${total}" + NumberFormatEntry.UNFORMATTED -> "$colorCode${stored}§7/§b${ + total.formatNumber().addSeparators() + }" else -> "$colorCode${stored}§7/§b${total}" } ) @@ -126,22 +134,24 @@ object SackDisplay { if (SackAPI.isTrophySack) newDisplay.addAsSingletonList("§cTotal Magmafish: §6${totalMagmaFish.addSeparators()}") - val name = SortType.entries[config.sortingType].longName + val name = SortType.entries[config.sortingType.ordinal].longName // todo avoid ordinal newDisplay.addAsSingletonList("§7Sorted By: §c$name") newDisplay.addSelector(" ", getName = { type -> type.shortName }, - isCurrent = { it.ordinal == config.sortingType }, + isCurrent = { it.ordinal == config.sortingType.ordinal }, // todo avoid ordinal onChange = { - config.sortingType = it.ordinal + config.sortingType = SortingTypeEntry.entries[it.ordinal] // todo avoid ordinals update(false) }) newDisplay.addButton( prefix = "§7Number format: ", - getName = NumberFormat.entries[config.numberFormat].DisplayName, + getName = NumberFormat.entries[config.numberFormat.ordinal].DisplayName, // todo avoid ordinal onChange = { - config.numberFormat = (config.numberFormat + 1) % 3 + // todo avoid ordinal + config.numberFormat = + NumberFormatEntry.entries[(config.numberFormat.ordinal + 1) % 3] update(false) } ) @@ -149,16 +159,18 @@ object SackDisplay { if (config.showPrice) { newDisplay.addSelector(" ", getName = { type -> type.displayName }, - isCurrent = { it.ordinal == config.priceFrom }, + isCurrent = { it.ordinal == config.priceFrom.ordinal }, // todo avoid ordinal onChange = { - config.priceFrom = it.ordinal + config.priceFrom = SackDisplayConfig.PriceFrom.entries[it.ordinal] // todo avoid ordinal update(false) }) newDisplay.addButton( prefix = "§7Price Format: ", - getName = PriceFormat.entries[config.priceFormat].displayName, + getName = PriceFormat.entries[config.priceFormat.ordinal].displayName, // todo avoid ordinal onChange = { - config.priceFormat = (config.priceFormat + 1) % 2 + // todo avoid ordinal + config.priceFormat = + PriceFormatEntry.entries[(config.priceFormat.ordinal + 1) % 2] update(false) } ) @@ -200,7 +212,8 @@ object SackDisplay { return newDisplay } - private fun format(price: Long) = if (config.priceFormat == 0) NumberUtil.format(price) else price.addSeparators() + private fun format(price: Long) = + if (config.priceFormat == PriceFormatEntry.FORMATTED) NumberUtil.format(price) else price.addSeparators() private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled @@ -229,4 +242,20 @@ object SackDisplay { FORMATTED("Formatted"), UNFORMATTED("Unformatted") } + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.transform(14, "inventory.sackDisplay.numberFormat") { element -> + ConfigUtils.migrateIntToEnum(element, NumberFormatEntry::class.java) + } + event.transform(14, "inventory.sackDisplay.priceFormat") { element -> + ConfigUtils.migrateIntToEnum(element, PriceFormatEntry::class.java) + } + event.transform(14, "inventory.sackDisplay.priceFrom") { element -> + ConfigUtils.migrateIntToEnum(element, SackDisplayConfig.PriceFrom::class.java) + } + event.transform(14, "inventory.sackDisplay.sortingType") { element -> + ConfigUtils.migrateIntToEnum(element, SortingTypeEntry::class.java) + } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt index abb0c0f4c..fdce2da62 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt @@ -2,10 +2,12 @@ package at.hannibal2.skyhanni.features.itemabilities import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.features.itemability.FireVeilWandConfig.DisplayEntry import at.hannibal2.skyhanni.data.ClickType import at.hannibal2.skyhanni.events.BlockClickEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.toChromaColor @@ -25,7 +27,7 @@ class FireVeilWandParticles { @SubscribeEvent fun onChatPacket(event: ReceiveParticleEvent) { if (!LorenzUtils.inSkyBlock) return - if (config.display == 0) return + if (config.display == DisplayEntry.PARTICLES) return if (System.currentTimeMillis() > lastClick + 5_500) return if (event.type == EnumParticleTypes.FLAME && event.speed == 0.55f) { event.isCanceled = true @@ -48,7 +50,7 @@ class FireVeilWandParticles { @SubscribeEvent fun onRenderWorld(event: LorenzRenderWorldEvent) { if (!LorenzUtils.inSkyBlock) return - if (config.display != 1) return + if (config.display != DisplayEntry.LINE) return if (System.currentTimeMillis() > lastClick + 5_500) return val color = config.displayColor.toChromaColor() @@ -60,5 +62,8 @@ class FireVeilWandParticles { fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { event.move(3, "itemAbilities.fireVeilWandDisplayColor", "itemAbilities.fireVeilWands.displayColor") event.move(3, "itemAbilities.fireVeilWandDisplay", "itemAbilities.fireVeilWands.display") + event.transform(14, "itemAbilities.fireVeilWands.display") { element -> + ConfigUtils.migrateIntToEnum(element, DisplayEntry::class.java) + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/HideArmor.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/HideArmor.kt index 96301ee7c..e3e6d62b3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/HideArmor.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/HideArmor.kt @@ -1,6 +1,9 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.features.misc.HideArmorConfig.ModeEntry +import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.EntityUtils.getArmorInventory import at.hannibal2.skyhanni.utils.EntityUtils.hasPotionEffect import at.hannibal2.skyhanni.utils.EntityUtils.isNPC @@ -24,10 +27,10 @@ class HideArmor { if (entity.isNPC()) return false return when (config.mode) { - 0 -> true + ModeEntry.ALL -> true - 1 -> entity is EntityPlayerSP - 2 -> entity !is EntityPlayerSP + ModeEntry.OWN -> entity is EntityPlayerSP + ModeEntry.OTHERS -> entity !is EntityPlayerSP else -> false } @@ -61,4 +64,11 @@ class HideArmor { armorInventory[index] = stack } } -} \ No newline at end of file + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.transform(14, "misc.hideArmor2.mode") { element -> + ConfigUtils.migrateIntToEnum(element, ModeEntry::class.java) + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PlayerChatSymbols.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PlayerChatSymbols.kt index 5133e65be..a406ce169 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PlayerChatSymbols.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PlayerChatSymbols.kt @@ -1,9 +1,12 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.features.chat.ChatSymbols.SymbolLocationEntry import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.features.misc.compacttablist.TabStringType import at.hannibal2.skyhanni.mixins.transformers.AccessorChatComponentText +import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.StringUtils import at.hannibal2.skyhanni.utils.StringUtils.getPlayerNameAndRankFromChatMessage @@ -79,8 +82,16 @@ class PlayerChatSymbols { private fun getNewText(emblemText: String, oldText: String, rankAndName: String): String = when (config.symbolLocation) { - 0 -> oldText.replace(rankAndName, "$emblemText $rankAndName") - 1 -> oldText.replace(rankAndName, "$rankAndName $emblemText ") + SymbolLocationEntry.LEFT -> oldText.replace(rankAndName, "$emblemText $rankAndName") + SymbolLocationEntry.RIGHT -> oldText.replace(rankAndName, "$rankAndName $emblemText ") + SymbolLocationEntry.HIDDEN -> oldText else -> oldText } + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.transform(14, "chat.chatSymbols.symbolLocation") { element -> + ConfigUtils.migrateIntToEnum(element, SymbolLocationEntry::class.java) + } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt index ab2b31777..d4dc00449 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt @@ -1,6 +1,8 @@ package at.hannibal2.skyhanni.features.misc.compacttablist import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.features.misc.compacttablist.AdvancedPlayerListConfig.PlayerSortEntry import at.hannibal2.skyhanni.data.FriendAPI import at.hannibal2.skyhanni.data.GuildAPI import at.hannibal2.skyhanni.data.IslandType @@ -10,6 +12,7 @@ import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.bingo.BingoAPI import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests +import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland @@ -107,21 +110,26 @@ object AdvancedPlayerList { val sorted = when (config.playerSortOrder) { - // Rank (Default) - 1 -> prepare.sortedBy { -(it.value.sbLevel) } + // SB Level + PlayerSortEntry.SB_LEVEL -> prepare.sortedBy { -(it.value.sbLevel) } // Name (Abc) - 2 -> prepare.sortedBy { it.value.name.lowercase().replace("_", "") } + PlayerSortEntry.NAME -> prepare.sortedBy { + it.value.name.lowercase().replace("_", "") + } // Ironman/Bingo - 3 -> prepare.sortedBy { -if (it.value.ironman) 10 else it.value.bingoLevel ?: -1 } + PlayerSortEntry.PROFILE_TYPE -> prepare.sortedBy { + -if (it.value.ironman) 10 else it.value.bingoLevel ?: -1 + } // Party/Friends/Guild First - 4 -> prepare.sortedBy { -socialScore(it.value.name) } + PlayerSortEntry.SOCIAL_STATUS -> prepare.sortedBy { -socialScore(it.value.name) } // Random - 5 -> prepare.sortedBy { getRandomOrder(it.value.name) } + PlayerSortEntry.RANDOM -> prepare.sortedBy { getRandomOrder(it.value.name) } + // Rank (Default) else -> prepare } @@ -238,4 +246,11 @@ object AdvancedPlayerList { MAGE(" §5ቾ"), NONE("") } + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.transform(14, "misc.compactTabList.advancedPlayerList.playerSortOrder") { element -> + ConfigUtils.migrateIntToEnum(element, PlayerSortEntry::class.java) + } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt index d6f8d8e05..0afcba7cf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt @@ -2,8 +2,10 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.features.crimsonisle.ReputationHelperConfig.ShowLocationEntry import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ProfileStorageData +import at.hannibal2.skyhanni.data.jsonobjects.repo.CrimsonIsleReputationJson import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzTickEvent @@ -12,6 +14,7 @@ import at.hannibal2.skyhanni.features.nether.reputationhelper.dailykuudra.DailyK import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.DailyQuestHelper import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.QuestLoader import at.hannibal2.skyhanni.features.nether.reputationhelper.miniboss.DailyMiniBossHelper +import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList @@ -19,7 +22,6 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.TabListData -import at.hannibal2.skyhanni.data.jsonobjects.repo.CrimsonIsleReputationJson import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -130,6 +132,9 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { event.move(2, "misc.reputationHelperHotkey", "crimsonIsle.reputationHelper.hotkey") event.move(2, "misc.crimsonIsleReputationHelperPos", "crimsonIsle.reputationHelper.position") event.move(2, "misc.crimsonIsleReputationShowLocation", "crimsonIsle.reputationHelper.showLocation") + event.transform(14, "crimsonIsle.reputationHelper.showLocation") { element -> + ConfigUtils.migrateIntToEnum(element, ShowLocationEntry::class.java) + } } fun update() { @@ -158,8 +163,8 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { } fun showLocations() = when (config.showLocation) { - 0 -> true - 1 -> config.hotkey.isKeyHeld() + ShowLocationEntry.ALWAYS -> true + ShowLocationEntry.ONLY_HOTKEY -> config.hotkey.isKeyHeld() else -> false } } 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 256349220..867e88dcd 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,5 +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.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent @@ -9,6 +11,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.features.rift.RiftAPI.motesNpcPrice +import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.LorenzColor @@ -163,14 +166,14 @@ class ShowMotesNpcSellPrice { } val total = itemMap.values.fold(0.0) { acc, pair -> acc + pair.second }.formatPrice() newDisplay.addAsSingletonList("§7Total price: §b$total") - val name = FormatType.entries[config.inventoryValue.formatType].type + val name = FormatType.entries[config.inventoryValue.formatType.ordinal].type // todo avoid ordinal newDisplay.addAsSingletonList("§7Price format: §c$name") newDisplay.addSelector( " ", getName = { type -> type.type }, - isCurrent = { it.ordinal == config.inventoryValue.formatType }, + isCurrent = { it.ordinal == config.inventoryValue.formatType.ordinal }, // todo avoid ordinal onChange = { - config.inventoryValue.formatType = it.ordinal + config.inventoryValue.formatType = NumberFormatEntry.entries[it.ordinal] // todo avoid ordinal update() } ) @@ -183,12 +186,19 @@ class ShowMotesNpcSellPrice { } private fun Double.formatPrice(): String = when (config.inventoryValue.formatType) { - 0 -> NumberUtil.format(this) - 1 -> this.addSeparators() + NumberFormatEntry.SHORT -> NumberUtil.format(this) + NumberFormatEntry.LONG -> this.addSeparators() else -> "0" } private fun isShowPriceEnabled() = RiftAPI.inRift() && config.showPrice private fun isInventoryValueEnabled() = RiftAPI.inRift() && config.inventoryValue.enabled + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.transform(14, "rift.motes.inventoryValue.formatType") { element -> + ConfigUtils.migrateIntToEnum(element, NumberFormatEntry::class.java) + } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt index 260d7d4d6..73076a932 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt @@ -3,12 +3,14 @@ package at.hannibal2.skyhanni.features.slayer.blaze import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.core.config.gui.GuiPositionEditor +import at.hannibal2.skyhanni.config.features.slayer.blaze.BlazeHellionConfig.FirstDaggerEntry import at.hannibal2.skyhanni.data.ClickType import at.hannibal2.skyhanni.events.BlockClickEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.TitleReceivedEvent +import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LocationUtils @@ -62,7 +64,7 @@ class BlazeSlayerDaggerHelper { checkActiveDagger() lastNearest = findNearest() - val first = Dagger.entries[config.firstDagger] + val first = Dagger.entries[config.firstDagger.ordinal] // todo avoid ordinal val second = first.other() textTop = format(holding, true, first) + " " + format(holding, true, second) @@ -249,6 +251,9 @@ class BlazeSlayerDaggerHelper { event.move(3, "slayer.blazeMarkRightHellionShield", "slayer.blazes.hellion.markRightHellionShield") event.move(3, "slayer.blazeFirstDagger", "slayer.blazes.hellion.firstDagger") event.move(3, "slayer.blazeHideDaggerWarning", "slayer.blazes.hellion.hideDaggerWarning") + event.transform(14, "slayer.blazes.hellion.firstDagger") { element -> + ConfigUtils.migrateIntToEnum(element, FirstDaggerEntry::class.java) + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt index e7b1faacb..6812476df 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.utils.tracker import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.Storage +import at.hannibal2.skyhanni.config.features.misc.TrackerConfig.PriceFromEntry import at.hannibal2.skyhanni.test.PriceSource import at.hannibal2.skyhanni.utils.ItemUtils.getNameWithEnchantment import at.hannibal2.skyhanni.utils.KeyboardManager @@ -50,9 +51,9 @@ class SkyHanniItemTracker( lists.addSelector( "", getName = { type -> type.displayName }, - isCurrent = { it.ordinal == config.priceFrom }, + isCurrent = { it.ordinal == config.priceFrom.ordinal }, // todo avoid ordinal onChange = { - config.priceFrom = it.ordinal + config.priceFrom = PriceFromEntry.entries[it.ordinal] // todo avoid ordinal 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 888d47361..80202fab0 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt @@ -1,11 +1,14 @@ 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 import at.hannibal2.skyhanni.data.ProfileStorageData 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 @@ -16,6 +19,7 @@ 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( @@ -36,8 +40,8 @@ open class SkyHanniTracker( private val storedTrackers get() = SkyHanniMod.feature.storage.trackerDisplayModes fun getPricePer(name: NEUInternalName) = when (config.priceFrom) { - 0 -> name.getBazaarData()?.sellPrice ?: name.getPriceOrNull() ?: 0.0 - 1 -> name.getBazaarData()?.buyPrice ?: name.getPriceOrNull() ?: 0.0 + PriceFromEntry.INSTANT_SELL -> name.getBazaarData()?.sellPrice ?: name.getPriceOrNull() ?: 0.0 + PriceFromEntry.SELL_OFFER -> name.getBazaarData()?.buyPrice ?: name.getPriceOrNull() ?: 0.0 else -> name.getNpcPriceOrNull() ?: 0.0 } @@ -172,4 +176,11 @@ open class SkyHanniTracker( override fun toString() = display } + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.transform(14, "misc.tracker.priceFrom") { element -> + ConfigUtils.migrateIntToEnum(element, PriceFromEntry::class.java) + } + } } -- cgit