From 3378a4127449f980b634b584cb67fc24821a8457 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 6 Jan 2024 10:39:10 +0100 Subject: Show error message for the commands /shcropsin and /shcroptime if show money per hour display is not loaded. --- .../hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt | 7 ++++++- .../at/hannibal2/skyhanni/features/garden/GardenCropsInCommand.kt | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt index 9739ece50..6629f1b00 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt @@ -32,12 +32,17 @@ object GardenCropTimeCommand { LorenzUtils.userError("Not a valid number: '$rawAmount'") return } + val multipliers = CropMoneyDisplay.multipliers + if (multipliers.isEmpty()) { + LorenzUtils.userError("Data not loaded yet. Join the garden and display the money per hour display.") + return + } val rawSearchName = args.toMutableList().drop(1).joinToString(" ") val searchName = rawSearchName.lowercase() val map = mutableMapOf() - for (entry in CropMoneyDisplay.multipliers) { + for (entry in multipliers) { val internalName = entry.key val itemName = internalName.getItemName() if (itemName.removeColor().lowercase().contains(searchName)) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropsInCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropsInCommand.kt index a059e65f1..768dcbc49 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropsInCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropsInCommand.kt @@ -10,7 +10,6 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TimeUtils - object GardenCropsInCommand { private val config get() = GardenAPI.config.moneyPerHours @@ -32,12 +31,17 @@ object GardenCropsInCommand { LorenzUtils.userError("Not a valid time: '$rawTime'") return } + val multipliers = CropMoneyDisplay.multipliers + if (multipliers.isEmpty()) { + LorenzUtils.userError("Data not loaded yet. Join the garden and display the money per hour display.") + return + } val rawSearchName = args.toMutableList().drop(1).joinToString(" ") val searchName = rawSearchName.lowercase() val map = mutableMapOf() - for (entry in CropMoneyDisplay.multipliers) { + for (entry in multipliers) { val internalName = entry.key val itemName = internalName.getItemName() if (itemName.removeColor().lowercase().contains(searchName)) { -- cgit