diff options
Diffstat (limited to 'src')
3 files changed, 13 insertions, 17 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt index ba0d8d863..984c60df7 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt @@ -78,6 +78,8 @@ class GardenCropMilestones { companion object { val cropCounter: MutableMap<CropType, Long> get() = SkyHanniMod.feature.hidden.gardenCropCounter + fun CropType.getCounter() = cropCounter[this]!! + fun getTierForCrops(crops: Long): Int { var tier = 0 var totalCrops = 0L diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt index 976994070..7e2619be1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.GardenCropMilestones +import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getCounter import at.hannibal2.skyhanni.utils.LorenzUtils.sorted import at.hannibal2.skyhanni.utils.TimeUtils import java.util.* @@ -20,8 +21,7 @@ class GardenBestCropTime { val sorted = if (gardenExp) { val helpMap = mutableMapOf<CropType, Long>() for ((cropName, time) in timeTillNextCrop) { - val crops = GardenCropMilestones.cropCounter[cropName]!! - val currentTier = GardenCropMilestones.getTierForCrops(crops) + val currentTier = GardenCropMilestones.getTierForCrops(cropName.getCounter()) val gardenExpForTier = getGardenExpForTier(currentTier + 1) val fakeTime = time / gardenExpForTier helpMap[cropName] = fakeTime @@ -52,8 +52,7 @@ class GardenBestCropTime { val color = if (isCurrent) "§e" else "§7" val contestFormat = if (GardenNextJacobContest.isNextCrop(crop)) "§n" else "" - val crops = GardenCropMilestones.cropCounter[crop]!! - val nextTier = GardenCropMilestones.getTierForCrops(crops) + 1 + val nextTier = GardenCropMilestones.getTierForCrops(crop.getCounter()) + 1 val cropNameDisplay = "$color$contestFormat${crop.cropName} $nextTier§r" list.add("$cropNameDisplay §b$duration") @@ -68,23 +67,23 @@ class GardenBestCropTime { private fun getGardenExpForTier(gardenLevel: Int) = if (gardenLevel > 30) 300 else gardenLevel * 10 fun updateTimeTillNextCrop() { - for ((cropName, speed) in GardenAPI.cropsPerSecond) { + for ((crop, speed) in GardenAPI.cropsPerSecond) { if (speed == -1) continue - val crops = GardenCropMilestones.cropCounter[cropName]!! - val currentTier = GardenCropMilestones.getTierForCrops(crops) + val counter = crop.getCounter() + val currentTier = GardenCropMilestones.getTierForCrops(counter) val cropsForCurrentTier = GardenCropMilestones.getCropsForTier(currentTier) val nextTier = currentTier + 1 val cropsForNextTier = GardenCropMilestones.getCropsForTier(nextTier) - val have = crops - cropsForCurrentTier + val have = counter - cropsForCurrentTier val need = cropsForNextTier - cropsForCurrentTier val missing = need - have val missingTimeSeconds = missing / speed val millis = missingTimeSeconds * 1000 - timeTillNextCrop[cropName] = millis + timeTillNextCrop[crop] = millis } } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt index cd23fc64b..a52e474ff 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.GardenCropMilestones +import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getCounter import at.hannibal2.skyhanni.data.SendTitleHelper import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.utils.LorenzUtils @@ -84,7 +85,7 @@ class GardenCropMilestoneDisplay { val old = cultivatingData[crop]!! val diff = counter - old try { - GardenCropMilestones.cropCounter[crop] = GardenCropMilestones.cropCounter[crop]!! + diff + GardenCropMilestones.cropCounter[crop] = crop.getCounter() + diff } catch (e: NullPointerException) { println("crop: '$crop'") println("GardenCropMilestones.cropCounter: '${GardenCropMilestones.cropCounter.keys}'") @@ -148,13 +149,7 @@ class GardenCropMilestoneDisplay { progressDisplay.clear() bestCropTime.display.clear() currentCrop?.let { - val crops = GardenCropMilestones.cropCounter[it] - if (crops == null) { - println("cropCounter is null for '$it'") - return - } - - drawProgressDisplay(it, crops) + drawProgressDisplay(it, it.getCounter()) if (config.cropMilestoneBestDisplay) { bestCropTime.drawBestDisplay(it) } |