From cc7422d5ccb78516b00198f9f5749a467332ce99 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 29 Dec 2023 09:05:10 +0100 Subject: Created LorenzRarity.isAtLeast() --- .../java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt | 10 +++++----- src/main/java/at/hannibal2/skyhanni/utils/LorenzRarity.kt | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src/main/java/at/hannibal2') 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 5288baf13..dffb6f0ef 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -29,9 +29,7 @@ import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getItemRarityOrNull import at.hannibal2.skyhanni.utils.LocationUtils.isPlayerInside -import at.hannibal2.skyhanni.utils.LorenzRarity.EPIC -import at.hannibal2.skyhanni.utils.LorenzRarity.LEGENDARY -import at.hannibal2.skyhanni.utils.LorenzRarity.RARE +import at.hannibal2.skyhanni.utils.LorenzRarity import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.LorenzVec @@ -50,8 +48,10 @@ object GardenAPI { var toolInHand: String? = null var itemInHand: ItemStack? = null var cropInHand: CropType? = null - val mushroomCowPet get() = PetAPI.isCurrentPet("Mooshroom Cow") && - GardenAPI.storage?.fortune?.farmingItems[FarmingItems.MOOSHROOM_COW]?.getItemRarityOrNull() in listOf(RARE, EPIC, LEGENDARY) + val mushroomCowPet + get() = PetAPI.isCurrentPet("Mooshroom Cow") && + storage?.fortune?.farmingItems?.get(FarmingItems.MOOSHROOM_COW) + ?.let { it.getItemRarityOrNull()?.isAtLeast(LorenzRarity.RARE) } ?: false private var inBarn = false val onBarnPlot get() = inBarn && inGarden() val storage get() = ProfileStorageData.profileSpecific?.garden diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzRarity.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzRarity.kt index b0aca2439..64d5f8538 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzRarity.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzRarity.kt @@ -51,6 +51,8 @@ enum class LorenzRarity(val color: LorenzColor, val id: Int) { return rarityBelow } + fun isAtLeast(other: LorenzRarity): Boolean = this.ordinal >= other.ordinal + companion object { fun getById(id: Int) = entries.firstOrNull { it.ordinal == id } fun getByName(name: String) = entries.firstOrNull { it.name == name } -- cgit