diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-05 16:50:24 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-05 16:50:24 +0100 |
commit | 95632c5677d51c351d20a900de0c9be15e17629b (patch) | |
tree | eb17cc34e6b0a717fc0889a9b6799e0fe35b0d72 /src/main/java/at/hannibal2 | |
parent | c4dfb229e7eaaffefe053afc90ac1371db24936e (diff) | |
download | skyhanni-95632c5677d51c351d20a900de0c9be15e17629b.tar.gz skyhanni-95632c5677d51c351d20a900de0c9be15e17629b.tar.bz2 skyhanni-95632c5677d51c351d20a900de0c9be15e17629b.zip |
show a text around new year that the calendar data are not loaded for the next contest.
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt | 34 |
1 files changed, 28 insertions, 6 deletions
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<String>() private var contests = mutableMapOf<SimpleTimeMark, FarmingContest>() private var inCalendar = false + private val patternDay = "§aDay (?<day>.*)".toPattern() private val patternMonth = "(?<month>.*), Year (?<year>.*)".toPattern() private val patternCrop = "§(e○|6☘) §7(?<crop>.*)".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<Any> { var duration = nextContest.endTime.timeUntil() if (duration > 4.days) { - list.add("§New SB Year, wait a bit.") + list.add(closeToNewYear) return list } |