From 5e273444ac192d1e10c48618de72c517c6b52c45 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 29 Apr 2023 15:42:01 +0200 Subject: Using tab list correctly when farming without cultivating --- .../skyhanni/features/garden/GardenCropMilestoneFix.kt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features/garden') diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt index 3539e40af..8fdec3787 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getCounter import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.setCounter import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent +import at.hannibal2.skyhanni.features.garden.farming.GardenCropMilestoneDisplay import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNeeded @@ -27,7 +28,7 @@ class GardenCropMilestoneFix { val tier = group("tier").romanToDecimalIfNeeded() val crops = GardenCropMilestones.getCropsForTier(tier) - changedValue(crop, crops, "level up chat message") + changedValue(crop, crops, "level up chat message", 0) } } @@ -64,7 +65,7 @@ class GardenCropMilestoneFix { val newValue = tabListValue.toLong() if (tabListCropProgress[crop] != newValue) { if (tabListCropProgress.containsKey(crop)) { - changedValue(crop, newValue, "tab list") + changedValue(crop, newValue, "tab list", smallestPercentage.toInt()) } } tabListCropProgress[crop] = newValue @@ -72,19 +73,21 @@ class GardenCropMilestoneFix { private val loadedCrops = mutableListOf() - private fun changedValue(crop: CropType, tabListValue: Long, source: String) { + private fun changedValue(crop: CropType, tabListValue: Long, source: String, minDiff: Int) { val calculated = crop.getCounter() val diff = calculated - tabListValue - if (diff < -5_000) { + + if (diff <= -minDiff) { crop.setCounter(tabListValue) + GardenCropMilestoneDisplay.update() if (!loadedCrops.contains(crop)) { LorenzUtils.chat("§e[SkyHanni] Loaded ${crop.cropName} milestone data from $source!") loadedCrops.add(crop) } - } - if (diff > 5_000) { + } else if (diff >= minDiff) { LorenzUtils.debug("Fixed wrong ${crop.cropName} milestone data from $source: ${diff.addSeparators()}") crop.setCounter(tabListValue) + GardenCropMilestoneDisplay.update() } } } \ No newline at end of file -- cgit