diff options
Diffstat (limited to 'src/main/java/at')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt | 57 |
1 files changed, 37 insertions, 20 deletions
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<List<Any>>() + 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<Any>() - 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<Any>() + 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 { |