diff options
Diffstat (limited to 'src')
51 files changed, 124 insertions, 113 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt index f46e0e194..7eeffb9a4 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt @@ -142,7 +142,7 @@ class ConfigManager { private fun fixConfig(line: String): String { var result = line - for (type in CropType.values()) { + for (type in CropType.entries) { val normal = "\"${type.cropName}\"" val enumName = "\"${type.name}\"" while (result.contains(normal)) { diff --git a/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt b/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt index df8c511ee..3c1643dad 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt @@ -103,7 +103,7 @@ class ApiDataLoader { private fun findApiCandidatesFromOtherMods(): Map<String, String> { LorenzUtils.consoleLog("Trying to find the api key from the config of other mods..") val candidates = mutableMapOf<String, String>() - for (mod in OtherMod.values()) { + for (mod in OtherMod.entries) { val modName = mod.modName val file = File(mod.configPath) if (file.exists()) { diff --git a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt index 91f2bed9a..ae68e34e2 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt @@ -27,7 +27,7 @@ enum class IslandType(val displayName: String, val apiName: String = "null") { companion object { fun getBySidebarName(name: String): IslandType { - return values().firstOrNull { it.displayName == name } ?: UNKNOWN + return entries.firstOrNull { it.displayName == name } ?: UNKNOWN } } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/data/model/ComposterUpgrade.kt b/src/main/java/at/hannibal2/skyhanni/data/model/ComposterUpgrade.kt index cc0a82a2d..f9f33d6cf 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/model/ComposterUpgrade.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/model/ComposterUpgrade.kt @@ -9,10 +9,10 @@ enum class ComposterUpgrade(val displayName: String, val slotNumber: Int) { ; companion object { - private fun regexValues() = values().joinToString("|") { it.displayName } + private fun regexValues() = entries.joinToString("|") { it.displayName } val regex = "§a(?<name>${regexValues()})(?: (?<level>.*))?".toPattern() - fun getByName(name: String) = values().firstOrNull { it.displayName == name } + fun getByName(name: String) = entries.firstOrNull { it.displayName == name } } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt index 83a2abbec..157883909 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt @@ -437,9 +437,8 @@ class DamageIndicatorManager { } private fun checkBlazeSlayer(entity: EntityLiving, entityData: EntityData, health: Int, maxHealth: Int): String { - val shields = HellionShield.values() var found = false - for (shield in shields) { + for (shield in HellionShield.entries) { val armorStand = entity.getNameTagWith(3, shield.name) if (armorStand != null) { val number = armorStand.name.split(" ♨")[1].substring(0, 1) diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt index 7f6ee3670..f843ff942 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt @@ -78,12 +78,12 @@ class BurrowWarpHelper { } private fun getNearestWarpPoint(location: LorenzVec): WarpPoint { - val map = WarpPoint.values().filter { it.enabled }.map { it to it.distance(location) } + val map = WarpPoint.entries.filter { it.enabled }.map { it to it.distance(location) } return map.sorted().first().first } fun resetDisabledWarps() { - WarpPoint.values().forEach { it.enabled = true } + WarpPoint.entries.forEach { it.enabled = true } LorenzUtils.chat("§e[SkyHanni] Reset disabled burrow warps.") } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt index 47ba57337..f8bf9943d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt @@ -131,7 +131,7 @@ class GriffinBurrowParticleFinder { fun getParticleType(packet: S2APacketParticles): ParticleType? { if (!packet.isLongDistance) return null - for (type in values()) { + for (type in entries) { if (type.check(packet)) { return type } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyRarity.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyRarity.kt index 2e61e1e80..7f3ff8524 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyRarity.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyRarity.kt @@ -11,6 +11,6 @@ enum class TrophyRarity(val formatCode: String) { val formattedString get() = "$formatCode${name.firstLetterUppercase()}" companion object { - fun getByName(rawName: String) = values().firstOrNull { rawName.uppercase().endsWith(it.name) } + fun getByName(rawName: String) = entries.firstOrNull { rawName.uppercase().endsWith(it.name) } } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt index 4c5f30ad3..1a761f0ae 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt @@ -32,7 +32,7 @@ class AnitaMedalProfit { ; } - private fun getMedal(name: String) = MedalType.values().firstOrNull { it.displayName == name } + private fun getMedal(name: String) = MedalType.entries.firstOrNull { it.displayName == name } @SubscribeEvent fun onInventoryClose(event: InventoryCloseEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/CropAccessory.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/CropAccessory.kt index b895c6511..c4269ce2e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/CropAccessory.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropAccessory.kt @@ -8,7 +8,7 @@ enum class CropAccessory(val internalName: String, private val affectedCrops: Se setOf(CropType.WHEAT, CropType.POTATO, CropType.CARROT, CropType.COCOA_BEANS, CropType.MELON, CropType.PUMPKIN), 20.0, Pair("SQUASH", 128) ), - FERMENTO("FERMENTO_ARTIFACT", CropType.values().toSet(), 30.0, Pair("CONDENSED_FERMENTO", 8)), + FERMENTO("FERMENTO_ARTIFACT", CropType.entries.toSet(), 30.0, Pair("CONDENSED_FERMENTO", 8)), ; fun getFortune(cropType: CropType): Double { @@ -16,6 +16,6 @@ enum class CropAccessory(val internalName: String, private val affectedCrops: Se } companion object { - fun getByName(internalName: String) = values().firstOrNull { it.internalName == internalName } + fun getByName(internalName: String) = entries.firstOrNull { it.internalName == internalName } } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt index ed6138082..084c8d9e9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt @@ -36,7 +36,7 @@ enum class CropType( fun getByNameOrNull(itemName: String): CropType? { if (itemName == "Red Mushroom" || itemName == "Brown Mushroom") return MUSHROOM if (itemName == "Seeds") return WHEAT - return values().firstOrNull { it.cropName == itemName } + return entries.firstOrNull { it.cropName == itemName } } fun getByName(name: String) = getByNameOrNull(name) ?: throw RuntimeException("No valid crop type '$name'") diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt index 72d1d1dc6..64952a625 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -127,7 +127,7 @@ object GardenAPI { fun ItemStack.getCropType(): CropType? { val internalName = getInternalName() - return CropType.values().firstOrNull { internalName.startsWith(it.toolName) } + return CropType.entries.firstOrNull { internalName.startsWith(it.toolName) } } fun readCounter(itemStack: ItemStack): Long = itemStack.getHoeCounter() ?: itemStack.getCultivatingCounter() ?: -1L diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt index 7905890ec..6f5e9abe0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt @@ -38,7 +38,7 @@ class GardenOptimalSpeed { @SubscribeEvent fun onGuiOpen(event: GuiOpenEvent) { - rancherOverlayList = CropType.values().map { crop -> + rancherOverlayList = CropType.entries.map { crop -> listOf(crop.icon, Renderable.link("${crop.cropName} - ${crop.getOptimalSpeed()}") { LorenzUtils.setTextIntoSign("${crop.getOptimalSpeed()}") }) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt index 9b06240ad..38132e8b6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt @@ -117,7 +117,7 @@ class ComposterDisplay { } if (next) { if (line == "") break - for (type in DataType.values()) { + for (type in DataType.entries) { type.pattern.matchMatcher(line) { newData[type] = group(1) } @@ -125,7 +125,7 @@ class ComposterDisplay { } } - for (type in DataType.values()) { + for (type in DataType.entries) { if (!newData.containsKey(type)) { tabListData = emptyMap() return 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 8943a2092..76825184a 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 @@ -122,7 +122,7 @@ class ComposterOverlay { fun onTooltip(event: ItemTooltipEvent) { if (inComposterUpgrades) { update() - for (upgrade in ComposterUpgrade.values()) { + for (upgrade in ComposterUpgrade.entries) { event.itemStack?.name?.let { if (it.contains(upgrade.displayName)) { maxLevel = ComposterUpgrade.regex.matchMatcher(it) { @@ -276,13 +276,15 @@ class ComposterOverlay { val fuelItem = currentFuelItem ?: return if (organicMatterItem == "" || fuelItem == "") return - newList.addSelector("§7Per ", TimeType.values(), + newList.addSelector<TimeType>( + "§7Per ", getName = { type -> type.display }, isCurrent = { it == currentTimeType }, onChange = { currentTimeType = it update() - }) + } + ) val list = mutableListOf<Any>() list.add("§7Using: ") diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt index d0a22dc25..e0b0961be 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt @@ -104,7 +104,7 @@ object FarmingContestAPI { cropPattern.matchMatcher(it) { CropType.getByName(group("crop")) } } ?: error("Crop not found in lore!") - val brackets = ContestBracket.values().associateWith { bracket -> + val brackets = ContestBracket.entries.associateWith { bracket -> lore.firstNotNullOfOrNull { bracket.pattern.matchMatcher(it) { group("amount").replace(",", "").toInt() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt index a2b5c10a8..a6ef0d4f1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt @@ -59,14 +59,14 @@ class JacobContestFFNeededDisplay { val crop = contest.crop add(listOf("§7For this ", crop.icon, "§7${crop.cropName} contest:")) - for (bracket in ContestBracket.values()) { + for (bracket in ContestBracket.entries) { addAsSingletonList(getLine(bracket, contest.brackets, crop)) } addAsSingletonList("") val (size, averages) = FarmingContestAPI.calculateAverages(crop) add(listOf("§7For the last §e$size ", crop.icon, "§7${crop.cropName} contests:")) - for (bracket in ContestBracket.values()) { + for (bracket in ContestBracket.entries) { addAsSingletonList(getLine(bracket, averages, crop)) } addAsSingletonList("") diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestTimeNeeded.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestTimeNeeded.kt index 09167dd76..7b0f01015 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestTimeNeeded.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestTimeNeeded.kt @@ -34,7 +34,7 @@ class JacobContestTimeNeeded { private fun update() { val sorted = mutableMapOf<CropType, Double>() val map = mutableMapOf<CropType, Renderable>() - for (crop in CropType.values()) { + for (crop in CropType.entries) { val speed = crop.getSpeed() if (speed == null) { sorted[crop] = Double.MAX_VALUE @@ -98,13 +98,15 @@ class JacobContestTimeNeeded { this.display = buildList { addAsSingletonList("§e§lTime Needed for ${currentBracket.displayName} §eMedal!") - addSelector("§7Bracket: ", ContestBracket.values(), + addSelector<ContestBracket>( + "§7Bracket: ", getName = { type -> type.name.lowercase() }, isCurrent = { it == currentBracket }, onChange = { currentBracket = it update() - }) + } + ) addAsSingletonList("") for (crop in sorted.sorted().keys) { val text = map[crop]!! diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt index b079782a8..08882db71 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt @@ -75,7 +75,7 @@ class CropSpeedMeter { fun onCropMilestoneUpdate(event: CropMilestoneUpdateEvent) { if (!isEnabled()) return val counters = mutableMapOf<CropType, Long>() - for (cropType in CropType.values()) { + for (cropType in CropType.entries) { counters[cropType] = cropType.getCounter() } if (startCrops.isEmpty()) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt index e4faf5f61..ea685338f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt @@ -32,7 +32,7 @@ class FarmingArmorDrops { @SubscribeEvent fun onChat(event: LorenzChatEvent) { - for (dropType in ArmorDropType.values()) { + for (dropType in ArmorDropType.entries) { if (dropType.chatMessage == event.message) { addDrop(dropType) if (config.farmingArmorDropsHideChat) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt index e2b5190c6..cbf4596c4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt @@ -337,7 +337,7 @@ class FarmingWeightDisplay { private fun calculateCollectionWeight(): MutableMap<CropType, Double> { val weightPerCrop = mutableMapOf<CropType, Double>() var totalWeight = 0.0 - for (crop in CropType.values()) { + for (crop in CropType.entries) { val weight = crop.getLocalCounter() / crop.getFactor() weightPerCrop[crop] = weight totalWeight += weight 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 ad9f98e6e..efdf267ef 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 @@ -26,7 +26,7 @@ class GardenBestCropTime { } fun updateTimeTillNextCrop() { - for (crop in CropType.values()) { + for (crop in CropType.entries) { val speed = crop.getSpeed() ?: continue if (crop.isMaxed()) continue @@ -50,7 +50,7 @@ class GardenBestCropTime { fun drawBestDisplay(currentCrop: CropType?): List<List<Any>> { val newList = mutableListOf<List<Any>>() - if (timeTillNextCrop.size < CropType.values().size) { + if (timeTillNextCrop.size < CropType.entries.size) { updateTimeTillNextCrop() } @@ -93,7 +93,7 @@ class GardenBestCropTime { for (crop in sorted.keys) { if (crop.isMaxed()) continue val millis = timeTillNextCrop[crop]!! - val biggestUnit = TimeUnit.values()[config.cropMilestoneHighestTimeFormat.get()] + val biggestUnit = TimeUnit.entries[config.cropMilestoneHighestTimeFormat.get()] val duration = TimeUtils.formatDuration(millis, biggestUnit, maxUnits = 2) val isCurrent = crop == currentCrop number++ diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt index 460908ccd..f6d0fe0b4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt @@ -182,7 +182,7 @@ object GardenCropMilestoneDisplay { val missingTimeSeconds = missing / farmingFortuneSpeed val millis = missingTimeSeconds * 1000 GardenBestCropTime.timeTillNextCrop[crop] = millis - val biggestUnit = TimeUnit.values()[config.cropMilestoneHighestTimeFormat.get()] + val biggestUnit = TimeUnit.entries[config.cropMilestoneHighestTimeFormat.get()] val duration = TimeUtils.formatDuration(millis, biggestUnit) tryWarn(millis, "§b${crop.cropName} $nextTier in $duration") val speedText = "§7In §b$duration" @@ -276,7 +276,7 @@ object GardenCropMilestoneDisplay { val missingTimeSeconds = missing / blocksPerSecond val millis = missingTimeSeconds * 1000 - val biggestUnit = TimeUnit.values()[config.cropMilestoneHighestTimeFormat.get()] + val biggestUnit = TimeUnit.entries[config.cropMilestoneHighestTimeFormat.get()] val duration = TimeUtils.formatDuration(millis.toLong(), biggestUnit) lineMap[3] = Collections.singletonList("§7In §b$duration") } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt index 424bec2a6..c9c645429 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt @@ -54,7 +54,7 @@ class CaptureFarmingGear { //todo better fall back items //todo Daedalus axe } else { - for (item in FarmingItems.values()) { + for (item in FarmingItems.entries) { if (item.name == currentCrop.name) { farmingItems[item] = itemStack } @@ -64,7 +64,7 @@ class CaptureFarmingGear { if (armor == null) continue val split = armor.getInternalName().split("_") if (split.first() in farmingSets) { - for (item in FarmingItems.values()) { + for (item in FarmingItems.entries) { if (item.name == split.last()) { farmingItems[item] = armor } @@ -94,7 +94,7 @@ class CaptureFarmingGear { for ((_, slot) in event.inventoryItems) { val split = slot.getInternalName().split("_") if (split.first() == "LOTUS") { - for (item in FarmingItems.values()) { + for (item in FarmingItems.entries) { if (item.name == split.last()) { farmingItems[item] = slot outdatedItems[item] = false @@ -208,7 +208,7 @@ class CaptureFarmingGear { } lotusUpgradePattern.matchMatcher(msg) { val piece = group("piece").uppercase() - for (item in FarmingItems.values()) { + for (item in FarmingItems.entries) { if (item.name == piece) { outdatedItems[item] = true } @@ -216,7 +216,7 @@ class CaptureFarmingGear { } petLevelUpPattern.matchMatcher(msg) { val pet = group("pet").uppercase() - for (item in FarmingItems.values()) { + for (item in FarmingItems.entries) { if (item.name.contains(pet)) { outdatedItems[item] = true } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt index 78c4e0c59..032c97547 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt @@ -67,7 +67,7 @@ open class FFGuideGUI : GuiScreen() { pages[FortuneGuidePage.UPGRADES] = UpgradePage() if (currentCrop != null) { - for (item in FarmingItems.values()) { + for (item in FarmingItems.entries) { if (item.name == currentCrop?.name) { FFStats.getCropStats(currentCrop!!, item.getItem()) } @@ -216,7 +216,7 @@ open class FFGuideGUI : GuiScreen() { } } } - for (crop in CropType.values()) { + for (crop in CropType.entries) { x += 30 if (GuiRenderUtils.isPointInRect(mouseX, mouseY, x, y, 25, 28)) { SoundUtils.playClickSound() @@ -225,7 +225,7 @@ open class FFGuideGUI : GuiScreen() { if (selectedPage == FortuneGuidePage.OVERVIEW) { selectedPage = FortuneGuidePage.CROP } - for (item in FarmingItems.values()) { + for (item in FarmingItems.entries) { if (item.name == crop.name) { FFStats.getCropStats(crop, item.getItem()) FortuneUpgrades.getCropSpecific(item.getItem()) @@ -234,14 +234,14 @@ open class FFGuideGUI : GuiScreen() { } else { if (selectedPage == FortuneGuidePage.CROP) { selectedPage = FortuneGuidePage.UPGRADES - for (item in FarmingItems.values()) { + for (item in FarmingItems.entries) { if (item.name == crop.name) { FortuneUpgrades.getCropSpecific(item.getItem()) } } } else { selectedPage = FortuneGuidePage.CROP - for (item in FarmingItems.values()) { + for (item in FarmingItems.entries) { if (item.name == crop.name) { FFStats.getCropStats(crop, item.getItem()) } @@ -347,7 +347,7 @@ open class FFGuideGUI : GuiScreen() { tooltipToDisplay.add("§eOverview") } - for (crop in CropType.values()) { + for (crop in CropType.entries) { x += 30 drawRect(x, y, x + 25, y + 28, if (currentCrop == crop) 0x50555555 else 0x50000000) GuiRenderUtils.renderItemStack(crop.icon, x + 5, y + 5) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrades.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrades.kt index 1b062dc57..beda557e3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrades.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrades.kt @@ -71,7 +71,7 @@ object FortuneUpgrades { private fun getTalismanUpgrade() { val currentTalismanTier = CropAccessoryData.cropAccessory?.ordinal ?: return if (currentTalismanTier < 3) { - val nextTalisman = CropAccessory.values()[currentTalismanTier + 1] + val nextTalisman = CropAccessory.entries[currentTalismanTier + 1] genericUpgrades.add(FortuneUpgrade("§7Upgrade your talisman to ${nextTalisman.internalName.replace("_", " ").lowercase()}", null, nextTalisman.upgradeCost?.first!!, nextTalisman.upgradeCost.second, 10.0)) } @@ -197,7 +197,7 @@ object FortuneUpgrades { private fun recombobulateItem(item: ItemStack, list: MutableList<FortuneUpgrade>) { if (item.isRecombobulated()) return val reforge = item.getReforgeName()?.let { - FarmingReforges.values().find { enumValue -> enumValue.name == it.uppercase() + FarmingReforges.entries.find { enumValue -> enumValue.name == it.uppercase() } } ?: return diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/CropPage.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/CropPage.kt index fdaf6ea8e..7a5435393 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/CropPage.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/CropPage.kt @@ -10,7 +10,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase class CropPage: FFGuideGUI.FFGuidePage() { override fun drawPage(mouseX: Int, mouseY: Int, partialTicks: Float) { - for (item in FarmingItems.values()) { + for (item in FarmingItems.entries) { if (item.name == FFGuideGUI.currentCrop?.name) { GuiRenderUtils.renderItemAndTip(item.getItem(), FFGuideGUI.guiLeft + 172, FFGuideGUI.guiTop + 60, mouseX, mouseY) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenCropMilestoneAverage.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenCropMilestoneAverage.kt index 6f16e3f53..7ea8ff423 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenCropMilestoneAverage.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenCropMilestoneAverage.kt @@ -18,12 +18,12 @@ class GardenCropMilestoneAverage { if (!SkyHanniMod.feature.garden.numberAverageCropMilestone) return val tiers = mutableListOf<Double>() - for (cropType in CropType.values()) { + for (cropType in CropType.entries) { val counter = cropType.getCounter() val tier = GardenCropMilestones.getTierForCrops(counter) tiers.add(tier.toDouble()) } - average = (tiers.sum() / CropType.values().size).round(2) + average = (tiers.sum() / CropType.entries.size).round(2) } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt index aee2c85de..eabae9ee0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt @@ -81,7 +81,7 @@ object GardenVisitorDropStatistics { saveAndUpdate() } - for (reward in VisitorReward.values()) { + for (reward in VisitorReward.entries) { reward.pattern.matchMatcher(message) { val old = rewardsCount[reward] ?: 0 rewardsCount = rewardsCount.editCopy { this[reward] = old + 1 } @@ -130,7 +130,7 @@ object GardenVisitorDropStatistics { addAsSingletonList(format(coinsSpent, "Coins Spent", "§6", "")) //9 – 14 - for (reward in VisitorReward.values()) { + for (reward in VisitorReward.entries) { val count = rewardsCount[reward] ?: 0 if (config.displayIcons) {// Icons val stack = NEUItems.getItemStack(reward.internalName, true) 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 2040b479d..4a3568a9f 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 @@ -141,7 +141,7 @@ class GardenVisitorFeatures { private fun readReward(offerItem: ItemStack): VisitorReward? { for (line in offerItem.getLore()) { - for (reward in VisitorReward.values()) { + for (reward in VisitorReward.entries) { if (line.contains(reward.displayName)) { return reward } 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 2b24ab1f1..8cff86bba 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt @@ -213,26 +213,28 @@ class SackDisplay { rendered++ } - val name = SortType.values()[config.sortingType].longName + val name = SortType.entries[config.sortingType].longName newDisplay.addAsSingletonList("§7Sorted By: §c$name") - newDisplay.addSelector(" ", SortType.values(), - getName = { type -> type.shortName }, - isCurrent = { it.ordinal == config.sortingType }, - onChange = { - config.sortingType = it.ordinal - update() - }) + newDisplay.addSelector<SortType>( + " ", + getName = { type -> type.shortName }, + isCurrent = { it.ordinal == config.sortingType }, + onChange = { + config.sortingType = it.ordinal + update() + }) if (config.showPrice) { newDisplay.addAsSingletonList("§cTotal price: §6${format(totalPrice)}") - newDisplay.addSelector(" ", PriceFrom.values(), - getName = { type -> type.displayName }, - isCurrent = { it.ordinal == config.priceFrom }, - onChange = { - config.priceFrom = it.ordinal - update() - }) + newDisplay.addSelector<PriceFrom>( + " ", + getName = { type -> type.displayName }, + isCurrent = { it.ordinal == config.priceFrom }, + onChange = { + config.priceFrom = it.ordinal + update() + }) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt index 8f62d5266..81ce2ac2d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt @@ -93,7 +93,7 @@ enum class ItemAbility( companion object { fun getByInternalName(internalName: String): ItemAbility? { - return values().firstOrNull { it.newVariant && internalName in it.internalNames } + return entries.firstOrNull { it.newVariant && internalName in it.internalNames } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt index e15395d16..330240ceb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt @@ -185,7 +185,7 @@ class ItemAbilityCooldown { val name: String = message.between(" (§6", "§b) ") if (name == lastAbility) return lastAbility = name - for (ability in ItemAbility.values()) { + for (ability in ItemAbility.entries) { if (ability.abilityName == name) { click(ability) return @@ -321,7 +321,7 @@ class ItemAbilityCooldown { val internalName = stack.getInternalName() val list = mutableListOf<ItemAbility>() - for (ability in ItemAbility.values()) { + for (ability in ItemAbility.entries) { if (ability.newVariant) { if (ability.internalNames.contains(internalName)) { list.add(ability) diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/HighlightMiningCommissionMobs.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/HighlightMiningCommissionMobs.kt index d34939d8c..46e96f0c5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/HighlightMiningCommissionMobs.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/HighlightMiningCommissionMobs.kt @@ -61,7 +61,7 @@ class HighlightMiningCommissionMobs { fun onTabListUpdate(event: TabListUpdateEvent) { if (!isEnabled()) return - MobType.values().filter { type -> + MobType.entries.filter { type -> event.tabList.find { line -> line.contains(type.commissionName) }?.let { !it.endsWith("§aDONE") } ?: false }.let { if (it != active) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt index 664c0a42d..8350a637e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt @@ -89,7 +89,7 @@ class FrozenTreasureTracker { if (config.hideMessages) event.blockedReason = "frozen treasure tracker" } - for (treasure in FrozenTreasure.values()) { + for (treasure in FrozenTreasure.entries) { if ("FROZEN TREASURE! You found ${treasure.displayName.removeColor()}!".toRegex().matches(message)) { treasuresMined += 1 val old = treasureCount[treasure] ?: 0 @@ -122,7 +122,7 @@ class FrozenTreasureTracker { addAsSingletonList("§8${formatNumber(compactProcs)} Compact Procs") addAsSingletonList("") - for (treasure in FrozenTreasure.values()) { + for (treasure in FrozenTreasure.entries) { val count = (treasureCount[treasure] ?: 0) * if (config.showAsDrops) treasure.defaultAmount else 1 addAsSingletonList("§b${formatNumber(count)} ${treasure.displayName}") } @@ -147,7 +147,7 @@ class FrozenTreasureTracker { private fun calculateIce() { estimatedIce = 0 estimatedIce += compactProcs * 160 - for (treasure in FrozenTreasure.values()) { + for (treasure in FrozenTreasure.entries) { val amount = treasureCount[treasure] ?: 0 estimatedIce += amount * treasure.defaultAmount * treasure.iceMultiplier } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt index 6477d7c36..d6e429fa0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt @@ -145,7 +145,7 @@ class NonGodPotEffectDisplay { for (stack in event.inventoryItems.values) { val name = stack.name ?: continue - for (effect in NonGodPotEffect.values()) { + for (effect in NonGodPotEffect.entries) { if (name != effect.displayName) continue for (line in stack.getLore()) { if (line.contains("Remaining") && @@ -182,7 +182,7 @@ class NonGodPotEffectDisplay { var effectsCount = 0 for (line in lines) { - for (effect in NonGodPotEffect.values()) { + for (effect in NonGodPotEffect.entries) { if (line.startsWith(effect.displayName)) { try { val duration = TimeUtils.getMillis(line.split("§f")[1]) @@ -221,7 +221,7 @@ class NonGodPotEffectDisplay { for (element in effects) { val effectJson = element.asJsonObject val name = effectJson["effect"].asString - val effect = NonGodPotEffect.values().find { it.apiName == name } ?: continue + val effect = NonGodPotEffect.entries.find { it.apiName == name } ?: continue val time = effectJson["ticks_remaining"].asLong / 20 val newValue = System.currentTimeMillis() + time * 1000 diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt index 82e40ced3..615559360 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt @@ -146,7 +146,7 @@ object DiscordRPCManager : IPCListener { } } - private fun getStatusByConfigId(id: Int) = DiscordStatus.values().getOrElse(id) { DiscordStatus.NONE } + private fun getStatusByConfigId(id: Int) = DiscordStatus.entries.getOrElse(id) { DiscordStatus.NONE } private fun isEnabled() = config.enabled.get() diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt index e2a25b219..5b4102a15 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt @@ -255,7 +255,7 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?) else if (milestoneResult != "Not farming!") milestoneResult else if (stackingResult != "") stackingResult else { - val statusNoAuto = DiscordStatus.values().toMutableList() + val statusNoAuto = entries.toMutableList() statusNoAuto.remove(AUTO) statusNoAuto[SkyHanniMod.feature.misc.discordRPC.auto.get()].getDisplayString() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/tiarelay/TiaRelayWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/tiarelay/TiaRelayWaypoints.kt index 10c6612bd..7bfc45ae9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/tiarelay/TiaRelayWaypoints.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/tiarelay/TiaRelayWaypoints.kt @@ -22,7 +22,7 @@ class TiaRelayWaypoints { if (!SkyHanniMod.feature.misc.tiaRelayNextWaypoint) return val message = event.message - for (relay in Relay.values()) { + for (relay in Relay.entries) { if (relay.chatMessage == message) { waypoint = relay.waypoint waypointName = relay.relayName @@ -42,7 +42,7 @@ class TiaRelayWaypoints { if (!LorenzUtils.inSkyBlock) return if (SkyHanniMod.feature.misc.tiaRelayAllWaypoints) { - for (relay in Relay.values()) { + for (relay in Relay.entries) { if (relay.island == LorenzUtils.skyBlockIsland) { event.drawWaypointFilled(relay.waypoint, LorenzColor.LIGHT_PURPLE.toColor()) event.drawDynamicText(relay.waypoint, "§d" + relay.relayName, 1.5) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt index 61f6fedda..11c0504d8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt @@ -133,13 +133,13 @@ class TrevorFeatures { active = true } - CurrentMobArea.values().firstOrNull { it.location == formattedLine }?.let { + CurrentMobArea.entries.firstOrNull { it.location == formattedLine }?.let { TrevorSolver.mobLocation = it found = true } locationPattern.matchMatcher(formattedLine) { val zone = group("zone") - TrevorSolver.mobLocation = CurrentMobArea.values().firstOrNull { it.location == zone } + TrevorSolver.mobLocation = CurrentMobArea.entries.firstOrNull { it.location == zone } ?: CurrentMobArea.NONE found = true } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt index 6ba60604c..0ef03688e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt @@ -52,7 +52,7 @@ object TrevorSolver { if (entity is EntityOtherPlayerMP) continue val name = entity.name val entityHealth = if (entity is EntityLivingBase) entity.baseMaxHealth else 0 - currentMob = TrevorMobs.values().firstOrNull { it.mobName.contains(name) } + currentMob = TrevorMobs.entries.firstOrNull { it.mobName.contains(name) } if (currentMob == TrevorMobs.CHICKEN) { if (entity is EntityChicken) { if (entity.hasMaxHealth(20_000)) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/mobs/AreaMiniBossFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/mobs/AreaMiniBossFeatures.kt index 8c1a2dd24..a0988ceac 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mobs/AreaMiniBossFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mobs/AreaMiniBossFeatures.kt @@ -27,7 +27,7 @@ class AreaMiniBossFeatures { val entity = event.entity val maxHealth = event.maxHealth - for (bossType in AreaMiniBossType.values()) { + for (bossType in AreaMiniBossType.entries) { if (!bossType.clazz.isInstance(entity)) continue if (!entity.hasMaxHealth(bossType.health, false, maxHealth)) continue diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/KloonHacking.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/KloonHacking.kt index aeb73b42d..d58eafd0e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/KloonHacking.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/KloonHacking.kt @@ -109,7 +109,7 @@ class KloonHacking { if (!config.waypoints) return if (!wearingHelmet) return val hidden = ProfileStorageData.profileSpecific?.rift ?: return - for (terminal in KloonTerminal.values()) { + for (terminal in KloonTerminal.entries) { if (terminal !in hidden.completedKloonTerminals) { event.drawWaypointFilled(terminal.location, LorenzColor.DARK_RED.toColor(), true, true) } @@ -124,7 +124,7 @@ class KloonHacking { "You've set the color of this terminal to (?<colour>.*)!".toPattern().matchMatcher(event.message.removeColor()) { val hidden = ProfileStorageData.profileSpecific?.rift ?: return val colour = group("colour") - val completedTerminal = KloonTerminal.values().firstOrNull { it.name == colour } ?: return + val completedTerminal = KloonTerminal.entries.firstOrNull { it.name == colour } ?: return if (completedTerminal != nearestTerminal) return hidden.completedKloonTerminals.add(completedTerminal) } @@ -146,7 +146,7 @@ class KloonHacking { var closestTerminal: KloonTerminal? = null var closestDistance = 8.0 - for (terminal in KloonTerminal.values()) { + for (terminal in KloonTerminal.entries) { val distance = terminal.location.distanceToPlayer() if (distance < closestDistance) { closestTerminal = terminal 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 1f88a4ad1..25bafb299 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 @@ -158,15 +158,17 @@ class ShowMotesNpcSellPrice { } val total = itemMap.values.fold(0.0) { acc, pair -> acc + pair.second }.formatPrice() newDisplay.addAsSingletonList("§7Total price: §b$total") - val name = FormatType.values()[config.inventoryValue.formatType].type + val name = FormatType.entries[config.inventoryValue.formatType].type newDisplay.addAsSingletonList("§7Price format: §c$name") - newDisplay.addSelector(" ", FormatType.values(), + newDisplay.addSelector<FormatType>( + " ", getName = { type -> type.type }, isCurrent = { it.ordinal == config.inventoryValue.formatType }, onChange = { config.inventoryValue.formatType = it.ordinal update() - }) + } + ) return newDisplay } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniBoss.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniBoss.kt index 5ed91696f..8c6399dde 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniBoss.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniBoss.kt @@ -26,7 +26,7 @@ class HighlightSlayerMiniBoss { if (DamageIndicatorManager.isBoss(entity)) return val maxHealth = event.maxHealth - for (bossType in SlayerMiniBossType.values()) { + for (bossType in SlayerMiniBossType.entries) { if (!bossType.clazz.isInstance(entity)) continue if (bossType.health.any { entity.hasMaxHealth(it, false, maxHealth) }) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt index cd08bbfdb..581761831 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt @@ -162,13 +162,15 @@ object SlayerItemProfitTracker { addAsSingletonList("§e§l$itemLogCategory Profit Tracker") if (inventoryOpen) { - addSelector("§7Display Mode: ", DisplayMode.values(), + addSelector<DisplayMode>( + "§7Display Mode: ", getName = { type -> type.displayName }, isCurrent = { it == currentDisplayMode }, onChange = { currentDisplayMode = it update() - }) + } + ) } var profit = 0.0 @@ -265,13 +267,15 @@ object SlayerItemProfitTracker { addAsSingletonList(Renderable.hoverTips(text, listOf("§7Profit per boss: $profitPrefix$profitPerBossFormat"))) if (inventoryOpen) { - addSelector("", PriceSource.values(), + addSelector<PriceSource>( + "", getName = { type -> type.displayName }, isCurrent = { it.ordinal == config.priceFrom }, onChange = { config.priceFrom = it.ordinal update() - }) + } + ) } if (inventoryOpen && currentDisplayMode == DisplayMode.CURRENT) { addAsSingletonList( diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerType.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerType.kt index 8c44dbd3b..8319bfb3a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerType.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerType.kt @@ -51,7 +51,7 @@ enum class SlayerType(val displayName: String, val clazz: Class<*>) { } fun getByDisplayName(text: String): SlayerType? { - return values().firstOrNull { text.startsWith(it.displayName) } + return entries.firstOrNull { text.startsWith(it.displayName) } } } }
\ No newline at end of file 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 632433573..68cd7bd17 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 @@ -63,7 +63,7 @@ class BlazeSlayerDaggerHelper { checkActiveDagger() lastNearest = findNearest() - val first = Dagger.values()[SkyHanniMod.feature.slayer.blazeFirstDagger] + val first = Dagger.entries[SkyHanniMod.feature.slayer.blazeFirstDagger] val second = first.other() textTopLeft = format(holding, true, first) @@ -122,7 +122,7 @@ class BlazeSlayerDaggerHelper { if (lastDaggerCheck + 1_000 > System.currentTimeMillis()) return lastDaggerCheck = System.currentTimeMillis() - for (dagger in Dagger.values()) { + for (dagger in Dagger.entries) { if (dagger.updated) continue val first = dagger.shields[0] @@ -160,7 +160,7 @@ class BlazeSlayerDaggerHelper { private fun getDaggerFromStack(stack: ItemStack?): Dagger? { val itemName = stack?.name ?: "" - for (dagger in Dagger.values()) { + for (dagger in Dagger.entries) { if (dagger.daggerNames.any { itemName.contains(it) }) { return dagger } @@ -174,9 +174,9 @@ class BlazeSlayerDaggerHelper { if (!isEnabled()) return - for (shield in HellionShield.values()) { + for (shield in HellionShield.entries) { if (shield.formattedName + "§r" == event.title) { - Dagger.values().filter { shield in it.shields }.forEach { + Dagger.entries.filter { shield in it.shields }.forEach { it.shields.forEach { shield -> shield.active = false } it.updated = true } @@ -310,7 +310,7 @@ class BlazeSlayerDaggerHelper { } private fun HellionShield.other(): HellionShield { - for (dagger in BlazeSlayerDaggerHelper.Dagger.values()) { + for (dagger in BlazeSlayerDaggerHelper.Dagger.entries) { if (this in dagger.shields) { for (shield in dagger.shields) { if (shield != this) { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 94d8dd10f..673d5b70e 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -14,6 +14,7 @@ import io.github.moulberry.notenoughupdates.mixins.AccessorGuiEditSign import io.github.moulberry.notenoughupdates.util.SkyBlockTime import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiEditSign +import net.minecraft.entity.Entity import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.SharedMonsterAttributes import net.minecraft.event.ClickEvent @@ -308,16 +309,15 @@ object LorenzUtils { } } - fun <T> MutableList<List<Any>>.addSelector( + inline fun <reified T : Enum<T>> MutableList<List<Any>>.addSelector( prefix: String, - values: Array<T>, getName: (T) -> String, isCurrent: (T) -> Boolean, - onChange: (T) -> Unit, + crossinline onChange: (T) -> Unit, ) { add(buildList { add(prefix) - for (entry in values) { + for (entry in enumValues<T>()) { val display = getName(entry) if (isCurrent(entry)) { add("§a[$display]") diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt index d39c8e757..a7b129349 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt @@ -239,7 +239,7 @@ object SkyBlockItemModifierUtils { ; companion object { - fun getByName(name: String) = GemstoneQuality.values().firstOrNull { it.name == name } + fun getByName(name: String) = entries.firstOrNull { it.name == name } } } @@ -255,7 +255,7 @@ object SkyBlockItemModifierUtils { ; companion object { - fun getByName(name: String) = values().firstOrNull { it.name == name } + fun getByName(name: String) = entries.firstOrNull { it.name == name } } } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt index 4f9c1b799..c088ded64 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt @@ -29,7 +29,7 @@ object TimeUtils { // TODO: if this weird offset gets removed, also remove that subtraction from formatDuration(kotlin.time.Duration) var milliseconds = millis + 999 val map = mutableMapOf<TimeUnit, Int>() - for (unit in TimeUnit.values()) { + for (unit in TimeUnit.entries) { if (unit.ordinal >= biggestUnit.ordinal) { val factor = unit.factor map[unit] = (milliseconds / factor).toInt() |