diff options
author | NetheriteMiner <88792142+NetheriteMiner@users.noreply.github.com> | 2024-07-31 18:02:34 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-01 00:02:34 +0200 |
commit | fe59112091a4b18de61e3a1e8bbca8661583402d (patch) | |
tree | a255857132f6178952466d5ec0002af249761692 /src/main/java/at/hannibal2/skyhanni/features/misc | |
parent | 1829187fd20c43c79810688729fde4ff40f51757 (diff) | |
download | skyhanni-fe59112091a4b18de61e3a1e8bbca8661583402d.tar.gz skyhanni-fe59112091a4b18de61e3a1e8bbca8661583402d.tar.bz2 skyhanni-fe59112091a4b18de61e3a1e8bbca8661583402d.zip |
Fix: Discord RPC dynamic off-by-one (#2279)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt index 0944ca9ad..009478787 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt @@ -226,25 +226,30 @@ enum class DiscordStatus(private val displayMessageSupplier: (() -> String?)) { DiscordRPCManager.config.customText.get() // custom field in the config }), - AUTO({ - var autoReturn = "" - for (statusID in DiscordRPCManager.config.autoPriority) { // for every dynamic that the user wants to see... - // TODO, change functionality to use enum rather than ordinals - val autoStatus = AutoStatus.entries[statusID.ordinal] - val result = - autoStatus.correspondingDiscordStatus.getDisplayString() // get what would happen if we were to display it - if (result != autoStatus.placeholderText) { // if that value is useful, display it - autoReturn = result - break + AUTO( + { + var autoReturn = "" + for (statusID in DiscordRPCManager.config.autoPriority) { // for every dynamic that the user wants to see... + // TODO, change functionality to use enum rather than ordinals + val autoStatus = AutoStatus.entries[statusID.ordinal] + val result = + autoStatus.correspondingDiscordStatus.getDisplayString() // get what would happen if we were to display it + if (result != autoStatus.placeholderText) { // if that value is useful, display it + autoReturn = result + break + } } - } - if (autoReturn == "") { // if we didn't find any useful information, display the fallback - val statusNoAuto = DiscordStatus.entries.toMutableList() - statusNoAuto.remove(AUTO) - autoReturn = statusNoAuto[DiscordRPCManager.config.auto.get().ordinal].getDisplayString() - } - autoReturn - }), + if (autoReturn == "") { // if we didn't find any useful information, display the fallback + val fallbackID = DiscordRPCManager.config.auto.get().ordinal + autoReturn = if (fallbackID == 10) { + NONE.getDisplayString() // 10 is this (DiscordStatus.AUTO); prevents an infinite loop + } else { + DiscordStatus.entries[fallbackID].getDisplayString() + } + } + autoReturn + }, + ), CROP_MILESTONES({ getCropMilestoneDisplay() }), |