diff options
4 files changed, 21 insertions, 12 deletions
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 81ce2ac2d..2e17e07ff 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 @@ -2,6 +2,8 @@ package at.hannibal2.skyhanni.features.itemabilities.abilitycooldown import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName enum class ItemAbility( val abilityName: String, @@ -51,7 +53,7 @@ enum class ItemAbility( ECHO("Echo", 3, "Ancestral Spade"); var newVariant = false - var internalNames = mutableListOf<String>() + var internalNames = mutableListOf<NEUInternalName>() constructor( cooldownInSeconds: Int, @@ -59,8 +61,10 @@ enum class ItemAbility( alternativePosition: Boolean = false, ) : this("no name", cooldownInSeconds, actionBarDetection = false, alternativePosition = alternativePosition) { newVariant = true - internalNames.addAll(alternateInternalNames) - internalNames.add(name) + alternateInternalNames.forEach { + internalNames.add(it.asInternalName()) + } + internalNames.add(name.asInternalName()) } fun activate(color: LorenzColor? = null, customCooldown: Int = (cooldownInSeconds * 1000)) { @@ -92,7 +96,7 @@ enum class ItemAbility( } companion object { - fun getByInternalName(internalName: String): ItemAbility? { + fun getByInternalName(internalName: NEUInternalName): ItemAbility? { 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 f09e86164..a0fd45a13 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 @@ -6,7 +6,7 @@ import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.ItemUtils.cleanName -import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_old +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.between @@ -46,8 +46,12 @@ class ItemAbilityCooldown { ItemAbility.GYROKINETIC_WAND_LEFT.sound() } if (event.pitch == 1f && event.volume == 1f) { - val internalName = InventoryUtils.getItemInHand()?.getInternalName_old() ?: return - if (!internalName.equalsOneOf("SHADOW_FURY", "STARRED_SHADOW_FURY")) return + val internalName = InventoryUtils.getItemInHand()?.getInternalName() ?: return + if (!internalName.equalsOneOf( + "SHADOW_FURY".asInternalName(), + "STARRED_SHADOW_FURY".asInternalName() + ) + ) return ItemAbility.SHADOW_FURY.sound() } @@ -157,7 +161,7 @@ class ItemAbilityCooldown { private fun handleItemClick(itemInHand: ItemStack?) { if (!LorenzUtils.inSkyBlock) return - itemInHand?.getInternalName_old()?.run { + itemInHand?.getInternalName()?.run { ItemAbility.getByInternalName(this)?.setItemClick() } } @@ -321,7 +325,7 @@ class ItemAbilityCooldown { private fun hasAbility(stack: ItemStack): MutableList<ItemAbility> { val itemName: String = stack.cleanName() - val internalName = stack.getInternalName_old() + val internalName = stack.getInternalName() val list = mutableListOf<ItemAbility>() for (ability in ItemAbility.entries) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt index fdad96da2..ca04f310c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt @@ -411,8 +411,8 @@ object EstimatedItemValue { private fun addSilex(stack: ItemStack, list: MutableList<String>): Double { val tier = stack.getSilexCount() ?: return 0.0 - val internalName = stack.getInternalName_old() - val maxTier = if (internalName == "STONK_PICKAXE") 4 else 5 + val internalName = stack.getInternalName() + val maxTier = if (internalName == "STONK_PICKAXE".asInternalName()) 4 else 5 val wtfHardcodedSilex = "SIL_EX".asInternalName() val price = wtfHardcodedSilex.getPrice() * tier diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 4e01f5da6..1bd3fa94d 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -29,6 +29,7 @@ import java.text.DecimalFormat import java.text.NumberFormat import java.text.SimpleDateFormat import java.util.* +import java.util.Timer import kotlin.properties.ReadWriteProperty import kotlin.reflect.KMutableProperty1 import kotlin.reflect.KProperty @@ -469,7 +470,7 @@ object LorenzUtils { // Taken and modified from Skytils @JvmStatic - fun Any.equalsOneOf(vararg other: Any): Boolean { + fun <T> T.equalsOneOf(vararg other: T): Boolean { for (obj in other) { if (this == obj) return true } |