aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-04-28 11:23:21 +0200
committerGitHub <noreply@github.com>2024-04-28 11:23:21 +0200
commit7467e9f16f84f7e1f77b5a91914c54d3a34c5097 (patch)
treeadc34924cd1d6167620bb9316c380f93574d97a3 /src/main/java/at
parente759f4a5d7b2e574cd6b3f3171eac71de90248b9 (diff)
downloadskyhanni-7467e9f16f84f7e1f77b5a91914c54d3a34c5097.tar.gz
skyhanni-7467e9f16f84f7e1f77b5a91914c54d3a34c5097.tar.bz2
skyhanni-7467e9f16f84f7e1f77b5a91914c54d3a34c5097.zip
Fixed: Gfs without amount (#1567)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at')
-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()
+}