diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-23 16:01:12 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-23 16:01:12 +0100 |
commit | 2a117487b3dc798a496bf3a2fc93c0a75808c18b (patch) | |
tree | 2b6ba0738ed5a3ee7217e3e6140ee09c52b89f64 /src/main/java/at/hannibal2/skyhanni | |
parent | 53303c391dc335bc676263f5be75bcc110a74446 (diff) | |
download | skyhanni-2a117487b3dc798a496bf3a2fc93c0a75808c18b.tar.gz skyhanni-2a117487b3dc798a496bf3a2fc93c0a75808c18b.tar.bz2 skyhanni-2a117487b3dc798a496bf3a2fc93c0a75808c18b.zip |
Added Compact Display. Once again hopefully fixing money per hour
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
3 files changed, 50 insertions, 40 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 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<List<Any>> { + private fun drawDisplay(): MutableList<List<Any>> { val newDisplay = mutableListOf<List<Any>>() - + 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<Any>() + 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<Any>() + 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<String, Double> { + private fun calculateMoneyPerHour(): Map<String, Double> { val moneyPerHours = mutableMapOf<String, Double>() 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 |