mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-11 20:00:46 +00:00
Round down balance when converting to double (#2135)
This commit is contained in:
parent
3b1eb683e1
commit
f569b89d8f
1 changed files with 8 additions and 1 deletions
|
@ -78,7 +78,14 @@ public class Economy {
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static double getMoney(String name) throws UserDoesNotExistException {
|
public static double getMoney(String name) throws UserDoesNotExistException {
|
||||||
return getMoneyExact(name).doubleValue();
|
BigDecimal exactAmount = getMoneyExact(name);
|
||||||
|
double amount = exactAmount.doubleValue();
|
||||||
|
if (new BigDecimal(amount).compareTo(exactAmount) > 0) {
|
||||||
|
// closest double is bigger than the exact amount
|
||||||
|
// -> get the previous double value to not return more money than the user has
|
||||||
|
amount = Math.nextAfter(amount, Double.NEGATIVE_INFINITY);
|
||||||
|
}
|
||||||
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BigDecimal getMoneyExact(String name) throws UserDoesNotExistException {
|
public static BigDecimal getMoneyExact(String name) throws UserDoesNotExistException {
|
||||||
|
|
Loading…
Reference in a new issue