aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-05-13 12:40:21 +0200
committerGitHub <noreply@github.com>2024-05-13 12:40:21 +0200
commit4e98f4a176fb8bfe2b9c9afcdb4b941d5b721704 (patch)
tree2fa38db1c75150d3a5f69b14f4654796cbed577b /src/main/java/at/hannibal2/skyhanni/utils
parent253d92a20b93a46d308cc94b73130e87e82f2da1 (diff)
downloadskyhanni-4e98f4a176fb8bfe2b9c9afcdb4b941d5b721704.tar.gz
skyhanni-4e98f4a176fb8bfe2b9c9afcdb4b941d5b721704.tar.bz2
skyhanni-4e98f4a176fb8bfe2b9c9afcdb4b941d5b721704.zip
Improvement: performance in various ways (#1782)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/SkyblockSeason.kt7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SkyblockSeason.kt b/src/main/java/at/hannibal2/skyhanni/utils/SkyblockSeason.kt
index 2e06ba423..fb596bea7 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/SkyblockSeason.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/SkyblockSeason.kt
@@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.utils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.UtilsPatterns.seasonPattern
+import kotlin.time.Duration.Companion.seconds
enum class SkyblockSeason(
val season: String,
@@ -20,7 +21,11 @@ enum class SkyblockSeason(
companion object {
- fun getCurrentSeason(): SkyblockSeason? = getSeasonByName(SkyBlockTime.now().monthName)
+ fun getCurrentSeason(): SkyblockSeason? = currentSeason.getValue()
+
+ private val currentSeason = RecalculatingValue(1.seconds) {
+ getSeasonByName(SkyBlockTime.now().monthName)
+ }
private fun getSeasonByName(name: String): SkyblockSeason? =
seasonPattern.matchMatcher(name) { entries.find { it.season.endsWith(group("season")) } }