stripped Bank support from Craftconomy, not sure what this dev is doing.

This commit is contained in:
Sleaker 2012-01-31 09:47:48 -08:00
parent c61a2c2dba
commit 58c81e6dc1

View File

@ -6,6 +6,8 @@ import java.util.logging.Logger;
import me.greatman.Craftconomy.Account; import me.greatman.Craftconomy.Account;
import me.greatman.Craftconomy.AccountHandler; import me.greatman.Craftconomy.AccountHandler;
import me.greatman.Craftconomy.Craftconomy; import me.greatman.Craftconomy.Craftconomy;
import me.greatman.Craftconomy.CurrencyHandler;
import me.greatman.Craftconomy.utils.Config;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse; import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType; import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
@ -86,13 +88,13 @@ public class Economy_Craftconomy implements Economy {
@Override @Override
public String format(double amount) { public String format(double amount) {
return Craftconomy.format(amount); return Craftconomy.format(amount, CurrencyHandler.getCurrency(Config.currencyDefault, true));
} }
@Override @Override
public double getBalance(String playerName) { public double getBalance(String playerName) {
if (AccountHandler.exists(playerName)) { if (AccountHandler.exists(playerName)) {
return AccountHandler.getAccount(playerName).getBalance(); return AccountHandler.getAccount(playerName).getDefaultBalance();
} else { } else {
return 0; return 0;
} }
@ -106,7 +108,7 @@ public class Economy_Craftconomy implements Economy {
balance = account.substractMoney(amount); balance = account.substractMoney(amount);
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, ""); return new EconomyResponse(amount, balance, ResponseType.SUCCESS, "");
} else { } else {
return new EconomyResponse(0, account.getBalance(), ResponseType.FAILURE, "Insufficient funds"); return new EconomyResponse(0, account.getDefaultBalance(), ResponseType.FAILURE, "Insufficient funds");
} }
} }
@ -114,7 +116,7 @@ public class Economy_Craftconomy implements Economy {
public EconomyResponse depositPlayer(String playerName, double amount) { public EconomyResponse depositPlayer(String playerName, double amount) {
Account account = AccountHandler.getAccount(playerName); Account account = AccountHandler.getAccount(playerName);
account.addMoney(amount); account.addMoney(amount);
return new EconomyResponse(amount, account.getBalance(), ResponseType.SUCCESS, null); return new EconomyResponse(amount, account.getDefaultBalance(), ResponseType.SUCCESS, null);
} }
@Override @Override
@ -124,80 +126,42 @@ public class Economy_Craftconomy implements Economy {
@Override @Override
public EconomyResponse createBank(String name, String player) { public EconomyResponse createBank(String name, String player) {
if (AccountHandler.exists(name)) { return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Craftconomy does not support Banks.");
return new EconomyResponse(0, AccountHandler.getAccount(player).getBalance(), ResponseType.FAILURE, "That account already exists.");
}
AccountHandler.getAccount(name);
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
} }
@Override @Override
public EconomyResponse deleteBank(String name) { public EconomyResponse deleteBank(String name) {
if (AccountHandler.exists(name)) { return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Craftconomy does not support Banks.");
AccountHandler.delete(AccountHandler.getAccount(name));
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
}
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Thank bank account does not exist!");
} }
@Override @Override
public EconomyResponse bankHas(String name, double amount) { public EconomyResponse bankHas(String name, double amount) {
if (!AccountHandler.exists(name)) { return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Craftconomy does not support Banks.");
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Account does not exists!");
}
double balance = AccountHandler.getAccount(name).getBank().getBalance();
if ( balance >= amount) {
return new EconomyResponse(0, balance, ResponseType.SUCCESS, "");
} else {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "The account does not have enough!");
}
} }
@Override @Override
public EconomyResponse bankWithdraw(String name, double amount) { public EconomyResponse bankWithdraw(String name, double amount) {
double balance; return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Craftconomy does not support Banks.");
if (!AccountHandler.exists(name)) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Account does not exists!");
}
Account account = AccountHandler.getAccount(name);
if (account.getBank().hasEnough(amount)) {
balance = account.getBank().substractMoney(amount);
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, "");
} else {
balance = account.getBank().getBalance();
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Insufficient funds");
}
} }
@Override @Override
public EconomyResponse bankDeposit(String name, double amount) { public EconomyResponse bankDeposit(String name, double amount) {
if (!AccountHandler.exists(name)) { return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Craftconomy does not support Banks.");
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Account does not exists!");
}
Account account = AccountHandler.getAccount(name);
return new EconomyResponse(amount, account.getBank().addMoney(amount), EconomyResponse.ResponseType.SUCCESS, "");
} }
@Override @Override
public EconomyResponse isBankOwner(String name, String playerName) { public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Craftconomy does not support Bank owners."); return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Craftconomy does not support Banks.");
} }
@Override @Override
public EconomyResponse isBankMember(String name, String playerName) { public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Craftconomy does not support Bank members."); return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Craftconomy does not support Banks.");
} }
@Override @Override
public EconomyResponse bankBalance(String name) { public EconomyResponse bankBalance(String name) {
if (!AccountHandler.exists(name)) { return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Craftconomy does not support Banks.");
return new EconomyResponse(0, 0, ResponseType.FAILURE, "There is no bank account with that name");
} else {
return new EconomyResponse(0, AccountHandler.getAccount(name).getBank().getBalance(), ResponseType.SUCCESS, null);
}
} }
@Override @Override
@ -207,7 +171,7 @@ public class Economy_Craftconomy implements Economy {
@Override @Override
public boolean hasBankSupport() { public boolean hasBankSupport() {
return true; return false;
} }
@Override @Override