diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-24 12:29:08 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-24 12:29:08 +0100 |
commit | 6e38916afbc66c8cc623f6d61b96101e64319c73 (patch) | |
tree | dea6868e79297ad6b7af3c95a10cd09d81c72604 /src/main/java/at/hannibal2 | |
parent | 871a604ac2916f63c38271e6d5c462ce656b2ba5 (diff) | |
download | skyhanni-6e38916afbc66c8cc623f6d61b96101e64319c73.tar.gz skyhanni-6e38916afbc66c8cc623f6d61b96101e64319c73.tar.bz2 skyhanni-6e38916afbc66c8cc623f6d61b96101e64319c73.zip |
Fixed Jacob Contest Warning.
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt | 14 |
1 files changed, 9 insertions, 5 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 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) "<b>${it.cropName}</b>" else it.cropName } + if (it == boostedCrop) "<b>${it.cropName}</b>" 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()) |