1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
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,
val abbreviatedPerk: String,
val perk: String,
) {
SPRING("§dSpring", "§6+25☘", "§7Gain §6+25☘ Farming Fortune§7."),
SUMMER("§6Summer", "§3+20☯", "§7Gain §3+20☯ Farming Wisdom§7."),
AUTUMN("§eAutumn", "§a15%+§4ൠ", "§4Pests §7spawn §a15% §7more often."),
WINTER("§9Winter", "§a5%+§cC", "§7Visitors give §a5% §7more §cCopper."),
;
fun getPerk(abbreviate: Boolean): String = if (abbreviate) abbreviatedPerk else perk
fun getSeason(abbreviate: Boolean): String = if (abbreviate) season.take(4) else season
companion object {
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")) } }
}
}
|