aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt21
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/inventory/GetFromSackConfig.java11
2 files changed, 25 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt
index 54517905a..7407dd660 100644
--- a/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt
@@ -148,7 +148,7 @@ object GetFromSackAPI {
when (result) {
CommandResult.VALID -> getFromSack(stack ?: return)
- CommandResult.WRONG_ARGUMENT -> ChatUtils.userError("Missing arguments! Usage: /getfromsacks <name/id> <amount>")
+ CommandResult.WRONG_ARGUMENT -> ChatUtils.userError("Missing arguments! Usage: /getfromsacks <name/id> [amount]")
CommandResult.WRONG_IDENTIFIER -> ChatUtils.userError("Couldn't find an item with this name or identifier!")
CommandResult.WRONG_AMOUNT -> ChatUtils.userError("Invalid amount!")
CommandResult.INTERNAL_ERROR -> {}
@@ -168,20 +168,27 @@ object GetFromSackAPI {
)
private fun commandValidator(args: List<String>): Pair<CommandResult, PrimitiveItemStack?> {
- if (args.size <= 1) {
- return CommandResult.WRONG_ARGUMENT to null
- }
+ if (args.isEmpty()) return CommandResult.WRONG_ARGUMENT to null
+
+ // The last parameter could be "2*3". This does not support ending with ")", but it is good enough
+ val argsNull = !args.last().last().isDigit()
+ val arguments = if (argsNull) {
+ if (!config.defaultGFS) return CommandResult.WRONG_ARGUMENT to null
+
+ args + config.defaultAmountGFS.toString()
+ } else args
- var amountString = args.last()
+ var amountString = arguments.last()
amountString = NEUCalculator.calculateOrNull(amountString)?.toString() ?: amountString
if (!amountString.isDouble()) return CommandResult.WRONG_AMOUNT to null
- val itemString = args.dropLast(1).joinToString(" ").uppercase().replace(':', '-')
+ val itemString = arguments.dropLast(1).joinToString(" ").uppercase().replace(':', '-')
+ val replacedString = itemString.replace("_"," ")
val item = when {
SackAPI.sackListInternalNames.contains(itemString) -> itemString.asInternalName()
- SackAPI.sackListNames.contains(itemString) -> NEUInternalName.fromItemNameOrNull(itemString) ?: run {
+ SackAPI.sackListNames.contains(replacedString) -> NEUInternalName.fromItemNameOrNull(replacedString) ?: run {
ErrorManager.logErrorStateWithData(
"Couldn't resolve item name",
"Query failed",
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/GetFromSackConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/GetFromSackConfig.java
index 03990536f..ee77d6664 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/GetFromSackConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/GetFromSackConfig.java
@@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.config.features.inventory;
import at.hannibal2.skyhanni.config.FeatureToggle;
import com.google.gson.annotations.Expose;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
public class GetFromSackConfig {
@@ -23,4 +24,14 @@ public class GetFromSackConfig {
@ConfigEditorBoolean
@FeatureToggle
public boolean superCraftGFS = true;
+
+ @Expose
+ @ConfigOption(name = "Default GfS", desc = "If you don't provide an amount, a default one will be used instead. Queued GfS needs to be on in order for this to work.")
+ @ConfigEditorBoolean
+ public boolean defaultGFS = false;
+
+ @Expose
+ @ConfigOption(name = "Default Amount GfS", desc = "The default amount of items used when an amount isn't provided.")
+ @ConfigEditorSlider(minValue = 1, maxValue = 64, minStep = 1)
+ public int defaultAmountGFS = 1;
}