diff options
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt | 6 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt index ba0e334a0..ad5ea7b6e 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt @@ -16,7 +16,7 @@ import at.hannibal2.skyhanni.utils.ChatUtils.senderIsSkyhanni import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName -import at.hannibal2.skyhanni.utils.NumberUtil.isInt +import at.hannibal2.skyhanni.utils.NumberUtil.isDouble import at.hannibal2.skyhanni.utils.PrimitiveItemStack import at.hannibal2.skyhanni.utils.PrimitiveItemStack.Companion.makePrimitiveStack import at.hannibal2.skyhanni.utils.SimpleTimeMark @@ -169,7 +169,7 @@ object GetFromSackAPI { var amountString = args.last() amountString = Calculator.calculate(amountString).toString() - if (!amountString.isInt()) return CommandResult.WRONG_AMOUNT to null + if (!amountString.isDouble()) return CommandResult.WRONG_AMOUNT to null val itemString = args.dropLast(1).joinToString(" ").uppercase().replace(':', '-') @@ -187,7 +187,7 @@ object GetFromSackAPI { else -> return CommandResult.WRONG_IDENTIFIER to null } - return CommandResult.VALID to PrimitiveItemStack(item, amountString.toInt()) + return CommandResult.VALID to PrimitiveItemStack(item, amountString.toDouble().toInt()) } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt index d266e80ce..5df1915c0 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt @@ -173,9 +173,9 @@ object NumberUtil { private val numberPattern = "^[0-9]*$".toPattern() private val formatPattern = "^[0-9,.]*[kmb]?$".toPattern() - fun String.isInt(): Boolean { - return isNotEmpty() && numberPattern.matcher(this).matches() - } + fun String.isInt(): Boolean = isNotEmpty() && numberPattern.matcher(this).matches() + + fun String.isDouble(): Boolean = runCatching { toDouble() }.getOrNull() != null fun String.isFormatNumber(): Boolean { return isNotEmpty() && formatPattern.matches(this) |