aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/garden
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-09-30 09:51:38 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-09-30 09:51:38 +0200
commit268b9a75050bffcbea90f8f89ab54006de832dc1 (patch)
tree95f54dd2d6523213311c418d6c93c358fac8fd8e /src/main/java/at/hannibal2/skyhanni/features/garden
parent88a1b28473aa0c87c69f5c0d577a1c9393a65b03 (diff)
downloadskyhanni-268b9a75050bffcbea90f8f89ab54006de832dc1.tar.gz
skyhanni-268b9a75050bffcbea90f8f89ab54006de832dc1.tar.bz2
skyhanni-268b9a75050bffcbea90f8f89ab54006de832dc1.zip
Workaround for wrong contest times.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/garden')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt
index a39efa894..8d7e1eae1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt
@@ -11,10 +11,12 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import io.github.moulberry.notenoughupdates.util.SkyBlockTime
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import kotlin.time.Duration.Companion.minutes
object FarmingContestAPI {
private val timePattern = "§a(?<month>.*) (?<day>.*)(?:rd|st|nd|th), Year (?<year>.*)".toPattern()
@@ -22,6 +24,7 @@ object FarmingContestAPI {
private val cropPattern = "§8(?<crop>.*) Contest".toPattern()
var inContest = false
var contestCrop: CropType? = null
+ private var startTime = SimpleTimeMark.farPast()
private val sidebarCropPattern = "§e○ §f(?<crop>.*) §a.*".toPattern()
var inInventory = false
@@ -37,19 +40,30 @@ object FarmingContestAPI {
}
private fun checkActiveContest() {
+ if (inContest) {
+ if (startTime.passedSince() > 20.minutes) {
+ FarmingContestEvent(contestCrop!!, FarmingContestPhase.STOP).postAndCatch()
+ inContest = false
+ }
+ }
+
val currentCrop = readCurrentCrop()
val currentContest = currentCrop != null
if (inContest != currentContest) {
if (currentContest) {
FarmingContestEvent(currentCrop!!, FarmingContestPhase.START).postAndCatch()
+ startTime = SimpleTimeMark.now()
} else {
- FarmingContestEvent(contestCrop!!, FarmingContestPhase.STOP).postAndCatch()
+ if (startTime.passedSince() > 2.minutes) {
+ FarmingContestEvent(contestCrop!!, FarmingContestPhase.STOP).postAndCatch()
+ }
}
inContest = currentContest
} else {
if (currentCrop != contestCrop) {
FarmingContestEvent(currentCrop!!, FarmingContestPhase.CHANGE).postAndCatch()
+ startTime = SimpleTimeMark.now()
}
}
contestCrop = currentCrop