aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt37
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()
}
}