diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-04-04 18:59:20 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-04-04 18:59:20 +0200 |
commit | b1be5758a2543df639c427038b61a86ea0e0cae6 (patch) | |
tree | 775d18f1c3c9a2f0c01e7dfee610673b67b0a966 /src | |
parent | 953682bd6b0c43b6caa9327b97eedaa1c31dcc82 (diff) | |
download | skyhanni-b1be5758a2543df639c427038b61a86ea0e0cae6.tar.gz skyhanni-b1be5758a2543df639c427038b61a86ea0e0cae6.tar.bz2 skyhanni-b1be5758a2543df639c427038b61a86ea0e0cae6.zip |
Added Best Crop Time Compact Display - Make the best crop time more compact by removing the crop name and exp and making the time format shorter
Diffstat (limited to 'src')
3 files changed, 26 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java index e48d0eee7..74b874186 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -258,6 +258,14 @@ public class Garden { public boolean cropMilestoneBestAlwaysOn = false; @Expose + @ConfigOption( + name = "Compact Display", + desc = "Make the best crop time more compact by removing the crop name and exp and making the time format shorter") + @ConfigEditorBoolean + @ConfigAccordionId(id = 7) + public boolean cropMilestoneBestCompact = false; + + @Expose public Position cropMilestoneNextDisplayPos = new Position(-112, -143, false, true); @Expose 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 139573899..003bcde11 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt @@ -34,7 +34,11 @@ class GardenBestCropTime { } val title = if (gardenExp) "§2Garden Experience" else "§bSkyBlock Level" - newList.addAsSingletonList("§eBest Crop Time §7($title§7)") + if (config.cropMilestoneBestCompact) { + newList.addAsSingletonList("§eBest Crop Time") + } else { + newList.addAsSingletonList("§eBest Crop Time §7($title§7)") + } if (sorted.isEmpty()) { newList.addAsSingletonList("§cFarm crops to add them to this list!") @@ -44,7 +48,8 @@ class GardenBestCropTime { var number = 0 for (crop in sorted.keys) { val millis = timeTillNextCrop[crop]!! - val duration = TimeUtils.formatDuration(millis) + val maxUnits = if (config.cropMilestoneBestCompact) 2 else -1 + val duration = TimeUtils.formatDuration(millis, maxUnits = maxUnits) val isCurrent = crop == currentCrop number++ if (number > config.cropMilestoneShowOnlyBest && !isCurrent) continue @@ -56,10 +61,12 @@ class GardenBestCropTime { val color = if (isCurrent) "§e" else "§7" val contestFormat = if (GardenNextJacobContest.isNextCrop(crop)) "§n" else "" val nextTier = GardenCropMilestones.getTierForCrops(crop.getCounter()) + 1 - val cropNameDisplay = "$color$contestFormat${crop.cropName} $nextTier§r" + + val cropName = if (!config.cropMilestoneBestCompact) crop.cropName +" " else "" + val cropNameDisplay = "$color$contestFormat$cropName$nextTier§r" list.add("$cropNameDisplay §b$duration") - if (gardenExp) { + if (gardenExp && !config.cropMilestoneBestCompact) { val gardenExpForTier = getGardenExpForTier(nextTier) list.add(" §7(§2$gardenExpForTier §7Exp)") } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt index 0e4561041..1491662c1 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt @@ -12,6 +12,7 @@ object TimeUtils { biggestUnit: TimeUnit = TimeUnit.YEAR, showMilliSeconds: Boolean = false, longName: Boolean = false, + maxUnits: Int = -1 ): String { var milliseconds = millis + 999 val map = mutableMapOf<TimeUnit, Int>() @@ -24,6 +25,7 @@ object TimeUtils { } val builder = StringBuilder() + var count = 0 for ((unit, value) in map.entries) { if (value > 0 || builder.isNotEmpty() || unit == TimeUnit.SECOND) { builder.append(value) @@ -43,6 +45,11 @@ object TimeUtils { } else { builder.append("$name ") } + + count++ + if (maxUnits != -1) { + if (count == maxUnits) break + } } } return builder.toString() |