I'm working on a plugin that gives money to players. I've discovered that if I send a currency amount with a level of precision that is smaller than what is configured the amount is rounded to the configured precision level but the SaneEconomyTransactionEvent gets sent out with the original amount.
Example
I have my currency format set to 0.000
I send currency to a player in the amount of 0.0025.
An event goes out with 0.0025 as the amount.
However, the player's balance is increased by 0.003.
Proposed Fix
In transact() method in class org.appledash.saneeconomy.economy.EconomyManager you send the event on line 170 and then call subtractBalance() or addBalance(). Both subtractBalance() and addBalance() round the amount in the first line of their function:
Summary
I'm working on a plugin that gives money to players. I've discovered that if I send a currency amount with a level of precision that is smaller than what is configured the amount is rounded to the configured precision level but the
SaneEconomyTransactionEvent
gets sent out with the original amount.Example
I have my currency format set to
0.000
I send currency to a player in the amount of0.0025
. An event goes out with0.0025
as the amount. However, the player's balance is increased by0.003
.Proposed Fix
In
transact()
method in classorg.appledash.saneeconomy.economy.EconomyManager
you send the event on line 170 and then callsubtractBalance()
oraddBalance()
. BothsubtractBalance()
andaddBalance()
round the amount in the first line of their function:https://github.com/AppleDash/SaneEconomy/blob/6be741b047901a08934192806577a9d371fbe4fd/SaneEconomyCore/src/main/java/org/appledash/saneeconomy/economy/EconomyManager.java#L95
https://github.com/AppleDash/SaneEconomy/blob/6be741b047901a08934192806577a9d371fbe4fd/SaneEconomyCore/src/main/java/org/appledash/saneeconomy/utils/NumberUtils.java#L46-L52
The currency amount should be rounded before you send the event.