diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-06-05 23:58:01 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-06-05 23:58:15 +0200 |
commit | c66f76a618b5a25f92767ed36fda254d81c302ff (patch) | |
tree | 3f3a9f0904c2d3b28d89e1b43573b40ee0699e6b /src/main/java/at/hannibal2/skyhanni/features | |
parent | 22002f2df339e794b86871850354fdb211176401 (diff) | |
download | skyhanni-c66f76a618b5a25f92767ed36fda254d81c302ff.tar.gz skyhanni-c66f76a618b5a25f92767ed36fda254d81c302ff.tar.bz2 skyhanni-c66f76a618b5a25f92767ed36fda254d81c302ff.zip |
Added support for maxed out crop milestones
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt | 10 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt | 52 |
2 files changed, 42 insertions, 20 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt index 0c8c83c3e..d722658b1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.garden.farming import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.GardenCropMilestones import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getCounter +import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.isMaxed import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIcon import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest @@ -27,6 +28,7 @@ class GardenBestCropTime { fun updateTimeTillNextCrop() { for (crop in CropType.values()) { val speed = crop.getSpeed() ?: continue + if (crop.isMaxed()) continue val counter = crop.getCounter() val currentTier = GardenCropMilestones.getTierForCrops(counter) @@ -55,11 +57,12 @@ class GardenBestCropTime { val gardenExp = config.cropMilestoneBestType == 0 val sorted = if (gardenExp) { val helpMap = mutableMapOf<CropType, Long>() - for ((cropName, time) in timeTillNextCrop) { - val currentTier = GardenCropMilestones.getTierForCrops(cropName.getCounter()) + for ((crop, time) in timeTillNextCrop) { + if (crop.isMaxed()) continue + val currentTier = GardenCropMilestones.getTierForCrops(crop.getCounter()) val gardenExpForTier = getGardenExpForTier(currentTier + 1) val fakeTime = time / gardenExpForTier - helpMap[cropName] = fakeTime + helpMap[crop] = fakeTime } helpMap.sorted() } else { @@ -88,6 +91,7 @@ class GardenBestCropTime { var number = 0 for (crop in sorted.keys) { + if (crop.isMaxed()) continue val millis = timeTillNextCrop[crop]!! val biggestUnit = TimeUnit.values()[config.cropMilestoneHighestTimeFormat.get()] val duration = TimeUtils.formatDuration(millis, biggestUnit, maxUnits = 2) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt index 8778ca04e..b4e7846d9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.garden.farming import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.GardenCropMilestones import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getCounter +import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.isMaxed import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.setCounter import at.hannibal2.skyhanni.data.TitleUtils import at.hannibal2.skyhanni.events.* @@ -144,7 +145,11 @@ object GardenCropMilestoneDisplay { val list = mutableListOf<Any>() list.addCropIcon(crop) - list.add("§7" + crop.cropName + " $currentTier➜$nextTier") + if (crop.isMaxed()) { + list.add("§7" + crop.cropName + " §eMAXED") + } else { + list.add("§7" + crop.cropName + " $currentTier➜$nextTier") + } lineMap[1] = list val cropsForNextTier = GardenCropMilestones.getCropsForTier(nextTier) @@ -157,9 +162,14 @@ object GardenCropMilestoneDisplay { Pair(have, need) } - val haveFormat = LorenzUtils.formatInteger(have) - val needFormat = LorenzUtils.formatInteger(need) - lineMap[2] = Collections.singletonList("§e$haveFormat§8/§e$needFormat") + lineMap[2] = if (crop.isMaxed()) { + val haveFormat = LorenzUtils.formatInteger(counter) + Collections.singletonList("§7Counter: §e$haveFormat") + } else { + val haveFormat = LorenzUtils.formatInteger(have) + val needFormat = LorenzUtils.formatInteger(need) + Collections.singletonList("§e$haveFormat§8/§e$needFormat") + } val farmingFortune = FarmingFortuneDisplay.getCurrentFarmingFortune(true) val speed = GardenCropSpeed.averageBlocksPerSecond @@ -167,18 +177,22 @@ object GardenCropMilestoneDisplay { if (farmingFortuneSpeed > 0) { crop.setSpeed(farmingFortuneSpeed) - val missing = need - have - val missingTimeSeconds = missing / farmingFortuneSpeed - val millis = missingTimeSeconds * 1000 - GardenBestCropTime.timeTillNextCrop[crop] = millis - val biggestUnit = TimeUnit.values()[config.cropMilestoneHighestTimeFormat.get()] - val duration = TimeUtils.formatDuration(millis, biggestUnit) - tryWarn(millis, "§b${crop.cropName} $nextTier in $duration") - val speedText = "§7In §b$duration" - lineMap[3] = Collections.singletonList(speedText) - GardenAPI.itemInHand?.let { - if (GardenAPI.readCounter(it) == -1L) { - lineMap[3] = listOf(speedText, " §7Inaccurate!") + if (crop.isMaxed()) { + lineMap[3] = listOf("§7In §bMaxed") + } else { + val missing = need - have + val missingTimeSeconds = missing / farmingFortuneSpeed + val millis = missingTimeSeconds * 1000 + GardenBestCropTime.timeTillNextCrop[crop] = millis + val biggestUnit = TimeUnit.values()[config.cropMilestoneHighestTimeFormat.get()] + val duration = TimeUtils.formatDuration(millis, biggestUnit) + tryWarn(millis, "§b${crop.cropName} $nextTier in $duration") + val speedText = "§7In §b$duration" + lineMap[3] = Collections.singletonList(speedText) + GardenAPI.itemInHand?.let { + if (GardenAPI.readCounter(it) == -1L) { + lineMap[3] = listOf(speedText, " §7Inaccurate!") + } } } @@ -189,7 +203,11 @@ object GardenCropMilestoneDisplay { } val percentageFormat = LorenzUtils.formatPercentage(have.toDouble() / need.toDouble()) - lineMap[6] = Collections.singletonList("§7Percentage: §e$percentageFormat") + lineMap[6] = if (crop.isMaxed()) { + Collections.singletonList("§7Percentage: §e100%") + } else { + Collections.singletonList("§7Percentage: §e$percentageFormat") + } if (GardenAPI.mushroomCowPet && crop != CropType.MUSHROOM) { addMushroomCowData() |