From 2a117487b3dc798a496bf3a2fc93c0a75808c18b Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 23 Mar 2023 16:01:12 +0100 Subject: Added Compact Display. Once again hopefully fixing money per hour --- .../hannibal2/skyhanni/config/features/Garden.java | 7 ++ .../skyhanni/features/garden/CropMoneyDisplay.kt | 81 +++++++++++----------- .../skyhanni/features/garden/GardenAPI.kt | 2 + 3 files changed, 50 insertions(+), 40 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni') 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 70e9907a9..81589a877 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -406,6 +406,13 @@ public class Garden { @ConfigEditorBoolean @ConfigAccordionId(id = 13) public boolean moneyPerHourAlwaysOn = false; + @Expose + @ConfigOption( + name = "Compact Display", + desc = "Hide the item name and the position number.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 13) + public boolean moneyPerHourCompact = false; @Expose @ConfigOption(name = "Money per hour Position", desc = "") diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt index d0d5d64f2..08d9ebee5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt @@ -52,56 +52,69 @@ class CropMoneyDisplay { private fun update() { init() - display = drawNewDisplay() + display = drawDisplay() } - private fun drawNewDisplay(): MutableList> { + private fun drawDisplay(): MutableList> { val newDisplay = mutableListOf>() - + newDisplay.add(Collections.singletonList("§7Money per hour when selling:")) if (!ready) { - newDisplay.add(Collections.singletonList("§7Money per hour when selling:")) newDisplay.add(Collections.singletonList("§eLoading...")) return newDisplay } if (!hasCropInHand && !config.moneyPerHourAlwaysOn) return newDisplay - newDisplay.add(Collections.singletonList("§7Money per hour when selling:")) + val moneyPerHourData = calculateMoneyPerHour() + if (moneyPerHourData.isEmpty()) { + if (!GardenAPI.isSpeedDataEmpty()) { + val message = "money/hr empty but speed data not empty, retry" + LorenzUtils.debug(message) + println(message) + newDisplay.add(Collections.singletonList("§eStill Loading...")) + ready = false + loaded = false + return newDisplay + } + newDisplay.add(Collections.singletonList("§cFarm crops to add them to this list!")) + return newDisplay + } var number = 0 - val map = calculateMoneyPerHour() - if (map.isEmpty()) { - newDisplay.add(Collections.singletonList("§cFarm crops to add them to this list!")) - } else { - for ((internalName, moneyPerHour) in map.sortedDesc()) { - number++ - val cropName = cropNames[internalName]!! - val isCurrent = cropName == GardenAPI.cropInHand - if (number > config.moneyPerHourShowOnlyBest && !isCurrent) continue - - val list = mutableListOf() + for ((internalName, moneyPerHour) in moneyPerHourData.sortedDesc()) { + number++ + val cropName = cropNames[internalName]!! + val isCurrent = cropName == GardenAPI.cropInHand + if (number > config.moneyPerHourShowOnlyBest && !isCurrent) continue + + val list = mutableListOf() + if (!config.moneyPerHourCompact) { list.add("§7$number# ") + } - try { - val itemStack = NEUItems.getItemStack(internalName) - list.add(itemStack) - } catch (e: NullPointerException) { - e.printStackTrace() - } - val format = LorenzUtils.formatInteger(moneyPerHour.toLong()) + try { + list.add(NEUItems.getItemStack(internalName)) + } catch (e: NullPointerException) { + e.printStackTrace() + } + + if (!config.moneyPerHourCompact) { val itemName = NEUItems.getItemStack(internalName).name?.removeColor() ?: continue - val color = if (isCurrent) "§e" else "§7" + val currentColor = if (isCurrent) "§e" else "§7" val contestFormat = if (GardenNextJacobContest.isNextCrop(cropName)) "§n" else "" - list.add("$color$contestFormat$itemName§7: §6$format") - - newDisplay.add(list) + list.add("$currentColor$contestFormat$itemName§7:") } + + val format = LorenzUtils.formatInteger(moneyPerHour.toLong()) + list.add(" §6$format") + + newDisplay.add(list) } return newDisplay } - private fun calculateMoneyPerHour(): MutableMap { + private fun calculateMoneyPerHour(): Map { val moneyPerHours = mutableMapOf() for ((internalName, amount) in multipliers) { val price = NEUItems.getPrice(internalName) @@ -132,18 +145,6 @@ class CropMoneyDisplay { loaded = true SkyHanniMod.coroutineScope.launch { - val crops = listOf( - "Wheat", - "Carrot", - "Potato", - "Pumpkin", - "Sugar Cane", - "Melon", - "Cactus", - "Cocoa Beans", - "Mushroom", - "Nether Wart", - ) for ((internalName, _) in NotEnoughUpdates.INSTANCE.manager.itemInformation) { if (!BazaarApi.isBazaarItem(internalName)) continue diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt index 8ca84f684..fafdbe700 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -127,5 +127,7 @@ class GardenAPI { e.printStackTrace() } } + + fun isSpeedDataEmpty() = cropsPerSecond.values.sum() < 0 } } \ No newline at end of file -- cgit