aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUCalculator.kt10
2 files changed, 12 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt
index d3034d003..af29921ce 100644
--- a/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt
@@ -15,6 +15,7 @@ import at.hannibal2.skyhanni.utils.ChatUtils.isCommand
import at.hannibal2.skyhanni.utils.ChatUtils.senderIsSkyhanni
import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.NEUCalculator
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NumberUtil.isDouble
@@ -24,7 +25,6 @@ import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
-import io.github.moulberry.notenoughupdates.util.Calculator
import net.minecraft.inventory.Slot
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.Deque
@@ -170,7 +170,7 @@ object GetFromSackAPI {
}
var amountString = args.last()
- amountString = Calculator.calculate(amountString).toString()
+ amountString = NEUCalculator.calculateOrNull(amountString)?.toString() ?: amountString
if (!amountString.isDouble()) return CommandResult.WRONG_AMOUNT to null
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUCalculator.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUCalculator.kt
new file mode 100644
index 000000000..1b017fea1
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUCalculator.kt
@@ -0,0 +1,10 @@
+package at.hannibal2.skyhanni.utils
+
+import io.github.moulberry.notenoughupdates.util.Calculator
+import java.math.BigDecimal
+
+object NEUCalculator {
+
+ // TODO add if (!usingNEU()) null
+ fun calculateOrNull(input: String): BigDecimal? = runCatching { Calculator.calculate(input) }.getOrNull()
+}