diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-15 12:18:18 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-15 12:18:18 +0100 |
commit | d1df749da1a58f0f3d8712b22341b59cc652a11b (patch) | |
tree | d27e6d5a3c59bcf9036a7a402e678de1f121e9a4 /src/main/java | |
parent | 3604594ba19899e7732b405f047c69ad7b1ab3da (diff) | |
download | skyhanni-d1df749da1a58f0f3d8712b22341b59cc652a11b.tar.gz skyhanni-d1df749da1a58f0f3d8712b22341b59cc652a11b.tar.bz2 skyhanni-d1df749da1a58f0f3d8712b22341b59cc652a11b.zip |
Added mythic visitor support.
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt | 5 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt | 9 |
2 files changed, 12 insertions, 2 deletions
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<VisitorRarity>(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<String>.anyContains(element: String) = any { it.contains(element) } + + inline fun <reified T : Enum<T>> enumValueOfOrNull(name: String): T? { + val enums = enumValues<T>() + return enums.firstOrNull { it.name == name } + } + + inline fun <reified T : Enum<T>> enumValueOf(name: String) = + enumValueOfOrNull<T>(name) + ?: kotlin.error("Unknown enum constant for ${enumValues<T>().first().name.javaClass.simpleName}: '$name'") } |