From d1df749da1a58f0f3d8712b22341b59cc652a11b Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 15 Nov 2023 12:18:18 +0100 Subject: Added mythic visitor support. --- .../features/garden/visitor/GardenVisitorDropStatistics.kt | 5 +++-- src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src/main') 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 2213f9482..860213e9e 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 @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.events.PreProfileSwitchEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorAcceptEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.test.command.ErrorManager +import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.LorenzUtils.addOrPut import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy @@ -115,7 +116,7 @@ object GardenVisitorDropStatistics { private fun setRarities(rarity: String) { acceptedVisitors += 1 - val currentRarity = VisitorRarity.valueOf(rarity) + val currentRarity = LorenzUtils.enumValueOf(rarity) val visitorRarities = GardenAPI.storage?.visitorDrops?.visitorRarities ?: return val temp = visitorRarities[currentRarity.ordinal] + 1 visitorRarities[currentRarity.ordinal] = temp @@ -243,5 +244,5 @@ object GardenVisitorDropStatistics { } enum class VisitorRarity { - UNCOMMON, RARE, LEGENDARY, SPECIAL, + UNCOMMON, RARE, LEGENDARY, MYTHIC, SPECIAL, } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index e90f8ee34..2e71ab2fa 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -537,4 +537,13 @@ object LorenzUtils { @Deprecated("Dont use this approach at all. check with regex or equals instead.", ReplaceWith("Regex or equals")) fun Iterable.anyContains(element: String) = any { it.contains(element) } + + inline fun > enumValueOfOrNull(name: String): T? { + val enums = enumValues() + return enums.firstOrNull { it.name == name } + } + + inline fun > enumValueOf(name: String) = + enumValueOfOrNull(name) + ?: kotlin.error("Unknown enum constant for ${enumValues().first().name.javaClass.simpleName}: '$name'") } -- cgit