Grand Economy

Grand Economy

249k Downloads

[1.12.2] GE arbitrary enforceNonNegativeBalance config option

Caltinor opened this issue ยท 1 comments

commented

Describe the bug
Changing the config value to false does not permit negative values. This is behavior was noticed when using the API for a mod compat implementation

To Reproduce
Steps to reproduce the behavior:

  1. set config option to false
  2. set GNC config tax rate to very short (eg. 100)
  3. set player balance to 5000
  4. create guild (survival mode for all)
  5. put remaining balance into guild account (E -> 3 -> enter value in center of screen and use "+" to transfer)
  6. claim one chunk
  7. claim outpost in non-adjacent chunk.
  8. claim land connected to the outpost but do not connect to first until only $100 remains in guild account.
  9. refresh guild menu to see account reduce by $30 each time taxes are applied.
  10. observe no more reduction in guild funds once it falls below $30.
    Guild&Commerce-1.2.4d.zip

I think I found out why. The economyWrapper does a check for the config value:

@Override
public boolean takeFromBalance(UUID uuid, double amount, Boolean isPlayer) {
if(globalConfig.enforceNonNegativeBalance && amount > 0) {
if(getBalance(uuid, isPlayer)-amount < 0)
return false;
}
return economy.takeFromBalance(uuid, amount, isPlayer);
}

But when the takeFromBalance method is invoked it still returns false if the balance outcome would be negative

Since you are checking the whether the balance is greater than the amount when you confirm the config is set to true, you could remove the two lines from takeFromBalance entirely.

Logs/Screenshots/Videos

Versions (please complete the following information, do NOT say "latest"):

  • Minecraft: [1.12.2]
  • Mod Version: [1.12.2-2.0.0]
  • Forge (If applicable) [Forge-1.12.2-14.23.5.2847]
commented

This is intentional, grand economy's native currency is not allowed to be negative either way. the enforce non-negative values option is to deal with other plugins/mods that aren't designed to go below 0 but do so anyways.