mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-11-23 19:16:31 +01:00
cleaned up BOSE7 implementation a bit
This commit is contained in:
parent
e1d28d1a7f
commit
045c322af7
@ -79,68 +79,34 @@ public class Economy_BOSE7 implements Economy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||||
double balance;
|
|
||||||
EconomyResponse.ResponseType type;
|
|
||||||
String errorMessage = null;
|
|
||||||
|
|
||||||
if (amount < 0) {
|
if (amount < 0) {
|
||||||
errorMessage = "Cannot withdraw negative funds";
|
return new EconomyResponse(0, economy.getPlayerMoneyDouble(playerName), ResponseType.FAILURE, "Cannot withdraw negative funds");
|
||||||
type = EconomyResponse.ResponseType.FAILURE;
|
|
||||||
amount = 0;
|
|
||||||
balance = economy.getPlayerMoneyDouble(playerName);
|
|
||||||
|
|
||||||
return new EconomyResponse(amount, balance, type, errorMessage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
balance = economy.getPlayerMoneyDouble(playerName);
|
if (!has(playerName, amount)) {
|
||||||
if (balance - amount < 0) {
|
return new EconomyResponse(0, economy.getPlayerMoneyDouble(playerName), ResponseType.FAILURE, "Insufficient funds");
|
||||||
errorMessage = "Insufficient funds";
|
|
||||||
type = EconomyResponse.ResponseType.FAILURE;
|
|
||||||
amount = 0;
|
|
||||||
|
|
||||||
return new EconomyResponse(amount, balance, type, errorMessage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double balance = economy.getPlayerMoneyDouble(playerName);
|
||||||
if (economy.setPlayerMoney(playerName, balance - amount, false)) {
|
if (economy.setPlayerMoney(playerName, balance - amount, false)) {
|
||||||
type = EconomyResponse.ResponseType.SUCCESS;
|
|
||||||
balance = economy.getPlayerMoneyDouble(playerName);
|
balance = economy.getPlayerMoneyDouble(playerName);
|
||||||
|
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, "");
|
||||||
return new EconomyResponse(amount, balance, type, errorMessage);
|
|
||||||
} else {
|
} else {
|
||||||
errorMessage = "Error withdrawing funds";
|
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Error withdrawing funds");
|
||||||
type = EconomyResponse.ResponseType.FAILURE;
|
|
||||||
amount = 0;
|
|
||||||
balance = economy.getPlayerMoneyDouble(playerName);
|
|
||||||
|
|
||||||
return new EconomyResponse(amount, balance, type, errorMessage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||||
double balance;
|
|
||||||
EconomyResponse.ResponseType type;
|
|
||||||
String errorMessage = null;
|
|
||||||
|
|
||||||
if (amount < 0) {
|
if (amount < 0) {
|
||||||
errorMessage = "Cannot deposit negative funds";
|
return new EconomyResponse(0, economy.getPlayerMoneyDouble(playerName), ResponseType.FAILURE, "Cannot deposit negative funds");
|
||||||
type = EconomyResponse.ResponseType.FAILURE;
|
|
||||||
amount = 0;
|
|
||||||
|
|
||||||
return new EconomyResponse(amount, economy.getPlayerMoneyDouble(playerName), type, errorMessage);
|
|
||||||
}
|
}
|
||||||
balance = economy.getPlayerMoneyDouble(playerName);
|
double balance = economy.getPlayerMoneyDouble(playerName);
|
||||||
if (economy.setPlayerMoney(playerName, balance + amount, false)) {
|
if (economy.setPlayerMoney(playerName, balance + amount, false)) {
|
||||||
type = EconomyResponse.ResponseType.SUCCESS;
|
|
||||||
balance = economy.getPlayerMoneyDouble(playerName);
|
balance = economy.getPlayerMoneyDouble(playerName);
|
||||||
|
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, "");
|
||||||
return new EconomyResponse(amount, balance, type, errorMessage);
|
|
||||||
} else {
|
} else {
|
||||||
errorMessage = "Error withdrawing funds";
|
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Error depositing funds");
|
||||||
type = EconomyResponse.ResponseType.FAILURE;
|
|
||||||
amount = 0;
|
|
||||||
balance = economy.getPlayerMoneyDouble(playerName);
|
|
||||||
|
|
||||||
return new EconomyResponse(amount, balance, type, errorMessage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user