Vault

Vault

7M Downloads

Try to reset by withdrawPlayer from getBalance amount, but get "Loan was not permitted"

natsimhan opened this issue ยท 3 comments

commented

I'm trying to reset player balance from Vault (and EssentialX), and for some amounts this doesn't work...

Code is very simple :

Double econ_balance = NatEcoBridge.econ.getBalance(op);
EconomyResponse er;
if(econ_balance < 0) {
  er = NatEcoBridge.econ.depositPlayer(op, -econ_balance);
}else{
  er = NatEcoBridge.econ.withdrawPlayer(op, econ_balance);
}
if(!er.transactionSuccess()) {
  NatEcoBridge.log.severe(String.format("[%s] %s", plugin.getDescription().getName(), er.errorMessage));
}

I suppose it is because use of Double and not BigDecimal .... how doing this ?

I'm trying to do :
er = NatEcoBridge.econ.withdrawPlayer(op, BigDecimal.valueOf(econ_balance).doubleValue());

... but this has no effect :/

Why do you not implement resetBalance() in API ? Many Economy plugins have it...

commented

Can't really help without more information. It's not implemented because it's not a universal thing, and 0 isn't necessarily a default value either.

commented

What information you want to have more?

I'll create a test that demonstrates the bug every time ...

The coolest would be to have a setBalance method :)

PS: Why close the ticket without letting me answer? : - /

commented

I read the source code or apis all economy plugins supported by Vault, and they almost all have a setBalance or resetBalance mechanics, either can do the other, why not consider this new feature Vault? :D

My ojectif is to make a synchornisation plugin balance of players between servers on Bungeecord, and without this feature, it's hard .... ^_^