diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-16 12:02:09 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-16 12:02:09 +0100 |
commit | ebd27f0e6eb1e380dc8711c258ecab4b431ba901 (patch) | |
tree | 80544200e2d6f17ced0fded212e8c27b6bdfe580 /src/main/java | |
parent | b07bde470f76c20b0eeeaa1cb96d4bb5e423c09e (diff) | |
download | skyhanni-ebd27f0e6eb1e380dc8711c258ecab4b431ba901.tar.gz skyhanni-ebd27f0e6eb1e380dc8711c258ecab4b431ba901.tar.bz2 skyhanni-ebd27f0e6eb1e380dc8711c258ecab4b431ba901.zip |
Money per hour display now shows a loading screen for the first seconds instead of nothing
Diffstat (limited to 'src/main/java')
-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 { |