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/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 ++- 21 files changed, 287 insertions(+), 102 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features') 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) + } } } -- cgit