From 95632c5677d51c351d20a900de0c9be15e17629b Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 5 Dec 2023 16:50:24 +0100 Subject: show a text around new year that the calendar data are not loaded for the next contest. --- .../features/garden/GardenNextJacobContest.kt | 34 ++++++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt index f6da72d88..5e8c0fd6b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt @@ -48,12 +48,15 @@ object GardenNextJacobContest { private var simpleDisplay = emptyList() private var contests = mutableMapOf() private var inCalendar = false + private val patternDay = "§aDay (?.*)".toPattern() private val patternMonth = "(?.*), Year (?.*)".toPattern() private val patternCrop = "§(e○|6☘) §7(?.*)".toPattern() + private val closeToNewYear = "§7Close to new SB year!" private const val maxContestsPerYear = 124 private val contestDuration = 20.minutes + private var lastWarningTime = 0L private var loadedContestsYear = -1 private var nextContestsAvailableAt = -1L @@ -81,12 +84,27 @@ object GardenNextJacobContest { if (counter == 4) break } } - newList.add("§cOpen calendar for") - newList.add("§cmore exact data!") + + if (isCloseToNewYear()) { + newList.add(closeToNewYear) + } else { + newList.add("§cOpen calendar for") + newList.add("§cmore exact data!") + } simpleDisplay = newList } + private fun isCloseToNewYear(): Boolean { + val now = SkyBlockTime.now() + val newYear = SkyBlockTime(year = now.year) + val nextYear = SkyBlockTime(year = now.year + 1) + val diffA = now.asTimeMark() - newYear.asTimeMark() + val diffB = nextYear.asTimeMark() - now.asTimeMark() + + return diffA < 30.minutes || diffB < 30.minutes + } + @SubscribeEvent fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return @@ -270,7 +288,11 @@ object GardenNextJacobContest { } if (contests.isEmpty()) { - list.add("§cOpen calendar to read jacob contest times!") + if (isCloseToNewYear()) { + list.add(closeToNewYear) + } else { + list.add("§cOpen calendar to read jacob contest times!") + } return list } @@ -280,8 +302,8 @@ object GardenNextJacobContest { // Show next contest if (nextContest != null) return drawNextContest(nextContest, list) - if (contests.size == maxContestsPerYear) { - list.add("§cNew SkyBlock Year! Open calendar again!") + if (isCloseToNewYear()) { + list.add(closeToNewYear) } else { list.add("§cOpen calendar to read jacob contest times!") } @@ -298,7 +320,7 @@ object GardenNextJacobContest { ): MutableList { var duration = nextContest.endTime.timeUntil() if (duration > 4.days) { - list.add("§New SB Year, wait a bit.") + list.add(closeToNewYear) return list } -- cgit