aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorDylan <61059252+DylanBruner@users.noreply.github.com>2024-01-06 04:32:48 -0500
committerGitHub <noreply@github.com>2024-01-06 10:32:48 +0100
commitc55ad5e0a58c8e7e26c1156401a65a4b47fefd3f (patch)
tree552aec6e7c47adf7b1c84ec38fdd9adfdb0d2ef7 /src/main/java/at/hannibal2
parentc6fd06063d63d1df159fffe59ede65caa187a073 (diff)
downloadskyhanni-c55ad5e0a58c8e7e26c1156401a65a4b47fefd3f.tar.gz
skyhanni-c55ad5e0a58c8e7e26c1156401a65a4b47fefd3f.tar.bz2
skyhanni-c55ad5e0a58c8e7e26c1156401a65a4b47fefd3f.zip
Feature: Add a reversed version of /shcroptime (#879)
Added /shcropsin and /shcroptime support for k and m numbers. #879
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropsInCommand.kt66
3 files changed, 74 insertions, 2 deletions
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
@@ -153,6 +154,10 @@ object Commands {
"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"
) { DiscordRPCManager.startCommand() }
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<String>) {
+ 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 <time> <item>")
+ return
+ }
+
+ val rawTime = args[0]
+ val seconds = try {
+ TimeUtils.getDuration(rawTime).inWholeSeconds
+ } catch (e: NumberFormatException) {
+ LorenzUtils.userError("Not a valid time: '$rawTime'")
+ return
+ }
+
+ val rawSearchName = args.toMutableList().drop(1).joinToString(" ")
+ val searchName = rawSearchName.lowercase()
+
+ val map = mutableMapOf<String, Long>()
+ for (entry in CropMoneyDisplay.multipliers) {
+ val internalName = entry.key
+ val itemName = internalName.getItemName()
+ if (itemName.removeColor().lowercase().contains(searchName)) {
+ val (baseId, baseAmount) = NEUItems.getMultiplier(internalName)
+ val baseName = baseId.getItemName()
+ val crop = CropType.getByName(baseName.removeColor())
+
+ val speed = crop.getSpeed()
+
+ if (speed == null){
+ map["$itemName §cNo speed data!"] = -1
+ } else {
+ val fullAmount = seconds * speed / baseAmount
+ map["$itemName §b${fullAmount.addSeparators()}x"] = fullAmount
+ }
+ }
+ }
+
+ if (map.isEmpty()) {
+ LorenzUtils.userError("No crops found for '$rawSearchName'")
+ return
+ }
+
+ LorenzUtils.chat("Crops farmed in $rawTime:\n" + map.sorted().keys.joinToString("\n"))
+ }
+}