diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-05-18 19:51:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-18 19:51:22 +0200 |
commit | b5b29450446248337a08ed358169e69faebba5c1 (patch) | |
tree | b91113853451d713ee1138987766b0a687ad62aa | |
parent | 6ee6072c64959811a389bafc23142663b06b7dce (diff) | |
download | skyhanni-b5b29450446248337a08ed358169e69faebba5c1.tar.gz skyhanni-b5b29450446248337a08ed358169e69faebba5c1.tar.bz2 skyhanni-b5b29450446248337a08ed358169e69faebba5c1.zip |
Fix: Farming Contest bugs (#1829)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt | 33 |
1 files changed, 20 insertions, 13 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 fb82c8be9..9b866bd3f 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 @@ -1,10 +1,11 @@ package at.hannibal2.skyhanni.features.garden.contest +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.events.FarmingContestEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut @@ -12,6 +13,7 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.isAnyOf import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SkyBlockTime @@ -39,7 +41,13 @@ object FarmingContestAPI { ) private val contests = mutableMapOf<Long, FarmingContest>() - var inContest = false + private var internalContest = false + val inContest + get() = internalContest && LorenzUtils.skyBlockIsland.isAnyOf( + IslandType.GARDEN, + IslandType.HUB, + IslandType.THE_FARMING_ISLANDS + ) var contestCrop: CropType? = null private var startTime = SimpleTimeMark.farPast() var inInventory = false @@ -49,21 +57,20 @@ object FarmingContestAPI { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { - if (event.repeatSeconds(1)) { - if (!LorenzUtils.inSkyBlock) return - if (!GardenAPI.inGarden()) return + fun onSecondPassed(event: SecondPassedEvent) { + if (!LorenzUtils.inSkyBlock) return - checkActiveContest() + if (internalContest && startTime.passedSince() > 20.minutes) { + FarmingContestEvent(contestCrop!!, FarmingContestPhase.STOP).postAndCatch() + internalContest = false } + + if (!GardenAPI.inGarden()) return + + checkActiveContest() } private fun checkActiveContest() { - if (inContest && startTime.passedSince() > 20.minutes) { - FarmingContestEvent(contestCrop!!, FarmingContestPhase.STOP).postAndCatch() - inContest = false - } - val currentCrop = readCurrentCrop() val currentContest = currentCrop != null @@ -76,7 +83,7 @@ object FarmingContestAPI { FarmingContestEvent(contestCrop!!, FarmingContestPhase.STOP).postAndCatch() } } - inContest = currentContest + internalContest = currentContest } else { if (currentCrop != contestCrop && currentCrop != null) { FarmingContestEvent(currentCrop, FarmingContestPhase.CHANGE).postAndCatch() |