diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt | 63 |
1 files changed, 25 insertions, 38 deletions
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 7a91b8765..44fa5f7a1 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 @@ -147,8 +147,8 @@ object GardenCropMilestoneDisplay { private fun drawProgressDisplay(crop: CropType): List<Renderable> { val counter = crop.getCounter() - val lineMap = mutableMapOf<Int, Renderable>() - lineMap[0] = Renderable.string("§6Crop Milestones") + val lineMap = mutableMapOf<MilestoneTextEntry, Renderable>() + lineMap[MilestoneTextEntry.TITLE] = Renderable.string("§6Crop Milestones") val customTargetLevel = storage?.get(crop) ?: 0 val overflowDisplay = overflowConfig.cropMilestoneDisplay @@ -159,7 +159,7 @@ object GardenCropMilestoneDisplay { val useCustomGoal = customTargetLevel != 0 && customTargetLevel > currentTier nextTier = if (useCustomGoal) customTargetLevel else nextTier - lineMap[1] = Renderable.horizontalContainer(buildList { + lineMap[MilestoneTextEntry.MILESTONE_TIER] = Renderable.horizontalContainer(buildList { addCropIconRenderable(crop) if (crop.isMaxed(overflowDisplay) && !overflowDisplay) { addString("§7" + crop.cropName + " §eMAXED") @@ -179,7 +179,7 @@ object GardenCropMilestoneDisplay { Pair(have, need) } - lineMap[2] = if (crop.isMaxed(overflowDisplay) && !overflowDisplay) { + lineMap[MilestoneTextEntry.NUMBER_OUT_OF_TOTAL] = if (crop.isMaxed(overflowDisplay) && !overflowDisplay) { val haveFormat = counter.addSeparators() Renderable.string("§7Counter: §e$haveFormat") } else { @@ -205,22 +205,22 @@ object GardenCropMilestoneDisplay { tryWarn(millis, "§b${crop.cropName} $nextTier in $duration") val speedText = "§7In §b$duration" - lineMap[3] = Renderable.string(speedText) + lineMap[MilestoneTextEntry.TIME] = Renderable.string(speedText) GardenAPI.itemInHand?.let { if (GardenAPI.readCounter(it) == -1L) { - lineMap[3] = Renderable.string("$speedText §7Inaccurate!") + lineMap[MilestoneTextEntry.TIME] = Renderable.string("$speedText §7Inaccurate!") } } } val format = (farmingFortuneSpeed * 60).addSeparators() - lineMap[4] = Renderable.string("§7Crops/Minute§8: §e$format") + lineMap[MilestoneTextEntry.CROPS_PER_MINUTE] = Renderable.string("§7Crops/Minute§8: §e$format") val formatBps = speed.round(config.blocksBrokenPrecision).addSeparators() - lineMap[5] = Renderable.string("§7Blocks/Second§8: §e$formatBps") + lineMap[MilestoneTextEntry.BLOCKS_PER_SECOND] = Renderable.string("§7Blocks/Second§8: §e$formatBps") } val percentageFormat = LorenzUtils.formatPercentage(have.toDouble() / need.toDouble()) - lineMap[6] = if (crop.isMaxed(overflowDisplay) && !overflowDisplay) { + lineMap[MilestoneTextEntry.PERCENTAGE] = if (crop.isMaxed(overflowDisplay) && !overflowDisplay) { Renderable.string("§7Percentage: §e100%") } else { Renderable.string("§7Percentage: §e$percentageFormat") @@ -228,7 +228,8 @@ object GardenCropMilestoneDisplay { if (overflowConfig.chat) { if (currentTier >= 46 && currentTier == previousNext && - nextRealTier == currentTier + 1 && lastWarnedLevel != currentTier) { + nextRealTier == currentTier + 1 && lastWarnedLevel != currentTier + ) { GardenCropMilestones.onOverflowLevelUp(crop, currentTier - 1, nextRealTier - 1) lastWarnedLevel = currentTier } @@ -236,7 +237,8 @@ object GardenCropMilestoneDisplay { if (overflowConfig.chat) { if (currentTier >= 46 && currentTier == previousNext && - nextRealTier == currentTier + 1 && lastWarnedLevel != currentTier) { + nextRealTier == currentTier + 1 && lastWarnedLevel != currentTier + ) { GardenCropMilestones.onOverflowLevelUp(crop, currentTier - 1, nextRealTier - 1) lastWarnedLevel = currentTier } @@ -265,14 +267,9 @@ object GardenCropMilestoneDisplay { } } - private fun formatDisplay(lineMap: MutableMap<Int, Renderable>): List<Renderable> { + private fun formatDisplay(lineMap: MutableMap<MilestoneTextEntry, Renderable>): List<Renderable> { val newList = mutableListOf<Renderable>() - for (index in config.text) { - // TODO, change functionality to use enum rather than ordinals - lineMap[index.ordinal]?.let { - newList.add(it) - } - } + newList.addAll(config.text.mapNotNull { lineMap[it] }) if (needsInventory) { newList.addString("§cOpen §e/cropmilestones §cto update!") @@ -292,7 +289,7 @@ object GardenCropMilestoneDisplay { return } - val lineMap = HashMap<Int, Renderable>() + val lineMap = HashMap<MushroomTextEntry, Renderable>() val counter = mushroom.getCounter() val currentTier = GardenCropMilestones.getTierForCropCount(counter, mushroom, allowOverflow) @@ -309,15 +306,13 @@ object GardenCropMilestoneDisplay { val missing = need - have - lineMap[0] = Renderable.string("§6Mooshroom Cow Perk") - lineMap[1] = Renderable.horizontalContainer( - buildList { - addCropIconRenderable(mushroom) - addString("§7Mushroom Tier $nextTier") - } - ) + lineMap[MushroomTextEntry.TITLE] = Renderable.string("§6Mooshroom Cow Perk") + lineMap[MushroomTextEntry.MUSHROOM_TIER] = Renderable.horizontalContainer(buildList { + addCropIconRenderable(mushroom) + addString("§7Mushroom Tier $nextTier") + }) - lineMap[2] = Renderable.string("§e$haveFormat§8/§e$needFormat") + lineMap[MushroomTextEntry.NUMBER_OUT_OF_TOTAL] = Renderable.string("§e$haveFormat§8/§e$needFormat") val speed = GardenCropSpeed.averageBlocksPerSecond if (speed != 0.0) { @@ -328,27 +323,19 @@ object GardenCropMilestoneDisplay { // TODO, change functionality to use enum rather than ordinals val biggestUnit = TimeUnit.entries[config.highestTimeFormat.get().ordinal] val duration = TimeUtils.formatDuration(millis.toLong(), biggestUnit) - lineMap[3] = Renderable.string("§7In §b$duration") + lineMap[MushroomTextEntry.TIME] = Renderable.string("§7In §b$duration") } val percentageFormat = LorenzUtils.formatPercentage(have.toDouble() / need.toDouble()) - lineMap[4] = Renderable.string("§7Percentage: §e$percentageFormat") + lineMap[MushroomTextEntry.PERCENTAGE] = Renderable.string("§7Percentage: §e$percentageFormat") if (currentTier >= 46 && currentTier == previousMushNext && nextTier == currentTier + 1 && lastMushWarnedLevel != currentTier) { GardenCropMilestones.onOverflowLevelUp(mushroom, currentTier - 1, nextTier - 1) lastMushWarnedLevel = currentTier } - val newList = mutableListOf<Renderable>() - for (index in config.mushroomPetPerk.text) { - // TODO, change functionality to use enum rather than ordinals - lineMap[index.ordinal]?.let { - newList.add(it) - } - } - previousMushNext = nextTier - mushroomCowPerkDisplay = newList + mushroomCowPerkDisplay = config.mushroomPetPerk.text.mapNotNull { lineMap[it] } } private fun isEnabled() = GardenAPI.inGarden() && config.progress |