Added deleteBank method. fixed eWallet not implemented messages.

This commit is contained in:
Sleaker 2012-01-28 11:15:41 -08:00
parent 7f08aa0609
commit 3d84e901de
14 changed files with 963 additions and 871 deletions

View File

@ -102,6 +102,13 @@ public interface Economy {
*/
public EconomyResponse createBank(String name, String player);
/**
* Deletes a bank account with the specified name.
* @param name
* @return if the operation completed successfully
*/
public EconomyResponse deleteBank(String name);
/**
* Returns the amount the bank has
* @param name

View File

@ -187,45 +187,50 @@ public class Economy_3co implements Economy {
}
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
}
@Override
public EconomyResponse deleteBank(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
}
@Override
public List<String> getBanks() {

View File

@ -38,238 +38,246 @@ import cosine.boseconomy.BOSEconomy;
@SuppressWarnings("deprecation")
public class Economy_BOSE6 implements Economy {
private static final Logger log = Logger.getLogger("Minecraft");
private static final Logger log = Logger.getLogger("Minecraft");
private String name = "BOSEconomy";
private Plugin plugin = null;
private BOSEconomy economy = null;
private String name = "BOSEconomy";
private Plugin plugin = null;
private BOSEconomy economy = null;
public Economy_BOSE6(Plugin plugin) {
this.plugin = plugin;
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
public Economy_BOSE6(Plugin plugin) {
this.plugin = plugin;
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (economy == null) {
Plugin bose = plugin.getServer().getPluginManager().getPlugin("BOSEconomy");
if (bose != null && bose.isEnabled() && bose.getDescription().getVersion().startsWith("0.6")) {
economy = (BOSEconomy) bose;
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
}
}
}
@Override
public String getName() {
return name;
}
@Override
public boolean isEnabled() {
if (economy == null) {
return false;
} else {
return economy.isEnabled();
}
}
// Load Plugin in case it was loaded before
if (economy == null) {
Plugin bose = plugin.getServer().getPluginManager().getPlugin("BOSEconomy");
if (bose != null && bose.isEnabled() && bose.getDescription().getVersion().startsWith("0.6")) {
economy = (BOSEconomy) bose;
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
}
}
}
@Override
public double getBalance(String playerName) {
return (double) economy.getPlayerMoney(playerName);
}
public String getName() {
return name;
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public boolean isEnabled() {
if (economy == null) {
return false;
} else {
return economy.isEnabled();
}
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
double balance;
EconomyResponse.ResponseType type;
String errorMessage = null;
@Override
public double getBalance(String playerName) {
return (double) economy.getPlayerMoney(playerName);
}
if (amount < 0) {
errorMessage = "Cannot withdraw negative funds";
type = EconomyResponse.ResponseType.FAILURE;
amount = 0;
balance = (double) economy.getPlayerMoney(playerName);
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
return new EconomyResponse(balance, balance, type, errorMessage);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
double balance;
EconomyResponse.ResponseType type;
String errorMessage = null;
amount = Math.ceil(amount);
balance = (double) economy.getPlayerMoney(playerName);
if (balance - amount < 0) {
errorMessage = "Insufficient funds";
type = EconomyResponse.ResponseType.FAILURE;
amount = 0;
if (amount < 0) {
errorMessage = "Cannot withdraw negative funds";
type = EconomyResponse.ResponseType.FAILURE;
amount = 0;
balance = (double) economy.getPlayerMoney(playerName);
return new EconomyResponse(balance, balance, type, errorMessage);
}
if (economy.setPlayerMoney(playerName, (int) (balance - amount), false)) {
type = EconomyResponse.ResponseType.SUCCESS;
balance = (double) economy.getPlayerMoney(playerName);
return new EconomyResponse(balance, balance, type, errorMessage);
}
return new EconomyResponse(amount, balance, type, errorMessage);
} else {
errorMessage = "Error withdrawing funds";
type = EconomyResponse.ResponseType.FAILURE;
amount = 0;
balance = (double) economy.getPlayerMoney(playerName);
amount = Math.ceil(amount);
balance = (double) economy.getPlayerMoney(playerName);
if (balance - amount < 0) {
errorMessage = "Insufficient funds";
type = EconomyResponse.ResponseType.FAILURE;
amount = 0;
return new EconomyResponse(amount, balance, type, errorMessage);
}
}
return new EconomyResponse(balance, balance, type, errorMessage);
}
if (economy.setPlayerMoney(playerName, (int) (balance - amount), false)) {
type = EconomyResponse.ResponseType.SUCCESS;
balance = (double) economy.getPlayerMoney(playerName);
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
double balance;
EconomyResponse.ResponseType type;
String errorMessage = null;
return new EconomyResponse(amount, balance, type, errorMessage);
} else {
errorMessage = "Error withdrawing funds";
type = EconomyResponse.ResponseType.FAILURE;
amount = 0;
balance = (double) economy.getPlayerMoney(playerName);
if (amount < 0) {
errorMessage = "Cannot deposit negative funds";
type = EconomyResponse.ResponseType.FAILURE;
amount = 0;
balance = (double) economy.getPlayerMoney(playerName);
return new EconomyResponse(amount, balance, type, errorMessage);
}
}
return new EconomyResponse(balance, balance, type, errorMessage);
}
amount = Math.ceil(amount);
balance = (double) economy.getPlayerMoney(playerName);
if (economy.setPlayerMoney(playerName, (int) (balance + amount), false)) {
type = EconomyResponse.ResponseType.SUCCESS;
balance = (double) economy.getPlayerMoney(playerName);
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
double balance;
EconomyResponse.ResponseType type;
String errorMessage = null;
return new EconomyResponse(amount, balance, type, errorMessage);
} else {
errorMessage = "Error withdrawing funds";
type = EconomyResponse.ResponseType.FAILURE;
amount = 0;
balance = (double) economy.getPlayerMoney(playerName);
if (amount < 0) {
errorMessage = "Cannot deposit negative funds";
type = EconomyResponse.ResponseType.FAILURE;
amount = 0;
balance = (double) economy.getPlayerMoney(playerName);
return new EconomyResponse(balance, balance, type, errorMessage);
}
}
return new EconomyResponse(balance, balance, type, errorMessage);
}
amount = Math.ceil(amount);
balance = (double) economy.getPlayerMoney(playerName);
if (economy.setPlayerMoney(playerName, (int) (balance + amount), false)) {
type = EconomyResponse.ResponseType.SUCCESS;
balance = (double) economy.getPlayerMoney(playerName);
public String getMoneyNamePlural() {
return economy.getMoneyNamePlural();
}
return new EconomyResponse(amount, balance, type, errorMessage);
} else {
errorMessage = "Error withdrawing funds";
type = EconomyResponse.ResponseType.FAILURE;
amount = 0;
balance = (double) economy.getPlayerMoney(playerName);
public String getMoneyNameSingular() {
return economy.getMoneyName();
}
return new EconomyResponse(balance, balance, type, errorMessage);
}
}
public class EconomyServerListener implements Listener {
Economy_BOSE6 economy = null;
public String getMoneyNamePlural() {
return economy.getMoneyNamePlural();
}
public EconomyServerListener(Economy_BOSE6 economy) {
this.economy = economy;
}
public String getMoneyNameSingular() {
return economy.getMoneyName();
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.economy == null) {
Plugin bose = plugin.getServer().getPluginManager().getPlugin("BOSEconomy");
public class EconomyServerListener implements Listener {
Economy_BOSE6 economy = null;
if (bose != null && bose.isEnabled() && bose.getDescription().getVersion().startsWith("0.6")) {
economy.economy = (BOSEconomy) bose;
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
}
}
}
public EconomyServerListener(Economy_BOSE6 economy) {
this.economy = economy;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.economy != null) {
if (event.getPlugin().getDescription().getName().equals("BOSEconomy") && event.getPlugin().getDescription().getVersion().startsWith("0.6")) {
economy.economy = null;
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.economy == null) {
Plugin bose = plugin.getServer().getPluginManager().getPlugin("BOSEconomy");
@Override
public String format(double amount) {
if (amount == 1) {
return String.format("%.0f %s", amount, getMoneyNameSingular());
} else {
return String.format("%.2f %s", amount, getMoneyNamePlural());
}
}
if (bose != null && bose.isEnabled() && bose.getDescription().getVersion().startsWith("0.6")) {
economy.economy = (BOSEconomy) bose;
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
}
}
}
@Override
public EconomyResponse createBank(String name, String player) {
boolean success = economy.addBankOwner(name, player, false);
if (success)
return new EconomyResponse(0, economy.getBankMoney(name), ResponseType.SUCCESS, "");
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.economy != null) {
if (event.getPlugin().getDescription().getName().equals("BOSEconomy") && event.getPlugin().getDescription().getVersion().startsWith("0.6")) {
economy.economy = null;
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
}
}
}
}
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to create that bank account.");
}
@Override
public String format(double amount) {
if (amount == 1) {
return String.format("%.0f %s", amount, getMoneyNameSingular());
} else {
return String.format("%.2f %s", amount, getMoneyNamePlural());
}
}
@Override
public EconomyResponse bankHas(String name, double amount) {
if (!economy.bankExists(name))
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
@Override
public EconomyResponse createBank(String name, String player) {
boolean success = economy.addBankOwner(name, player, false);
if (success)
return new EconomyResponse(0, economy.getBankMoney(name), ResponseType.SUCCESS, "");
double bankMoney = economy.getBankMoney(name);
if (bankMoney < amount)
return new EconomyResponse(0, bankMoney, ResponseType.FAILURE, "The bank does not have enough money!");
else
return new EconomyResponse(0, bankMoney, ResponseType.SUCCESS, "");
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to create that bank account.");
}
@Override
public EconomyResponse deleteBank(String name) {
boolean success = economy.removeBank(name);
if (success) {
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
}
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to remove that bank account.");
}
}
@Override
public EconomyResponse bankHas(String name, double amount) {
if (!economy.bankExists(name))
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
EconomyResponse er = bankHas(name, amount);
if (!er.transactionSuccess())
return er;
else {
economy.addBankMoney(name, (int) -amount, true);
return new EconomyResponse((int) amount, economy.getBankMoney(name), ResponseType.SUCCESS, "");
}
}
double bankMoney = economy.getBankMoney(name);
if (bankMoney < amount)
return new EconomyResponse(0, bankMoney, ResponseType.FAILURE, "The bank does not have enough money!");
else
return new EconomyResponse(0, bankMoney, ResponseType.SUCCESS, "");
@Override
public EconomyResponse bankDeposit(String name, double amount) {
if (!economy.bankExists(name))
return new EconomyResponse(amount, 0, ResponseType.FAILURE, "That bank does not exist!");
else {
economy.addBankMoney(name, (int) amount, true);
return new EconomyResponse((int) amount, economy.getBankMoney(name), ResponseType.SUCCESS, "");
}
}
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
if (!economy.bankExists(name))
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
else if (economy.isBankOwner(name, playerName)) {
return new EconomyResponse(0, economy.getBankMoney(name), ResponseType.SUCCESS, "");
} else
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player is not a bank owner!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
EconomyResponse er = bankHas(name, amount);
if (!er.transactionSuccess())
return er;
else {
economy.addBankMoney(name, (int) -amount, true);
return new EconomyResponse((int) amount, economy.getBankMoney(name), ResponseType.SUCCESS, "");
}
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
if (!economy.bankExists(name))
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
else if (economy.isBankMember(name, playerName)) {
return new EconomyResponse(0, economy.getBankMoney(name), ResponseType.SUCCESS, "");
} else
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player is not a bank member!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
if (!economy.bankExists(name))
return new EconomyResponse(amount, 0, ResponseType.FAILURE, "That bank does not exist!");
else {
economy.addBankMoney(name, (int) amount, true);
return new EconomyResponse((int) amount, economy.getBankMoney(name), ResponseType.SUCCESS, "");
}
}
@Override
public EconomyResponse bankBalance(String name) {
if (!economy.bankExists(name))
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
if (!economy.bankExists(name))
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
else if (economy.isBankOwner(name, playerName)) {
return new EconomyResponse(0, economy.getBankMoney(name), ResponseType.SUCCESS, "");
} else
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player is not a bank owner!");
}
double bankMoney = economy.getBankMoney(name);
return new EconomyResponse(0, bankMoney, ResponseType.SUCCESS, null);
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
if (!economy.bankExists(name))
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
else if (economy.isBankMember(name, playerName)) {
return new EconomyResponse(0, economy.getBankMoney(name), ResponseType.SUCCESS, "");
} else
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player is not a bank member!");
}
@Override
public EconomyResponse bankBalance(String name) {
if (!economy.bankExists(name))
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
double bankMoney = economy.getBankMoney(name);
return new EconomyResponse(0, bankMoney, ResponseType.SUCCESS, null);
}
@Override
public List<String> getBanks() {

View File

@ -195,87 +195,97 @@ public class Economy_BOSE7 implements Economy {
}
}
@Override
public EconomyResponse createBank(String name, String player) {
boolean success = economy.addBankOwner(name, player, false);
if (success)
return new EconomyResponse(0, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
@Override
public EconomyResponse createBank(String name, String player) {
boolean success = economy.addBankOwner(name, player, false);
if (success) {
return new EconomyResponse(0, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
}
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to create that bank account.");
}
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to create that bank account.");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
if (!economy.bankExists(name))
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
@Override
public EconomyResponse deleteBank(String name) {
boolean success = economy.removeBank(name);
if (success) {
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
}
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to remove that bank account.");
}
double bankMoney = economy.getBankMoneyDouble(name);
if (bankMoney < amount)
return new EconomyResponse(0, bankMoney, ResponseType.FAILURE, "The bank does not have enough money!");
else
return new EconomyResponse(0, bankMoney, ResponseType.SUCCESS, "");
@Override
public EconomyResponse bankHas(String name, double amount) {
if (!economy.bankExists(name))
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
}
double bankMoney = economy.getBankMoneyDouble(name);
if (bankMoney < amount)
return new EconomyResponse(0, bankMoney, ResponseType.FAILURE, "The bank does not have enough money!");
else
return new EconomyResponse(0, bankMoney, ResponseType.SUCCESS, "");
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
EconomyResponse er = bankHas(name, amount);
if (!er.transactionSuccess())
return er;
else {
economy.addBankMoney(name, -amount, true);
return new EconomyResponse(amount, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
}
}
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
if (!economy.bankExists(name))
return new EconomyResponse(amount, 0, ResponseType.FAILURE, "That bank does not exist!");
else {
economy.addBankMoney(name, amount, true);
return new EconomyResponse(amount, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
}
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
EconomyResponse er = bankHas(name, amount);
if (!er.transactionSuccess())
return er;
else {
economy.addBankMoney(name, -amount, true);
return new EconomyResponse(amount, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
}
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
if (!economy.bankExists(name))
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
else if (economy.isBankOwner(name, playerName)) {
return new EconomyResponse(0, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
} else
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player is not a bank owner!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
if (!economy.bankExists(name))
return new EconomyResponse(amount, 0, ResponseType.FAILURE, "That bank does not exist!");
else {
economy.addBankMoney(name, amount, true);
return new EconomyResponse(amount, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
}
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
if (!economy.bankExists(name))
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
else if (economy.isBankMember(name, playerName)) {
return new EconomyResponse(0, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
} else
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player is not a bank member!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
if (!economy.bankExists(name))
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
else if (economy.isBankOwner(name, playerName)) {
return new EconomyResponse(0, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
} else
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player is not a bank owner!");
}
@Override
public EconomyResponse bankBalance(String name) {
if (!economy.bankExists(name))
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
@Override
public EconomyResponse isBankMember(String name, String playerName) {
if (!economy.bankExists(name))
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
else if (economy.isBankMember(name, playerName)) {
return new EconomyResponse(0, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
} else
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player is not a bank member!");
}
double bankMoney = economy.getBankMoneyDouble(name);
return new EconomyResponse(0, bankMoney, ResponseType.SUCCESS, null);
}
@Override
public EconomyResponse bankBalance(String name) {
if (!economy.bankExists(name))
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
@Override
public List<String> getBanks() {
return economy.getBankList();
}
double bankMoney = economy.getBankMoneyDouble(name);
return new EconomyResponse(0, bankMoney, ResponseType.SUCCESS, null);
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public List<String> getBanks() {
return economy.getBankList();
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public boolean hasBankSupport() {

View File

@ -132,6 +132,15 @@ public class Economy_Craftconomy implements Economy {
}
@Override
public EconomyResponse deleteBank(String name) {
if (AccountHandler.exists(name)) {
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
public EconomyResponse bankHas(String name, double amount) {
if (!AccountHandler.exists(name)) {

View File

@ -135,6 +135,15 @@ public class Economy_CurrencyCore implements Economy {
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
}
@Override
public EconomyResponse deleteBank(String name) {
if (this.currency.getAccountManager().hasAccount(name)) {
this.currency.getAccountManager().removeAccount(name);
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
}
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That account does not exist!");
}
@Override
public EconomyResponse bankBalance(String name) {
AccountContext account = this.currency.getAccountManager().getAccount(name);

View File

@ -20,120 +20,120 @@ import org.bukkit.plugin.Plugin;
import ca.agnate.EconXP.EconXP;
public class Economy_EconXP implements Economy {
private static final Logger log = Logger.getLogger("Minecraft");
private static final Logger log = Logger.getLogger("Minecraft");
private String name = "EconXP";
private Plugin plugin = null;
private EconXP econ = null;
private String name = "EconXP";
private Plugin plugin = null;
private EconXP econ = null;
public Economy_EconXP(Plugin plugin) {
this.plugin = plugin;
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
public Economy_EconXP(Plugin plugin) {
this.plugin = plugin;
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (econ == null) {
Plugin econ = plugin.getServer().getPluginManager().getPlugin("EconXP");
if (econ != null && econ.isEnabled()) {
this.econ = (EconXP) econ;
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
}
}
}
// Load Plugin in case it was loaded before
if (econ == null) {
Plugin econ = plugin.getServer().getPluginManager().getPlugin("EconXP");
if (econ != null && econ.isEnabled()) {
this.econ = (EconXP) econ;
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
}
}
}
public class EconomyServerListener implements Listener {
Economy_EconXP economy = null;
public class EconomyServerListener implements Listener {
Economy_EconXP economy = null;
public EconomyServerListener(Economy_EconXP economy) {
this.economy = economy;
}
public EconomyServerListener(Economy_EconXP economy) {
this.economy = economy;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.econ == null) {
Plugin eco = plugin.getServer().getPluginManager().getPlugin("EconXP");
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.econ == null) {
Plugin eco = plugin.getServer().getPluginManager().getPlugin("EconXP");
if (eco != null && eco.isEnabled()) {
economy.econ = (EconXP) eco;
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
}
}
}
if (eco != null && eco.isEnabled()) {
economy.econ = (EconXP) eco;
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.econ != null) {
if (event.getPlugin().getDescription().getName().equals("EconXP")) {
economy.econ = null;
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.econ != null) {
if (event.getPlugin().getDescription().getName().equals("EconXP")) {
economy.econ = null;
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
}
}
}
}
@Override
public boolean isEnabled() {
return this.econ != null;
}
@Override
public boolean isEnabled() {
return this.econ != null;
}
@Override
public String getName() {
return name;
}
@Override
public String getName() {
return name;
}
@Override
public String format(double amount) {
amount = Math.ceil(amount);
@Override
public String format(double amount) {
amount = Math.ceil(amount);
return String.format("%d %s", (int)amount, "experience");
}
return String.format("%d %s", (int)amount, "experience");
}
@Override
public double getBalance(String playerName) {
OfflinePlayer player = econ.getPlayer(playerName);
@Override
public double getBalance(String playerName) {
OfflinePlayer player = econ.getPlayer(playerName);
if ( player == null ) { return 0; }
if ( player == null ) { return 0; }
return econ.getExp(player);
}
return econ.getExp(player);
}
@Override
public boolean has(String playerName, double amount) {
OfflinePlayer player = econ.getPlayer(playerName);
@Override
public boolean has(String playerName, double amount) {
OfflinePlayer player = econ.getPlayer(playerName);
if ( player == null ) { return false; }
return econ.hasExp(player, (int) Math.ceil(amount) );
}
return econ.hasExp(player, (int) Math.ceil(amount) );
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
OfflinePlayer player = econ.getPlayer(playerName);
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
OfflinePlayer player = econ.getPlayer(playerName);
if ( player == null ) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Player does not exist");
}
double balance = econ.getExp(player);
amount = Math.ceil(amount);
double balance = econ.getExp(player);
amount = Math.ceil(amount);
if (amount < 0) {
if (amount < 0) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot withdraw negative funds");
}
if ( econ.hasExp(player, (int) amount) == false ) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Insufficient funds");
}
if ( econ.hasExp(player, (int) amount) == false ) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Insufficient funds");
}
econ.removeExp(player, (int) amount);
econ.removeExp(player, (int) amount);
double finalBalance = econ.getExp(player);
double finalBalance = econ.getExp(player);
return new EconomyResponse(amount, finalBalance, ResponseType.SUCCESS, null);
}
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
OfflinePlayer player = econ.getPlayer(playerName);
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
OfflinePlayer player = econ.getPlayer(playerName);
if ( player == null ) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Player does not exist");
@ -147,45 +147,50 @@ public class Economy_EconXP implements Economy {
}
econ.addExp(player, (int) amount );
balance = econ.getExp(player);
balance = econ.getExp(player);
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, null);
}
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, null);
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
}
@Override
public EconomyResponse deleteBank(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
}
@Override
public List<String> getBanks() {

View File

@ -203,45 +203,50 @@ public class Economy_Essentials implements Economy {
return com.earth2me.essentials.api.Economy.format(amount);
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
@Override
public EconomyResponse deleteBank(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
@Override
public List<String> getBanks() {

View File

@ -19,141 +19,146 @@ import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
public class Economy_MineConomy implements Economy {
private static final Logger log = Logger.getLogger("Minecraft");
private static final Logger log = Logger.getLogger("Minecraft");
private String name = "MineConomy";
private Plugin plugin = null;
private MineConomy econ = null;
private String name = "MineConomy";
private Plugin plugin = null;
private MineConomy econ = null;
public Economy_MineConomy(Plugin plugin) {
this.plugin = plugin;
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
public Economy_MineConomy(Plugin plugin) {
this.plugin = plugin;
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (econ == null) {
Plugin econ = plugin.getServer().getPluginManager().getPlugin("MineConomy");
if (econ != null && econ.isEnabled()) {
this.econ = (MineConomy) econ;
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
}
}
}
// Load Plugin in case it was loaded before
if (econ == null) {
Plugin econ = plugin.getServer().getPluginManager().getPlugin("MineConomy");
if (econ != null && econ.isEnabled()) {
this.econ = (MineConomy) econ;
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
}
}
}
public class EconomyServerListener implements Listener {
Economy_MineConomy economy = null;
public class EconomyServerListener implements Listener {
Economy_MineConomy economy = null;
public EconomyServerListener(Economy_MineConomy economy) {
this.economy = economy;
}
public EconomyServerListener(Economy_MineConomy economy) {
this.economy = economy;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.econ == null) {
Plugin eco = plugin.getServer().getPluginManager().getPlugin("MineConomy");
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.econ == null) {
Plugin eco = plugin.getServer().getPluginManager().getPlugin("MineConomy");
if (eco != null && eco.isEnabled()) {
economy.econ = (MineConomy) eco;
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
}
}
}
if (eco != null && eco.isEnabled()) {
economy.econ = (MineConomy) eco;
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.econ != null) {
if (event.getPlugin().getDescription().getName().equals("MineConomy")) {
economy.econ = null;
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.econ != null) {
if (event.getPlugin().getDescription().getName().equals("MineConomy")) {
economy.econ = null;
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
}
}
}
}
@Override
public boolean isEnabled() {
return this.econ != null;
}
@Override
public boolean isEnabled() {
return this.econ != null;
}
@Override
public String getName() {
return name;
}
@Override
public String getName() {
return name;
}
@Override
public String format(double amount) {
return String.valueOf(amount);
}
@Override
public String format(double amount) {
return String.valueOf(amount);
}
@Override
public double getBalance(String playerName) {
return Accounting.getBalance(playerName, MineConomy.accounts);
}
@Override
public double getBalance(String playerName) {
return Accounting.getBalance(playerName, MineConomy.accounts);
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
double balance = getBalance(playerName);
if (amount < 0) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot withdraw negative funds");
} else if (balance >= amount) {
double finalBalance = balance - amount;
Accounting.setBalance(playerName, finalBalance, MineConomy.accounts);
return new EconomyResponse(amount, finalBalance, ResponseType.SUCCESS, null);
} else {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Insufficient funds");
}
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
double balance = getBalance(playerName);
if (amount < 0) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot withdraw negative funds");
} else if (balance >= amount) {
double finalBalance = balance - amount;
Accounting.setBalance(playerName, finalBalance, MineConomy.accounts);
return new EconomyResponse(amount, finalBalance, ResponseType.SUCCESS, null);
} else {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Insufficient funds");
}
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
double balance = getBalance(playerName);
if (amount < 0) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot deposit negative funds");
} else {
balance += amount;
Accounting.setBalance(playerName, balance, MineConomy.accounts);
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, null);
}
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
double balance = getBalance(playerName);
if (amount < 0) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot deposit negative funds");
} else {
balance += amount;
Accounting.setBalance(playerName, balance, MineConomy.accounts);
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, null);
}
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
}
@Override
public EconomyResponse deleteBank(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
}
@Override
public List<String> getBanks() {

View File

@ -186,45 +186,50 @@ public class Economy_MultiCurrency implements Economy {
return String.format("%.2f %s", amount, "Currency");
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
}
@Override
public EconomyResponse deleteBank(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
}
@Override
public List<String> getBanks() {

View File

@ -18,149 +18,154 @@ import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
public class Economy_eWallet implements Economy {
private static final Logger log = Logger.getLogger("Minecraft");
private static final Logger log = Logger.getLogger("Minecraft");
private String name = "eWallet";
private Plugin plugin = null;
private ECO econ = null;
private String name = "eWallet";
private Plugin plugin = null;
private ECO econ = null;
public Economy_eWallet(Plugin plugin) {
this.plugin = plugin;
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
public Economy_eWallet(Plugin plugin) {
this.plugin = plugin;
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (econ == null) {
Plugin econ = plugin.getServer().getPluginManager().getPlugin("eWallet");
if (econ != null && econ.isEnabled()) {
this.econ = (ECO) econ;
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
}
}
}
// Load Plugin in case it was loaded before
if (econ == null) {
Plugin econ = plugin.getServer().getPluginManager().getPlugin("eWallet");
if (econ != null && econ.isEnabled()) {
this.econ = (ECO) econ;
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
}
}
}
public class EconomyServerListener implements Listener {
Economy_eWallet economy = null;
public class EconomyServerListener implements Listener {
Economy_eWallet economy = null;
public EconomyServerListener(Economy_eWallet economy) {
this.economy = economy;
}
public EconomyServerListener(Economy_eWallet economy) {
this.economy = economy;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.econ == null) {
Plugin eco = plugin.getServer().getPluginManager().getPlugin("eWallet");
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (economy.econ == null) {
Plugin eco = plugin.getServer().getPluginManager().getPlugin("eWallet");
if (eco != null && eco.isEnabled()) {
economy.econ = (ECO) eco;
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
}
}
}
if (eco != null && eco.isEnabled()) {
economy.econ = (ECO) eco;
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.econ != null) {
if (event.getPlugin().getDescription().getName().equals("eWallet")) {
economy.econ = null;
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (economy.econ != null) {
if (event.getPlugin().getDescription().getName().equals("eWallet")) {
economy.econ = null;
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
}
}
}
}
@Override
public boolean isEnabled() {
return this.econ != null;
}
@Override
public boolean isEnabled() {
return this.econ != null;
}
@Override
public String getName() {
return name;
}
@Override
public String getName() {
return name;
}
@Override
public String format(double amount) {
amount = Math.ceil(amount);
@Override
public String format(double amount) {
amount = Math.ceil(amount);
if (amount == 1) {
return String.format("%d %s", (int)amount, econ.singularCurrency);
} else {
return String.format("%d %s", (int)amount, econ.pluralCurrency);
}
}
}
@Override
public double getBalance(String playerName) {
Integer i = econ.getMoney(playerName);
return i == null ? 0 : i;
}
@Override
public double getBalance(String playerName) {
Integer i = econ.getMoney(playerName);
return i == null ? 0 : i;
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= Math.ceil(amount);
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= Math.ceil(amount);
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
double balance = getBalance(playerName);
amount = Math.ceil(amount);
if (amount < 0) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot withdraw negative funds");
} else if (balance >= amount) {
double finalBalance = balance - amount;
econ.takeMoney(playerName, (int) amount);
return new EconomyResponse(amount, finalBalance, ResponseType.SUCCESS, null);
} else {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Insufficient funds");
}
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
double balance = getBalance(playerName);
amount = Math.ceil(amount);
if (amount < 0) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot withdraw negative funds");
} else if (balance >= amount) {
double finalBalance = balance - amount;
econ.takeMoney(playerName, (int) amount);
return new EconomyResponse(amount, finalBalance, ResponseType.SUCCESS, null);
} else {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Insufficient funds");
}
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
double balance = getBalance(playerName);
amount = Math.ceil(amount);
if (amount < 0) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot deposit negative funds");
} else {
balance += amount;
econ.giveMoney(playerName, (int) amount);
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, null);
}
}
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
double balance = getBalance(playerName);
amount = Math.ceil(amount);
if (amount < 0) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot deposit negative funds");
} else {
balance += amount;
econ.giveMoney(playerName, (int) amount);
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, null);
}
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
}
@Override
public EconomyResponse deleteBank(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
}
@Override
public List<String> getBanks() {

View File

@ -193,45 +193,50 @@ public class Economy_iConomy4 implements Economy {
}
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy4 does not support bank accounts!");
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy4 does not support bank accounts!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy4 does not support bank accounts!");
}
@Override
public EconomyResponse deleteBank(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy4 does not support bank accounts!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy4 does not support bank accounts!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy4 does not support bank accounts!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy4 does not support bank accounts!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy4 does not support bank accounts!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy4 does not support bank accounts!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy4 does not support bank accounts!");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy4 does not support bank accounts!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy4 does not support bank accounts!");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy4 does not support bank accounts!");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy4 does not support bank accounts!");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy4 does not support bank accounts!");
}
@Override
public List<String> getBanks() {

View File

@ -156,45 +156,50 @@ public class Economy_iConomy5 implements Economy {
return iConomy.format(amount);
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy5 does not support single account banks!");
}
@Override
public EconomyResponse createBank(String name, String player) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy5 does not support single account banks!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy5 does not support single bank accounts!");
}
@Override
public EconomyResponse deleteBank(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy5 does not support bank accounts!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy5 does not support single bank accounts!");
}
@Override
public EconomyResponse bankHas(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy5 does not support single bank accounts!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy5 does not support single bank accounts!");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy5 does not support single bank accounts!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy5 does not support single bank accounts!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy5 does not support single bank accounts!");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy5 does not support single bank accounts!");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy5 does not support single bank accounts!");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy5 does not support single bank accounts!");
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy5 does not support single bank accounts!");
}
@Override
public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy5 does not support single bank accounts!");
}
@Override
public List<String> getBanks() {

View File

@ -135,59 +135,68 @@ public class Economy_iConomy6 implements Economy {
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, null);
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@Override
public EconomyResponse createBank(String name, String player) {
if (accounts.exists(name))
return new EconomyResponse(0, accounts.get(name).getHoldings().getBalance(), ResponseType.FAILURE, "That account already exists.");
@Override
public EconomyResponse createBank(String name, String player) {
if (accounts.exists(name))
return new EconomyResponse(0, accounts.get(name).getHoldings().getBalance(), ResponseType.FAILURE, "That account already exists.");
boolean created = accounts.create(name);
if (created)
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
else
return new EconomyResponse(0, 0, ResponseType.FAILURE, "There was an error creating the account");
boolean created = accounts.create(name);
if (created)
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
else
return new EconomyResponse(0, 0, ResponseType.FAILURE, "There was an error creating the account");
}
}
@Override
public EconomyResponse bankHas(String name, double amount) {
if (has(name, amount))
return new EconomyResponse(0, amount, ResponseType.SUCCESS, "");
else
return new EconomyResponse(0, accounts.get(name).getHoldings().getBalance(), ResponseType.FAILURE, "The account does not have enough!");
}
@Override
public EconomyResponse deleteBank(String name) {
if (accounts.exists(name)) {
accounts.remove(name);
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
}
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank account does not exist.");
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return withdrawPlayer(name, amount);
}
@Override
public EconomyResponse bankHas(String name, double amount) {
if (has(name, amount))
return new EconomyResponse(0, amount, ResponseType.SUCCESS, "");
else
return new EconomyResponse(0, accounts.get(name).getHoldings().getBalance(), ResponseType.FAILURE, "The account does not have enough!");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return depositPlayer(name, amount);
}
@Override
public EconomyResponse bankWithdraw(String name, double amount) {
return withdrawPlayer(name, amount);
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy 6 does not support Bank owners.");
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return depositPlayer(name, amount);
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy 6 does not support Bank members.");
}
@Override
public EconomyResponse isBankOwner(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy 6 does not support Bank owners.");
}
@Override
public EconomyResponse bankBalance(String name) {
if (!accounts.exists(name))
return new EconomyResponse(0, 0, ResponseType.FAILURE, "There is no bank account with that name");
else
return new EconomyResponse(0, accounts.get(name).getHoldings().getBalance(), ResponseType.SUCCESS, null);
}
@Override
public EconomyResponse isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy 6 does not support Bank members.");
}
@Override
public EconomyResponse bankBalance(String name) {
if (!accounts.exists(name))
return new EconomyResponse(0, 0, ResponseType.FAILURE, "There is no bank account with that name");
else
return new EconomyResponse(0, accounts.get(name).getHoldings().getBalance(), ResponseType.SUCCESS, null);
}
@Override
public List<String> getBanks() {