From 4e98f4a176fb8bfe2b9c9afcdb4b941d5b721704 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Mon, 13 May 2024 12:40:21 +0200 Subject: Improvement: performance in various ways (#1782) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- src/main/java/at/hannibal2/skyhanni/utils/SkyblockSeason.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/main/java/at/hannibal2/skyhanni/utils') 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")) } } -- cgit