aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/FarmingMilestoneCommand.kt22
2 files changed, 11 insertions, 15 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 61b24c76c..611b57621 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
@@ -296,9 +296,7 @@ object Commands {
registerCommand0(
"shcropgoal",
"Define a custom milestone goal for a crop.",
- {
- FarmingMilestoneCommand.setGoal(it.getOrNull(0), it.getOrNull(1))
- },
+ { FarmingMilestoneCommand.setGoal(it) },
FarmingMilestoneCommand::onComplete
)
registerCommand0(
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingMilestoneCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingMilestoneCommand.kt
index 72f09be00..160619096 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingMilestoneCommand.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingMilestoneCommand.kt
@@ -28,8 +28,10 @@ object FarmingMilestoneCommand {
if (currentMilestone == null) {
val currentProgress = enteredCrop.getCounter()
- val currentCropMilestone = GardenCropMilestones.getTierForCropCount(currentProgress, enteredCrop, allowOverflow = true) + 1
- val cropsForTier = GardenCropMilestones.getCropsForTier(currentCropMilestone, enteredCrop, allowOverflow = true)
+ val currentCropMilestone =
+ GardenCropMilestones.getTierForCropCount(currentProgress, enteredCrop, allowOverflow = true) + 1
+ val cropsForTier =
+ GardenCropMilestones.getCropsForTier(currentCropMilestone, enteredCrop, allowOverflow = true)
val output = (cropsForTier - currentProgress).formatOutput(needsTime, enteredCrop)
ChatUtils.chat("§7$output needed to reach the next milestone")
@@ -55,24 +57,20 @@ object FarmingMilestoneCommand {
ChatUtils.chat("§7$output needed for milestone §7$currentMilestone §a-> §7$targetMilestone")
}
- fun setGoal(crop: String?, target: String?) {
+ fun setGoal(args: Array<String>) {
val storage = ProfileStorageData.profileSpecific?.garden?.customGoalMilestone ?: return
- if (crop == null) {
- ChatUtils.userError("No crop type entered.")
+ if (args.size != 2) {
+ ChatUtils.userError("Usage: /shcropgoal <crop name> <target milestone>")
return
}
- val enteredCrop = CropType.getByName(crop) ?: run {
- ChatUtils.userError("Invalid crop type entered.")
+ val enteredCrop = CropType.getByNameOrNull(args[0]) ?: run {
+ ChatUtils.userError("Not a crop type: '${args[0]}'")
return
}
+ val targetLevel = args[1].formatIntOrUserError() ?: return
- val targetLevel = target?.formatIntOrUserError()
- if (targetLevel == null) {
- ChatUtils.userError("$target is not a valid number.")
- return
- }
val counter = enteredCrop.getCounter()
val level = GardenCropMilestones.getTierForCropCount(counter, enteredCrop)
if (targetLevel <= level && targetLevel != 0) {