aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-05-06 17:30:50 +0200
committerGitHub <noreply@github.com>2024-05-06 17:30:50 +0200
commit026bd1c14fb5ee90ba8b828b843d1a048dc9c838 (patch)
tree707355e323857a8c22df53092fff7580b56eb75a /src/main
parent82370ca380c81aa06aa10aef483147778be15253 (diff)
downloadskyhanni-026bd1c14fb5ee90ba8b828b843d1a048dc9c838.tar.gz
skyhanni-026bd1c14fb5ee90ba8b828b843d1a048dc9c838.tar.bz2
skyhanni-026bd1c14fb5ee90ba8b828b843d1a048dc9c838.zip
Backend: Enum in GardenCropMilestoneDisplay (#1535)
Co-authored-by: HiZe <superhize@hotmail.com> Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Co-authored-by: alexia <me@alexia.lol> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt63
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