From c55ad5e0a58c8e7e26c1156401a65a4b47fefd3f Mon Sep 17 00:00:00 2001 From: Dylan <61059252+DylanBruner@users.noreply.github.com> Date: Sat, 6 Jan 2024 04:32:48 -0500 Subject: Feature: Add a reversed version of /shcroptime (#879) Added /shcropsin and /shcroptime support for k and m numbers. #879 --- .../hannibal2/skyhanni/config/commands/Commands.kt | 5 ++ .../features/garden/GardenCropTimeCommand.kt | 5 +- .../features/garden/GardenCropsInCommand.kt | 66 ++++++++++++++++++++++ 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropsInCommand.kt (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 11f6de89a..f958591c1 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -25,6 +25,7 @@ import at.hannibal2.skyhanni.features.fishing.tracker.FishingProfitTracker import at.hannibal2.skyhanni.features.fishing.tracker.SeaCreatureTracker import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.GardenCropTimeCommand +import at.hannibal2.skyhanni.features.garden.GardenCropsInCommand import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest import at.hannibal2.skyhanni.features.garden.composter.ComposterOverlay import at.hannibal2.skyhanni.features.garden.farming.ArmorDropTracker @@ -152,6 +153,10 @@ object Commands { "shcroptime", "Calculates with your current crop per second speed how long you need to farm a crop to collect this amount of items" ) { GardenCropTimeCommand.onCommand(it) } + registerCommand( + "shcropsin", + "Calculates with your current crop per second how many items you can collect in this amount of time" + ) { GardenCropsInCommand.onCommand(it) } registerCommand( "shrpcstart", "Manually starts the Discord Rich Presence feature" 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 bc1993c96..e6d970b24 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.sorted import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TimeUtils @@ -26,7 +27,7 @@ object GardenCropTimeCommand { val rawAmount = args[0] val amount = try { - rawAmount.toInt() + rawAmount.formatNumber().toInt() } catch (e: NumberFormatException) { LorenzUtils.userError("Not a valid number: '$rawAmount'") return @@ -63,7 +64,7 @@ object GardenCropTimeCommand { } if (map.isEmpty()) { - LorenzUtils.error("No crop item found for '$rawSearchName'.") + LorenzUtils.userError("No crop item found for '$rawSearchName'.") return } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropsInCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropsInCommand.kt new file mode 100644 index 000000000..a059e65f1 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropsInCommand.kt @@ -0,0 +1,66 @@ +package at.hannibal2.skyhanni.features.garden + +import at.hannibal2.skyhanni.features.garden.farming.CropMoneyDisplay +import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed +import at.hannibal2.skyhanni.utils.ItemUtils.getItemName +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.sorted +import at.hannibal2.skyhanni.utils.NEUItems +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 + + fun onCommand(args: Array) { + if (!config.display) { + LorenzUtils.userError("shcropsin requires 'Show money per Hour' feature to be enabled to work!") + return + } + + if (args.size < 2) { + LorenzUtils.userError("Usage: /shcropsin