Skip to content

Commit

Permalink
[TS-508] Fix money dupe glitch caused by a specific input
Browse files Browse the repository at this point in the history
Closes #508
  • Loading branch information
erikzimmermann committed Feb 23, 2024
1 parent cd85352 commit 243674d
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,14 @@ public boolean isClickable(@NotNull Trade trade, @NotNull Perspective perspectiv
public @Nullable BigDecimal convertInput(@NotNull String input) {
if (input.isEmpty()) return null;

BigDecimal value = (BigDecimal) TradeSystem.handler().getMoneyPattern().parse(input, new ParsePosition(0));
if (value == null) return null;
Number n = TradeSystem.handler().getMoneyPattern().parse(input, new ParsePosition(0));
if (n == null) return null;

// We forced the money pattern to parse BigDecimals only.
// If we don't get a BigDecimal, there have been complications with the parsing.
// We can then assume that either a NaN or an infinite number has been triggered.
if (!(n instanceof BigDecimal)) return null;
BigDecimal value = (BigDecimal) n;

BigDecimal factor = TradeSystem.handler().getMoneyShortcutFactor(input);
if (factor != null) value = value.multiply(factor);
Expand Down

0 comments on commit 243674d

Please sign in to comment.