fixed BOSE7 implementation it now properly supports Double values and no

longer uses deprecated API. removed BOSE6 jar as it was causing issues
with the BOSE7 API, BOSE6 API is still contained in it.
Added start of Regions interface.
This commit is contained in:
sleak 2011-12-22 13:32:38 -08:00
parent 3a09fe1a73
commit 5307b58b99
14 changed files with 138 additions and 45 deletions

Binary file not shown.

View File

@ -19,6 +19,8 @@
package net.milkbowl.vault.economy; package net.milkbowl.vault.economy;
import java.util.List;
/** /**
* The main economy API * The main economy API
* *
@ -130,4 +132,10 @@ public interface Economy {
* @return * @return
*/ */
public EconomyResponse isBankMember(String name, String playerName); public EconomyResponse isBankMember(String name, String playerName);
/**
* Gets the list of banks
* @return the List of Banks
*/
public List<String> getBanks();
} }

View File

@ -19,6 +19,8 @@
package net.milkbowl.vault.economy.plugins; package net.milkbowl.vault.economy.plugins;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import me.ic3d.eco.ECO; import me.ic3d.eco.ECO;
@ -226,4 +228,9 @@ public class Economy_3co implements Economy {
public EconomyResponse bankBalance(String name) { public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!"); return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
} }
@Override
public List<String> getBanks() {
return new ArrayList<String>();
}
} }

View File

@ -19,6 +19,7 @@
package net.milkbowl.vault.economy.plugins; package net.milkbowl.vault.economy.plugins;
import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
@ -35,6 +36,7 @@ import org.bukkit.plugin.PluginManager;
import cosine.boseconomy.BOSEconomy; import cosine.boseconomy.BOSEconomy;
@SuppressWarnings("deprecation")
public class Economy_BOSE6 implements Economy { public class Economy_BOSE6 implements Economy {
private static final Logger log = Logger.getLogger("Minecraft"); private static final Logger log = Logger.getLogger("Minecraft");
@ -77,14 +79,9 @@ public class Economy_BOSE6 implements Economy {
} }
} }
@Override @Override
public double getBalance(String playerName) { public double getBalance(String playerName) {
final double balance; return (double) economy.getPlayerMoney(playerName);
balance = (double) economy.getPlayerMoney(playerName);
final double fBalance = balance;
return fBalance;
} }
@Override @Override
@ -113,7 +110,6 @@ public class Economy_BOSE6 implements Economy {
errorMessage = "Insufficient funds"; errorMessage = "Insufficient funds";
type = EconomyResponse.ResponseType.FAILURE; type = EconomyResponse.ResponseType.FAILURE;
amount = 0; amount = 0;
balance = (double) economy.getPlayerMoney(playerName);
return new EconomyResponse(balance, balance, type, errorMessage); return new EconomyResponse(balance, balance, type, errorMessage);
} }
@ -279,4 +275,9 @@ public class Economy_BOSE6 implements Economy {
double bankMoney = economy.getBankMoney(name); double bankMoney = economy.getBankMoney(name);
return new EconomyResponse(0, bankMoney, ResponseType.SUCCESS, null); return new EconomyResponse(0, bankMoney, ResponseType.SUCCESS, null);
} }
@Override
public List<String> getBanks() {
return economy.getBankList();
}
} }

View File

@ -19,6 +19,7 @@
package net.milkbowl.vault.economy.plugins; package net.milkbowl.vault.economy.plugins;
import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
@ -81,7 +82,7 @@ public class Economy_BOSE7 implements Economy {
public double getBalance(String playerName) { public double getBalance(String playerName) {
final double balance; final double balance;
balance = (double) economy.getPlayerMoney(playerName); balance = economy.getPlayerMoneyDouble(playerName);
final double fBalance = balance; final double fBalance = balance;
return fBalance; return fBalance;
@ -97,31 +98,30 @@ public class Economy_BOSE7 implements Economy {
errorMessage = "Cannot withdraw negative funds"; errorMessage = "Cannot withdraw negative funds";
type = EconomyResponse.ResponseType.FAILURE; type = EconomyResponse.ResponseType.FAILURE;
amount = 0; amount = 0;
balance = (double) economy.getPlayerMoney(playerName); balance = economy.getPlayerMoneyDouble(playerName);
return new EconomyResponse(amount, balance, type, errorMessage); return new EconomyResponse(amount, balance, type, errorMessage);
} }
amount = Math.ceil(amount); amount = Math.ceil(amount);
balance = (double) economy.getPlayerMoney(playerName); balance = economy.getPlayerMoneyDouble(playerName);
if (balance - amount < 0) { if (balance - amount < 0) {
errorMessage = "Insufficient funds"; errorMessage = "Insufficient funds";
type = EconomyResponse.ResponseType.FAILURE; type = EconomyResponse.ResponseType.FAILURE;
amount = 0; amount = 0;
balance = (double) economy.getPlayerMoney(playerName);
return new EconomyResponse(amount, balance, type, errorMessage); return new EconomyResponse(amount, balance, type, errorMessage);
} }
if (economy.setPlayerMoney(playerName, (int) (balance - amount), false)) { if (economy.setPlayerMoney(playerName, balance - amount, false)) {
type = EconomyResponse.ResponseType.SUCCESS; type = EconomyResponse.ResponseType.SUCCESS;
balance = (double) economy.getPlayerMoney(playerName); balance = economy.getPlayerMoneyDouble(playerName);
return new EconomyResponse(amount, balance, type, errorMessage); return new EconomyResponse(amount, balance, type, errorMessage);
} else { } else {
errorMessage = "Error withdrawing funds"; errorMessage = "Error withdrawing funds";
type = EconomyResponse.ResponseType.FAILURE; type = EconomyResponse.ResponseType.FAILURE;
amount = 0; amount = 0;
balance = (double) economy.getPlayerMoney(playerName); balance = economy.getPlayerMoneyDouble(playerName);
return new EconomyResponse(amount, balance, type, errorMessage); return new EconomyResponse(amount, balance, type, errorMessage);
} }
@ -137,22 +137,21 @@ public class Economy_BOSE7 implements Economy {
errorMessage = "Cannot deposit negative funds"; errorMessage = "Cannot deposit negative funds";
type = EconomyResponse.ResponseType.FAILURE; type = EconomyResponse.ResponseType.FAILURE;
amount = 0; amount = 0;
balance = (double) economy.getPlayerMoney(playerName);
return new EconomyResponse(amount, balance, type, errorMessage); return new EconomyResponse(amount, economy.getPlayerMoneyDouble(playerName), type, errorMessage);
} }
amount = Math.ceil(amount); amount = Math.ceil(amount);
balance = (double) economy.getPlayerMoney(playerName); balance = economy.getPlayerMoneyDouble(playerName);
if (economy.setPlayerMoney(playerName, (int) (balance + amount), false)) { if (economy.setPlayerMoney(playerName, balance + amount, false)) {
type = EconomyResponse.ResponseType.SUCCESS; type = EconomyResponse.ResponseType.SUCCESS;
balance = (double) economy.getPlayerMoney(playerName); balance = economy.getPlayerMoneyDouble(playerName);
return new EconomyResponse(amount, balance, type, errorMessage); return new EconomyResponse(amount, balance, type, errorMessage);
} else { } else {
errorMessage = "Error withdrawing funds"; errorMessage = "Error withdrawing funds";
type = EconomyResponse.ResponseType.FAILURE; type = EconomyResponse.ResponseType.FAILURE;
amount = 0; amount = 0;
balance = (double) economy.getPlayerMoney(playerName); balance = economy.getPlayerMoneyDouble(playerName);
return new EconomyResponse(amount, balance, type, errorMessage); return new EconomyResponse(amount, balance, type, errorMessage);
} }
@ -202,11 +201,12 @@ public class Economy_BOSE7 implements Economy {
return String.format("%.2f %s", amount, getMoneyNamePlural()); return String.format("%.2f %s", amount, getMoneyNamePlural());
} }
} }
@Override @Override
public EconomyResponse createBank(String name, String player) { public EconomyResponse createBank(String name, String player) {
boolean success = economy.addBankOwner(name, player, false); boolean success = economy.addBankOwner(name, player, false);
if (success) if (success)
return new EconomyResponse(0, economy.getBankMoney(name), ResponseType.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.");
} }
@ -216,7 +216,7 @@ public class Economy_BOSE7 implements Economy {
if (!economy.bankExists(name)) if (!economy.bankExists(name))
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!"); return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
double bankMoney = economy.getBankMoney(name); double bankMoney = economy.getBankMoneyDouble(name);
if (bankMoney < amount) if (bankMoney < amount)
return new EconomyResponse(0, bankMoney, ResponseType.FAILURE, "The bank does not have enough money!"); return new EconomyResponse(0, bankMoney, ResponseType.FAILURE, "The bank does not have enough money!");
else else
@ -230,8 +230,8 @@ public class Economy_BOSE7 implements Economy {
if (!er.transactionSuccess()) if (!er.transactionSuccess())
return er; return er;
else { else {
economy.addBankMoney(name, (int) -amount, true); economy.addBankMoney(name, -amount, true);
return new EconomyResponse((int) amount, economy.getBankMoney(name), ResponseType.SUCCESS, ""); return new EconomyResponse(amount, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
} }
} }
@ -240,8 +240,8 @@ public class Economy_BOSE7 implements Economy {
if (!economy.bankExists(name)) if (!economy.bankExists(name))
return new EconomyResponse(amount, 0, ResponseType.FAILURE, "That bank does not exist!"); return new EconomyResponse(amount, 0, ResponseType.FAILURE, "That bank does not exist!");
else { else {
economy.addBankMoney(name, (int) amount, true); economy.addBankMoney(name, amount, true);
return new EconomyResponse((int) amount, economy.getBankMoney(name), ResponseType.SUCCESS, ""); return new EconomyResponse(amount, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
} }
} }
@ -250,7 +250,7 @@ public class Economy_BOSE7 implements Economy {
if (!economy.bankExists(name)) if (!economy.bankExists(name))
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!"); return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
else if (economy.isBankOwner(name, playerName)) { else if (economy.isBankOwner(name, playerName)) {
return new EconomyResponse(0, economy.getBankMoney(name), ResponseType.SUCCESS, ""); return new EconomyResponse(0, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
} else } else
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player is not a bank owner!"); return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player is not a bank owner!");
} }
@ -260,7 +260,7 @@ public class Economy_BOSE7 implements Economy {
if (!economy.bankExists(name)) if (!economy.bankExists(name))
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!"); return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
else if (economy.isBankMember(name, playerName)) { else if (economy.isBankMember(name, playerName)) {
return new EconomyResponse(0, economy.getBankMoney(name), ResponseType.SUCCESS, ""); return new EconomyResponse(0, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
} else } else
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player is not a bank member!"); return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player is not a bank member!");
} }
@ -270,10 +270,15 @@ public class Economy_BOSE7 implements Economy {
if (!economy.bankExists(name)) if (!economy.bankExists(name))
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!"); return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
double bankMoney = economy.getBankMoney(name); double bankMoney = economy.getBankMoneyDouble(name);
return new EconomyResponse(0, bankMoney, ResponseType.SUCCESS, null); return new EconomyResponse(0, bankMoney, ResponseType.SUCCESS, null);
} }
@Override
public List<String> getBanks() {
return economy.getBankList();
}
@Override @Override
public boolean has(String playerName, double amount) { public boolean has(String playerName, double amount) {
return getBalance(playerName) >= amount; return getBalance(playerName) >= amount;

View File

@ -1,5 +1,7 @@
package net.milkbowl.vault.economy.plugins; package net.milkbowl.vault.economy.plugins;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
@ -189,4 +191,9 @@ public class Economy_EconXP implements Economy {
public EconomyResponse bankBalance(String name) { public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!"); return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
} }
@Override
public List<String> getBanks() {
return new ArrayList<String>();
}
} }

View File

@ -19,6 +19,8 @@
package net.milkbowl.vault.economy.plugins; package net.milkbowl.vault.economy.plugins;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
@ -90,8 +92,7 @@ public class Economy_Essentials implements Economy {
balance = 0; balance = 0;
} }
final double fBalance = balance; return balance;
return fBalance;
} }
private boolean createPlayerAccount(String playerName) { private boolean createPlayerAccount(String playerName) {
@ -249,4 +250,9 @@ public class Economy_Essentials implements Economy {
public EconomyResponse bankBalance(String name) { public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!"); return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
} }
@Override
public List<String> getBanks() {
return new ArrayList<String>();
}
} }

View File

@ -1,5 +1,7 @@
package net.milkbowl.vault.economy.plugins; package net.milkbowl.vault.economy.plugins;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import me.mjolnir.mineconomy.Accounting; import me.mjolnir.mineconomy.Accounting;
@ -158,4 +160,9 @@ public class Economy_MineConomy implements Economy {
public EconomyResponse bankBalance(String name) { public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!"); return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
} }
@Override
public List<String> getBanks() {
return new ArrayList<String>();
}
} }

View File

@ -19,6 +19,8 @@
package net.milkbowl.vault.economy.plugins; package net.milkbowl.vault.economy.plugins;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
@ -229,4 +231,9 @@ public class Economy_MultiCurrency implements Economy {
public EconomyResponse bankBalance(String name) { public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts"); return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
} }
@Override
public List<String> getBanks() {
return new ArrayList<String>();
}
} }

View File

@ -1,5 +1,7 @@
package net.milkbowl.vault.economy.plugins; package net.milkbowl.vault.economy.plugins;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import me.ethan.eWallet.ECO; import me.ethan.eWallet.ECO;
@ -165,4 +167,9 @@ public class Economy_eWallet implements Economy {
public EconomyResponse bankBalance(String name) { public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!"); return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
} }
@Override
public List<String> getBanks() {
return new ArrayList<String>();
}
} }

View File

@ -19,6 +19,8 @@
package net.milkbowl.vault.economy.plugins; package net.milkbowl.vault.economy.plugins;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
@ -93,12 +95,7 @@ public class Economy_iConomy4 implements Economy {
@Override @Override
public double getBalance(String playerName) { public double getBalance(String playerName) {
final double balance; return getAccountBalance(playerName);
balance = getAccountBalance(playerName);
final double fBalance = balance;
return fBalance;
} }
private double getAccountBalance(String playerName) { private double getAccountBalance(String playerName) {
@ -240,4 +237,9 @@ public class Economy_iConomy4 implements Economy {
public EconomyResponse bankBalance(String name) { public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy4 does not support bank accounts!"); return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy4 does not support bank accounts!");
} }
@Override
public List<String> getBanks() {
return new ArrayList<String>();
}
} }

View File

@ -19,6 +19,8 @@
package net.milkbowl.vault.economy.plugins; package net.milkbowl.vault.economy.plugins;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
@ -86,12 +88,7 @@ public class Economy_iConomy5 implements Economy {
@Override @Override
public double getBalance(String playerName) { public double getBalance(String playerName) {
final double balance; return getAccountBalance(playerName);
balance = getAccountBalance(playerName);
final double fBalance = balance;
return fBalance;
} }
@Override @Override
@ -203,4 +200,9 @@ public class Economy_iConomy5 implements Economy {
public EconomyResponse bankBalance(String name) { public EconomyResponse bankBalance(String name) {
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy5 does not support single bank accounts!"); return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy5 does not support single bank accounts!");
} }
@Override
public List<String> getBanks() {
return new ArrayList<String>();
}
} }

View File

@ -1,5 +1,6 @@
package net.milkbowl.vault.economy.plugins; package net.milkbowl.vault.economy.plugins;
import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.event.Event.Priority; import org.bukkit.event.Event.Priority;
@ -197,4 +198,8 @@ public class Economy_iConomy6 implements Economy {
return new EconomyResponse(0, accounts.get(name).getHoldings().getBalance(), ResponseType.SUCCESS, null); return new EconomyResponse(0, accounts.get(name).getHoldings().getBalance(), ResponseType.SUCCESS, null);
} }
@Override
public List<String> getBanks() {
throw new UnsupportedOperationException("iConomy does not support listing of bank accounts");
}
} }

View File

@ -0,0 +1,29 @@
package net.milkbowl.vault.regions;
import java.util.Set;
import org.bukkit.entity.Player;
public abstract class Regions {
/**
* Gets name of regions method
* @return Name of Regions Method
*/
abstract public String getName();
/**
* Checks if this regions method is enabled.
* @return Success or Failure
*/
abstract public boolean isEnabled();
abstract public boolean playerInRegion(Player player, String name);
abstract public Set<String> getRegions(Player player);
abstract public boolean canBuild(Player player);
abstract public boolean canUse(Player player);
}