This commit is contained in:
mung3r 2011-10-31 10:22:34 -07:00
commit 371a1c3d4f
9 changed files with 570 additions and 151 deletions

View File

@ -49,6 +49,13 @@ public interface Economy {
*/
public double getBalance(String playerName);
/**
* Checks if the player account has the amount
* @param playerName
* @param amount
* @return
*/
public boolean has(String playerName, double amount);
/**
* Withdraw an amount from a player
* @param playerName Name of player
@ -64,4 +71,52 @@ public interface Economy {
* @return Detailed response of transaction
*/
public EconomyResponse depositPlayer(String playerName, double amount);
/**
* Creates a bank account with the specified name and the player as the owner
* @param name
* @param player
* @return
*/
public EconomyResponse createBank(String name, String player);
/**
* Returns true or false whether the bank has the amount specified
* @param name
* @param amount
* @return
*/
public EconomyResponse bankHas(String name, double amount);
/**
* Withdraw an amount from a bank account
* @param name
* @param amount
* @return
*/
public EconomyResponse bankWithdraw(String name, double amount);
/**
* Deposit an amount into a bank account
* @param name
* @param amount
* @return
*/
public EconomyResponse bankDeposit(String name, double amount);
/**
* Check if a player is the owner of a bank account
* @param name
* @param playerName
* @return
*/
public EconomyResponse isBankOwner(String name, String playerName);
/**
* Check if the player is a member of the bank account
* @param name
* @param playerName
* @return
*/
public EconomyResponse isBankMember(String name, String playerName);
}

View File

@ -24,6 +24,7 @@ import java.util.logging.Logger;
import me.ic3d.eco.ECO;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
@ -97,7 +98,7 @@ public class Economy_3co implements Economy {
amount = 0;
balance = (double) economy.getMoney(plugin.getServer().getPlayer(playerName));
return new EconomyResponse(balance, balance, type, errorMessage);
return new EconomyResponse(amount, balance, type, errorMessage);
}
amount = Math.ceil(amount);
@ -108,7 +109,7 @@ public class Economy_3co implements Economy {
amount = 0;
balance = (double) economy.getMoney(plugin.getServer().getPlayer(playerName));
return new EconomyResponse(balance, balance, type, errorMessage);
return new EconomyResponse(amount, balance, type, errorMessage);
}
economy.setMoney(plugin.getServer().getPlayer(playerName), (int) (balance - amount));
type = EconomyResponse.ResponseType.SUCCESS;
@ -129,7 +130,7 @@ public class Economy_3co implements Economy {
amount = 0;
balance = (double) economy.getMoney(plugin.getServer().getPlayer(playerName));
return new EconomyResponse(balance, balance, type, errorMessage);
return new EconomyResponse(amount, balance, type, errorMessage);
}
amount = Math.ceil(amount);
balance = (double) economy.getMoney(plugin.getServer().getPlayer(playerName));
@ -185,4 +186,39 @@ public class Economy_3co implements Economy {
return String.format("%d %s", (int)amount, getMoneyNamePlural());
}
}
@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 bankWithdraw(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 boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
@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 isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
}
}

View File

@ -23,6 +23,7 @@ import java.util.logging.Logger;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
@ -35,170 +36,238 @@ import org.bukkit.plugin.PluginManager;
import cosine.boseconomy.BOSEconomy;
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 PluginManager pluginManager = null;
private BOSEconomy economy = null;
private EconomyServerListener economyServerListener = null;
private String name = "BOSEconomy";
private Plugin plugin = null;
private PluginManager pluginManager = null;
private BOSEconomy economy = null;
private EconomyServerListener economyServerListener = null;
public Economy_BOSE6(Plugin plugin) {
this.plugin = plugin;
pluginManager = this.plugin.getServer().getPluginManager();
public Economy_BOSE6(Plugin plugin) {
this.plugin = plugin;
pluginManager = this.plugin.getServer().getPluginManager();
economyServerListener = new EconomyServerListener(this);
economyServerListener = new EconomyServerListener(this);
this.pluginManager.registerEvent(Type.PLUGIN_ENABLE, economyServerListener, Priority.Monitor, plugin);
this.pluginManager.registerEvent(Type.PLUGIN_DISABLE, economyServerListener, Priority.Monitor, plugin);
this.pluginManager.registerEvent(Type.PLUGIN_ENABLE, economyServerListener, Priority.Monitor, plugin);
this.pluginManager.registerEvent(Type.PLUGIN_DISABLE, economyServerListener, Priority.Monitor, 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));
}
}
}
// 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 String getName() {
return name;
}
@Override
public boolean isEnabled() {
if (economy == null) {
return false;
} else {
return economy.isEnabled();
}
}
@Override
public boolean isEnabled() {
if (economy == null) {
return false;
} else {
return economy.isEnabled();
}
}
@Override
public double getBalance(String playerName) {
final double balance;
@Override
public double getBalance(String playerName) {
final double balance;
balance = (double) economy.getPlayerMoney(playerName);
balance = (double) economy.getPlayerMoney(playerName);
final double fBalance = balance;
return fBalance;
}
final double fBalance = balance;
return fBalance;
}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
double balance;
EconomyResponse.ResponseType type;
String errorMessage = null;
@Override
public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
if (amount < 0) {
errorMessage = "Cannot withdraw negative funds";
type = EconomyResponse.ResponseType.FAILURE;
amount = 0;
balance = (double) economy.getPlayerMoney(playerName);
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
double balance;
EconomyResponse.ResponseType type;
String errorMessage = null;
return new EconomyResponse(balance, balance, type, errorMessage);
}
if (amount < 0) {
errorMessage = "Cannot withdraw negative 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;
balance = (double) economy.getPlayerMoney(playerName);
return new EconomyResponse(balance, 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);
amount = Math.ceil(amount);
balance = (double) economy.getPlayerMoney(playerName);
if (balance - amount < 0) {
errorMessage = "Insufficient funds";
type = EconomyResponse.ResponseType.FAILURE;
amount = 0;
balance = (double) economy.getPlayerMoney(playerName);
return new EconomyResponse(amount, balance, type, errorMessage);
} else {
errorMessage = "Error withdrawing 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(amount, 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);
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
double balance;
EconomyResponse.ResponseType type;
String errorMessage = null;
return new EconomyResponse(amount, balance, type, errorMessage);
}
}
if (amount < 0) {
errorMessage = "Cannot deposit negative funds";
type = EconomyResponse.ResponseType.FAILURE;
amount = 0;
balance = (double) economy.getPlayerMoney(playerName);
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
double balance;
EconomyResponse.ResponseType type;
String errorMessage = null;
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);
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);
} else {
errorMessage = "Error withdrawing funds";
type = EconomyResponse.ResponseType.FAILURE;
amount = 0;
balance = (double) economy.getPlayerMoney(playerName);
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);
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);
public String getMoneyNamePlural() {
return economy.getMoneyNamePlural();
}
return new EconomyResponse(balance, balance, type, errorMessage);
}
}
public String getMoneyNameSingular() {
return economy.getMoneyName();
}
public String getMoneyNamePlural() {
return economy.getMoneyNamePlural();
}
private class EconomyServerListener extends ServerListener {
Economy_BOSE6 economy = null;
public String getMoneyNameSingular() {
return economy.getMoneyName();
}
public EconomyServerListener(Economy_BOSE6 economy) {
this.economy = economy;
}
private class EconomyServerListener extends ServerListener {
Economy_BOSE6 economy = null;
public void onPluginEnable(PluginEnableEvent event) {
if (economy.economy == null) {
Plugin bose = plugin.getServer().getPluginManager().getPlugin("BOSEconomy");
public EconomyServerListener(Economy_BOSE6 economy) {
this.economy = economy;
}
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 void onPluginEnable(PluginEnableEvent event) {
if (economy.economy == null) {
Plugin bose = plugin.getServer().getPluginManager().getPlugin("BOSEconomy");
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));
}
}
}
}
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 String format(double amount) {
if (amount == 1) {
return String.format("%.0f %s", amount, getMoneyNameSingular());
} else {
return String.format("%.2f %s", amount, getMoneyNamePlural());
}
}
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));
}
}
}
}
@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 createBank(String name, String player) {
boolean success = economy.addBankOwner(name, player, false);
if (success)
return new EconomyResponse(0, economy.getBankMoney(name), ResponseType.SUCCESS, "");
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!");
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 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 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 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!");
}
}

View File

@ -23,6 +23,7 @@ import java.util.logging.Logger;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
@ -98,7 +99,7 @@ public class Economy_BOSE7 implements Economy {
amount = 0;
balance = (double) economy.getPlayerMoney(playerName);
return new EconomyResponse(balance, balance, type, errorMessage);
return new EconomyResponse(amount, balance, type, errorMessage);
}
amount = Math.ceil(amount);
@ -109,7 +110,7 @@ public class Economy_BOSE7 implements Economy {
amount = 0;
balance = (double) economy.getPlayerMoney(playerName);
return new EconomyResponse(balance, balance, type, errorMessage);
return new EconomyResponse(amount, balance, type, errorMessage);
}
if (economy.setPlayerMoney(playerName, (int) (balance - amount), false)) {
type = EconomyResponse.ResponseType.SUCCESS;
@ -138,7 +139,7 @@ public class Economy_BOSE7 implements Economy {
amount = 0;
balance = (double) economy.getPlayerMoney(playerName);
return new EconomyResponse(balance, balance, type, errorMessage);
return new EconomyResponse(amount, balance, type, errorMessage);
}
amount = Math.ceil(amount);
balance = (double) economy.getPlayerMoney(playerName);
@ -153,7 +154,7 @@ public class Economy_BOSE7 implements Economy {
amount = 0;
balance = (double) economy.getPlayerMoney(playerName);
return new EconomyResponse(balance, balance, type, errorMessage);
return new EconomyResponse(amount, balance, type, errorMessage);
}
}
@ -201,4 +202,71 @@ public class Economy_BOSE7 implements Economy {
return String.format("%.2f %s", amount, getMoneyNamePlural());
}
}
@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, "");
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!");
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 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 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 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 boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount;
}
}

View File

@ -23,6 +23,7 @@ import java.util.logging.Logger;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
@ -208,4 +209,39 @@ public class Economy_Essentials implements Economy {
public String format(double amount) {
return com.earth2me.essentials.api.Economy.format(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 bankHas(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 bankDeposit(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 isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
}
}

View File

@ -23,6 +23,7 @@ import java.util.logging.Logger;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
@ -99,7 +100,7 @@ public class Economy_MultiCurrency implements Economy {
amount = 0;
balance = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName);
return new EconomyResponse(balance, balance, type, errorMessage);
return new EconomyResponse(amount, balance, type, errorMessage);
}
if (!CurrencyList.hasEnough(playerName, amount)) {
@ -108,7 +109,7 @@ public class Economy_MultiCurrency implements Economy {
amount = 0;
balance = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName);
return new EconomyResponse(balance, balance, type, errorMessage);
return new EconomyResponse(amount, balance, type, errorMessage);
}
if (CurrencyList.subtract(playerName, amount)) {
@ -138,7 +139,7 @@ public class Economy_MultiCurrency implements Economy {
amount = 0;
balance = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName);
return new EconomyResponse(balance, balance, type, errorMessage);
return new EconomyResponse(amount, balance, type, errorMessage);
}
if (CurrencyList.add(playerName, amount)) {
@ -152,7 +153,7 @@ public class Economy_MultiCurrency implements Economy {
amount = 0;
balance = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName);
return new EconomyResponse(balance, balance, type, errorMessage);
return new EconomyResponse(amount, balance, type, errorMessage);
}
}
@ -188,4 +189,39 @@ public class Economy_MultiCurrency implements Economy {
public String format(double amount) {
return String.format("%.2f %s", amount, "Currency");
}
@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 bankHas(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 bankDeposit(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 isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
}
}

View File

@ -23,6 +23,7 @@ import java.util.logging.Logger;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
@ -199,4 +200,39 @@ public class Economy_iConomy4 implements Economy {
}
}
}
@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 bankHas(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 bankDeposit(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 isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy4 does not support bank accounts!");
}
}

View File

@ -23,6 +23,7 @@ import java.util.logging.Logger;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
@ -105,13 +106,13 @@ public class Economy_iConomy5 implements Economy {
holdings.subtract(amount);
balance = getAccountBalance(playerName);
type = EconomyResponse.ResponseType.SUCCESS;
return new EconomyResponse(balance, balance, type, errorMessage);
return new EconomyResponse(amount, balance, type, errorMessage);
} else {
amount = 0;
balance = getAccountBalance(playerName);
type = EconomyResponse.ResponseType.FAILURE;
errorMessage = "Insufficient funds";
return new EconomyResponse(balance, balance, type, errorMessage);
return new EconomyResponse(amount, balance, type, errorMessage);
}
}
@ -162,4 +163,39 @@ public class Economy_iConomy5 implements Economy {
public String format(double amount) {
return iConomy.format(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 bankHas(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 bankDeposit(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 isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy5 does not support single bank accounts!");
}
}

View File

@ -18,6 +18,7 @@ import com.iCo6.system.Holdings;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
public class Economy_iConomy6 implements Economy {
private static final Logger log = Logger.getLogger("Minecraft");
@ -117,13 +118,13 @@ public class Economy_iConomy6 implements Economy {
holdings.subtract(amount);
balance = holdings.getBalance();
type = EconomyResponse.ResponseType.SUCCESS;
return new EconomyResponse(balance, balance, type, errorMessage);
return new EconomyResponse(amount, balance, type, errorMessage);
} else {
amount = 0;
balance = holdings.getBalance();
type = EconomyResponse.ResponseType.FAILURE;
errorMessage = "Insufficient funds";
return new EconomyResponse(balance, balance, type, errorMessage);
return new EconomyResponse(amount, balance, type, errorMessage);
}
}
@ -142,4 +143,50 @@ public class Economy_iConomy6 implements Economy {
return new EconomyResponse(amount, balance, type, errorMessage);
}
@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.");
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 bankWithdraw(String name, double amount) {
return withdrawPlayer(name, amount);
}
@Override
public EconomyResponse bankDeposit(String name, double amount) {
return depositPlayer(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 isBankMember(String name, String playerName) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy 6 does not support Bank members.");
}
}