diff options
author | Empa <42304516+ItsEmpa@users.noreply.github.com> | 2024-05-13 18:13:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-13 18:13:10 +0200 |
commit | 32a6b798111dac52fdcf94532bc268a1235b5be0 (patch) | |
tree | 0b04d118e53269f592e0c7a67d9cecc1e1f3378f /src/main/java/at/hannibal2/skyhanni/features/garden | |
parent | 8e2d5c04573a3f57c9200786a039ecc73ad78863 (diff) | |
download | skyhanni-32a6b798111dac52fdcf94532bc268a1235b5be0.tar.gz skyhanni-32a6b798111dac52fdcf94532bc268a1235b5be0.tar.bz2 skyhanni-32a6b798111dac52fdcf94532bc268a1235b5be0.zip |
Improvement: Fixpests delay (#1764)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/garden')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt index 1351ab5bd..1d1c4e0b6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt @@ -121,28 +121,27 @@ object PestAPI { var firstScoreboardCheck = false private fun fixPests(loop: Int = 2) { - val accurateAmount = getPlotsWithAccuratePests().sumOf { it.pests } - val inaccurateAmount = getPlotsWithInaccuratePests().size - if (scoreboardPests == accurateAmount + inaccurateAmount) { // if we can assume all inaccurate plots have 1 pest each - for (plot in getPlotsWithInaccuratePests()) { - plot.pests = 1 + DelayedRun.runDelayed(2.seconds) { + val accurateAmount = getPlotsWithAccuratePests().sumOf { it.pests } + val inaccurateAmount = getPlotsWithInaccuratePests().size + if (scoreboardPests == accurateAmount + inaccurateAmount) { // if we can assume all inaccurate plots have 1 pest each + for (plot in getPlotsWithInaccuratePests()) { + plot.pests = 1 + plot.isPestCountInaccurate = false + } + } else if (inaccurateAmount == 1) { // if we can assume all the inaccurate pests are in the only inaccurate plot + val plot = getPlotsWithInaccuratePests().firstOrNull() ?: return@runDelayed + plot.pests = scoreboardPests - accurateAmount plot.isPestCountInaccurate = false - } - } else if (inaccurateAmount == 1) { // if we can assume all the inaccurate pests are in the only inaccurate plot - val plot = getPlotsWithInaccuratePests().firstOrNull() ?: return - plot.pests = scoreboardPests - accurateAmount - plot.isPestCountInaccurate = false - } else if (accurateAmount + inaccurateAmount > scoreboardPests) { // when logic fails and we reach impossible pest counts - getInfestedPlots().forEach { - it.pests = 0 - it.isPestCountInaccurate = true - } - if (loop > 0) { - DelayedRun.runDelayed(2.seconds) { - fixPests(loop - 1) + } else if (accurateAmount + inaccurateAmount > scoreboardPests) { // when logic fails and we reach impossible pest counts + getInfestedPlots().forEach { + it.pests = 0 + it.isPestCountInaccurate = true } + if (loop > 0) { + fixPests(loop - 1) + } else sendPestError() } - else sendPestError() } } |