From ebd27f0e6eb1e380dc8711c258ecab4b431ba901 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 16 Mar 2023 12:02:09 +0100 Subject: Money per hour display now shows a loading screen for the first seconds instead of nothing --- .../skyhanni/features/garden/CropMoneyDisplay.kt | 57 ++++++++++++++-------- 1 file changed, 37 insertions(+), 20 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni') 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 bc440cf6a..fcfaceae4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt @@ -57,6 +57,12 @@ class CropMoneyDisplay { val newDisplay = drawNewDisplay() display.clear() display.addAll(newDisplay) + } else { + val newDisplay = mutableListOf>() + newDisplay.add(Collections.singletonList("§7Money per hour when selling:")) + newDisplay.add(Collections.singletonList("§eLoading...")) + display.clear() + display.addAll(newDisplay) } } @@ -68,27 +74,32 @@ class CropMoneyDisplay { newDisplay.add(Collections.singletonList("§7Money per hour when selling:")) var number = 0 - for ((internalName, moneyPerHour) in calculateMoneyPerHour().sortedDesc()) { - number++ - val cropName = cropNames[internalName] - val isCurrent = cropName == GardenAPI.cropInHand - if (number > config.moneyPerHourShowOnlyBest && !isCurrent) continue - - val list = mutableListOf() - list.add("§7$number# ") - - try { - val itemStack = NEUItems.getItemStack(internalName) - list.add(itemStack) - } catch (e: NullPointerException) { - e.printStackTrace() - } - val format = LorenzUtils.formatInteger(moneyPerHour.toLong()) - val itemName = NEUItems.getItemStack(internalName).name?.removeColor() ?: continue - val color = if (isCurrent) "§e" else "§7" - list.add("$color$itemName§7: §6$format") + 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() + list.add("§7$number# ") + + try { + val itemStack = NEUItems.getItemStack(internalName) + list.add(itemStack) + } catch (e: NullPointerException) { + e.printStackTrace() + } + val format = LorenzUtils.formatInteger(moneyPerHour.toLong()) + val itemName = NEUItems.getItemStack(internalName).name?.removeColor() ?: continue + val color = if (isCurrent) "§e" else "§7" + list.add("$color$itemName§7: §6$format") - newDisplay.add(list) + newDisplay.add(list) + } } return newDisplay @@ -117,6 +128,12 @@ class CropMoneyDisplay { private fun init() { if (loaded) return + + if (BazaarApi.bazaarMap.isEmpty()) { + LorenzUtils.debug("bz not ready for money/time!") + return + } + loaded = true SkyHanniMod.coroutineScope.launch { -- cgit