diff options
| author | Walker Selby <git@walkerselby.com> | 2023-12-11 13:59:52 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-11 22:59:52 +0100 |
| commit | d5b4a817e2b9e7e5c88eb0c8212b9a6e678bd92f (patch) | |
| tree | bc07923686b77da759b3f12ea535f2e3c02deead /src/main/java | |
| parent | b8ec689ce9bd6fe89e4b825a988edb63fb51b5ab (diff) | |
| download | skyhanni-d5b4a817e2b9e7e5c88eb0c8212b9a6e678bd92f.tar.gz skyhanni-d5b4a817e2b9e7e5c88eb0c8212b9a6e678bd92f.tar.bz2 skyhanni-d5b4a817e2b9e7e5c88eb0c8212b9a6e678bd92f.zip | |
Internal: Migrate Deprecated Config Values to Enums (#790)
Migrate Deprecated Config Values to Enums. #790
Diffstat (limited to 'src/main/java')
44 files changed, 1149 insertions, 189 deletions
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<DamageIndicatorBossEntry> bossesToShow = new ArrayList<>(Arrays.asList( + public List<BossCategory> 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 legac |
