Using another economic plugin with paid commands may cause the player's balance to be reset to zero
dex2code opened this issue ยท 1 comments
Type of bug
Compatibility issue, Other unexpected behaviour
/ess dump all
output
https://essentialsx.net/dump.html?id=07c1d18d17fc41458c73f359089101f8
Error log (if applicable)
No response
Bug description
Using the command-costs functionality may cause the player's balance to reset if a third party economic plugin is used.
The cause is in the strange mechanics of reducing the user's balance with command-costs functionality.
In fact, Essentials first resets the player's balance to zero, and then increases it by the amount of the previous balance minus the cost of the command instead of just increase it with price value:
Player has $1000 and type /heal command which costs $10
Transaction_1 - Player's balance decreases to zero (Withdraw $1000)
Transaction_2 - Players' balance increases to previous value MINUS the command price (Deposit $990)
The problem is that these two transactions may come to another Economy plugin in wrong order (async?) and in case players balance is close to server limit value, the Deposit transaction fails:
Player has $1000, server balance limit is also $1000 and player is going to run /heal command which costs $10
Another Economy plugin receives transactions in wrong order:
Transaction_1 - Deposit $990 - fails because there is a balance limit ($1000)
Transaction_2 - Withdraw $1000 - sets balance to zero
In the screenshot below you can see two situations with the same player.
- Server max-money value set to $8'000'000 and /heal command costs $150
- First we set player's balance to $5'000'000 and Player runs command. We do not see DEPOSIT transaction because it fails
- Then we set player's balance to $4'000'000 and Player runs the same command again. There are full WITHDRAW and then DEPOSIT instead of just WITHDRAW
Steps to reproduce
- Install Vault plugin
- Install Essentials with the following settings:
max-money: 1000
min-money: 0
command-costs:
heal: 10 - Install another Economy plugin (XConomy) with the same balance limitation: max $1000
- Set players balance to $1000
- Player runs /heal command
- Players balance set to zero
Expected behaviour
Essentials plugin should decrease players balance with one transaction with correct price
Actual behaviour
Essentials plugin decreases player's balance with two transactions - full withdraw and then deposit with new value