From 6e38916afbc66c8cc623f6d61b96101e64319c73 Mon Sep 17 00:00:00 2001
From: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Date: Sun, 24 Dec 2023 12:29:08 +0100
Subject: Fixed Jacob Contest Warning.
---
.../skyhanni/features/garden/GardenNextJacobContest.kt | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
(limited to 'src/main/java')
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 d62353f49..689c5d076 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
@@ -20,6 +20,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderSingleLineWithItems
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.asTimeMark
+import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.now
import at.hannibal2.skyhanni.utils.SoundUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
@@ -59,7 +60,7 @@ object GardenNextJacobContest {
private const val maxContestsPerYear = 124
private val contestDuration = 20.minutes
- private var lastWarningTime = 0L
+ private var lastWarningTime = SimpleTimeMark.farPast()
private var loadedContestsYear = -1
private var nextContestsAvailableAt = -1L
@@ -333,13 +334,13 @@ object GardenNextJacobContest {
} else {
list.add("§eNext: ")
duration -= contestDuration
- warn(duration, nextContest.crops, boostedCrop)
}
for (crop in nextContest.crops) {
list.add(" ")
list.addCropIcon(crop, highlight = (crop == boostedCrop))
nextContestCrops.add(crop)
}
+ warn(duration, nextContest.crops, boostedCrop)
val format = duration.format()
list.add("§7(§b$format§7)")
@@ -365,16 +366,18 @@ object GardenNextJacobContest {
if (config.warnTime.seconds <= duration) return
if (!warnForCrop()) return
- if (System.currentTimeMillis() < lastWarningTime) return
- lastWarningTime = System.currentTimeMillis() + 60_000 * 40
+ // Check that it only gets called once for the current event
+ if (lastWarningTime.passedSince() < config.warnTime.seconds) return
+ lastWarningTime = now()
val cropText = crops.joinToString("§7, ") { (if (it == boostedCrop) "§6" else "§a") + it.cropName }
LorenzUtils.chat("Next farming contest: $cropText")
LorenzUtils.sendTitle("§eFarming Contest!", 5.seconds)
SoundUtils.playBeepSound()
val cropTextNoColor = crops.joinToString(", ") {
- if (it == boostedCrop) "${it.cropName}" else it.cropName }
+ if (it == boostedCrop) "${it.cropName}" else it.cropName
+ }
if (config.warnPopup && !Display.isActive()) {
SkyHanniMod.coroutineScope.launch {
openPopupWindow(
@@ -455,6 +458,7 @@ object GardenNextJacobContest {
private fun isFetchEnabled() = isEnabled() && config.fetchAutomatically
private fun isSendEnabled() =
isFetchEnabled() && config.shareAutomatically != ShareContestsEntry.DISABLED
+
private fun askToSendContests() =
config.shareAutomatically == ShareContestsEntry.ASK // (Only call if isSendEnabled())
--
cgit