From 02ac961b3f1a371302963559e875698de8eb7a1d Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Mon, 7 Aug 2023 23:37:18 +0200 Subject: replace enum.getEntries() to enum.entries and using .addSelector --- .../skyhanni/features/slayer/HighlightSlayerMiniBoss.kt | 2 +- .../skyhanni/features/slayer/SlayerItemProfitTracker.kt | 12 ++++++++---- .../java/at/hannibal2/skyhanni/features/slayer/SlayerType.kt | 2 +- .../features/slayer/blaze/BlazeSlayerDaggerHelper.kt | 12 ++++++------ 4 files changed, 16 insertions(+), 12 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features/slayer') 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( + "§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( + "", 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) { -- cgit