mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-11-23 19:16:31 +01:00
fix CurrencyCore bankBalance method, simplified some code in iCo6
This commit is contained in:
parent
062c0ee12b
commit
9406183409
@ -111,9 +111,10 @@ public class Economy_CurrencyCore implements Economy {
|
||||
return new EconomyResponse(0.0, 0.0, ResponseType.FAILURE, "That account does not exist");
|
||||
} else if (!account.hasBalance(amount)) {
|
||||
return new EconomyResponse(0.0, account.getBalance(), ResponseType.FAILURE, "Insufficient funds");
|
||||
} else {
|
||||
account.subtractBalance(amount);
|
||||
return new EconomyResponse(amount, account.getBalance(), ResponseType.SUCCESS, "");
|
||||
}
|
||||
account.subtractBalance(amount);
|
||||
return new EconomyResponse(amount, account.getBalance(), ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -137,11 +138,12 @@ public class Economy_CurrencyCore implements Economy {
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
if (this.currency.getAccountManager().hasAccount(name)) {
|
||||
return new EconomyResponse(0, getBalance(name), ResponseType.FAILURE, "That account already exists.");
|
||||
AccountContext account = this.currency.getAccountManager().getAccount(name);
|
||||
|
||||
if (account == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That account does not exists.");
|
||||
}
|
||||
this.currency.getAccountManager().createAccount(name);
|
||||
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
|
||||
return new EconomyResponse(0, account.getBalance(), ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -132,16 +132,12 @@ public class Economy_iConomy6 implements Economy {
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
double balance;
|
||||
EconomyResponse.ResponseType type;
|
||||
String errorMessage = null;
|
||||
|
||||
Account account = accounts.get(playerName);
|
||||
Holdings holdings = account.getHoldings();
|
||||
Holdings holdings = accounts.get(playerName).getHoldings();
|
||||
holdings.add(amount);
|
||||
balance = holdings.getBalance();
|
||||
type = EconomyResponse.ResponseType.SUCCESS;
|
||||
|
||||
return new EconomyResponse(amount, balance, type, errorMessage);
|
||||
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user