mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-11-23 11:05:48 +01:00
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:
parent
3a09fe1a73
commit
5307b58b99
Binary file not shown.
@ -19,6 +19,8 @@
|
||||
|
||||
package net.milkbowl.vault.economy;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The main economy API
|
||||
*
|
||||
@ -130,4 +132,10 @@ public interface Economy {
|
||||
* @return
|
||||
*/
|
||||
public EconomyResponse isBankMember(String name, String playerName);
|
||||
|
||||
/**
|
||||
* Gets the list of banks
|
||||
* @return the List of Banks
|
||||
*/
|
||||
public List<String> getBanks();
|
||||
}
|
@ -19,6 +19,8 @@
|
||||
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import me.ic3d.eco.ECO;
|
||||
@ -226,4 +228,9 @@ public class Economy_3co implements Economy {
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
@ -35,6 +36,7 @@ import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import cosine.boseconomy.BOSEconomy;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class Economy_BOSE6 implements Economy {
|
||||
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) {
|
||||
final double balance;
|
||||
|
||||
balance = (double) economy.getPlayerMoney(playerName);
|
||||
|
||||
final double fBalance = balance;
|
||||
return fBalance;
|
||||
return (double) economy.getPlayerMoney(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -113,7 +110,6 @@ public class Economy_BOSE6 implements Economy {
|
||||
errorMessage = "Insufficient funds";
|
||||
type = EconomyResponse.ResponseType.FAILURE;
|
||||
amount = 0;
|
||||
balance = (double) economy.getPlayerMoney(playerName);
|
||||
|
||||
return new EconomyResponse(balance, balance, type, errorMessage);
|
||||
}
|
||||
@ -279,4 +275,9 @@ public class Economy_BOSE6 implements Economy {
|
||||
double bankMoney = economy.getBankMoney(name);
|
||||
return new EconomyResponse(0, bankMoney, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return economy.getBankList();
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
@ -81,7 +82,7 @@ public class Economy_BOSE7 implements Economy {
|
||||
public double getBalance(String playerName) {
|
||||
final double balance;
|
||||
|
||||
balance = (double) economy.getPlayerMoney(playerName);
|
||||
balance = economy.getPlayerMoneyDouble(playerName);
|
||||
|
||||
final double fBalance = balance;
|
||||
return fBalance;
|
||||
@ -97,31 +98,30 @@ public class Economy_BOSE7 implements Economy {
|
||||
errorMessage = "Cannot withdraw negative funds";
|
||||
type = EconomyResponse.ResponseType.FAILURE;
|
||||
amount = 0;
|
||||
balance = (double) economy.getPlayerMoney(playerName);
|
||||
balance = economy.getPlayerMoneyDouble(playerName);
|
||||
|
||||
return new EconomyResponse(amount, balance, type, errorMessage);
|
||||
}
|
||||
|
||||
amount = Math.ceil(amount);
|
||||
balance = (double) economy.getPlayerMoney(playerName);
|
||||
balance = economy.getPlayerMoneyDouble(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);
|
||||
}
|
||||
if (economy.setPlayerMoney(playerName, (int) (balance - amount), false)) {
|
||||
if (economy.setPlayerMoney(playerName, balance - amount, false)) {
|
||||
type = EconomyResponse.ResponseType.SUCCESS;
|
||||
balance = (double) economy.getPlayerMoney(playerName);
|
||||
balance = economy.getPlayerMoneyDouble(playerName);
|
||||
|
||||
return new EconomyResponse(amount, balance, type, errorMessage);
|
||||
} else {
|
||||
errorMessage = "Error withdrawing funds";
|
||||
type = EconomyResponse.ResponseType.FAILURE;
|
||||
amount = 0;
|
||||
balance = (double) economy.getPlayerMoney(playerName);
|
||||
balance = economy.getPlayerMoneyDouble(playerName);
|
||||
|
||||
return new EconomyResponse(amount, balance, type, errorMessage);
|
||||
}
|
||||
@ -137,22 +137,21 @@ public class Economy_BOSE7 implements Economy {
|
||||
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(amount, economy.getPlayerMoneyDouble(playerName), type, errorMessage);
|
||||
}
|
||||
amount = Math.ceil(amount);
|
||||
balance = (double) economy.getPlayerMoney(playerName);
|
||||
if (economy.setPlayerMoney(playerName, (int) (balance + amount), false)) {
|
||||
balance = economy.getPlayerMoneyDouble(playerName);
|
||||
if (economy.setPlayerMoney(playerName, balance + amount, false)) {
|
||||
type = EconomyResponse.ResponseType.SUCCESS;
|
||||
balance = (double) economy.getPlayerMoney(playerName);
|
||||
balance = economy.getPlayerMoneyDouble(playerName);
|
||||
|
||||
return new EconomyResponse(amount, balance, type, errorMessage);
|
||||
} else {
|
||||
errorMessage = "Error withdrawing funds";
|
||||
type = EconomyResponse.ResponseType.FAILURE;
|
||||
amount = 0;
|
||||
balance = (double) economy.getPlayerMoney(playerName);
|
||||
balance = economy.getPlayerMoneyDouble(playerName);
|
||||
|
||||
return new EconomyResponse(amount, balance, type, errorMessage);
|
||||
}
|
||||
@ -202,11 +201,12 @@ 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, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
|
||||
|
||||
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))
|
||||
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)
|
||||
return new EconomyResponse(0, bankMoney, ResponseType.FAILURE, "The bank does not have enough money!");
|
||||
else
|
||||
@ -230,8 +230,8 @@ public class Economy_BOSE7 implements Economy {
|
||||
if (!er.transactionSuccess())
|
||||
return er;
|
||||
else {
|
||||
economy.addBankMoney(name, (int) -amount, true);
|
||||
return new EconomyResponse((int) amount, economy.getBankMoney(name), ResponseType.SUCCESS, "");
|
||||
economy.addBankMoney(name, -amount, true);
|
||||
return new EconomyResponse(amount, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,8 +240,8 @@ public class Economy_BOSE7 implements Economy {
|
||||
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, "");
|
||||
economy.addBankMoney(name, amount, true);
|
||||
return new EconomyResponse(amount, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,7 +250,7 @@ public class Economy_BOSE7 implements Economy {
|
||||
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, "");
|
||||
return new EconomyResponse(0, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
|
||||
} else
|
||||
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))
|
||||
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, "");
|
||||
return new EconomyResponse(0, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
|
||||
} else
|
||||
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))
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return economy.getBankList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
return getBalance(playerName) >= amount;
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -189,4 +191,9 @@ public class Economy_EconXP implements Economy {
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
@ -90,8 +92,7 @@ public class Economy_Essentials implements Economy {
|
||||
balance = 0;
|
||||
}
|
||||
|
||||
final double fBalance = balance;
|
||||
return fBalance;
|
||||
return balance;
|
||||
}
|
||||
|
||||
private boolean createPlayerAccount(String playerName) {
|
||||
@ -249,4 +250,9 @@ public class Economy_Essentials implements Economy {
|
||||
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() {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import me.mjolnir.mineconomy.Accounting;
|
||||
@ -158,4 +160,9 @@ public class Economy_MineConomy implements Economy {
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
@ -229,4 +231,9 @@ public class Economy_MultiCurrency implements Economy {
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import me.ethan.eWallet.ECO;
|
||||
@ -165,4 +167,9 @@ public class Economy_eWallet implements Economy {
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "3co does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
@ -93,12 +95,7 @@ public class Economy_iConomy4 implements Economy {
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
final double balance;
|
||||
|
||||
balance = getAccountBalance(playerName);
|
||||
|
||||
final double fBalance = balance;
|
||||
return fBalance;
|
||||
return getAccountBalance(playerName);
|
||||
}
|
||||
|
||||
private double getAccountBalance(String playerName) {
|
||||
@ -240,4 +237,9 @@ public class Economy_iConomy4 implements Economy {
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy4 does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
@ -19,6 +19,8 @@
|
||||
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
@ -86,12 +88,7 @@ public class Economy_iConomy5 implements Economy {
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
final double balance;
|
||||
|
||||
balance = getAccountBalance(playerName);
|
||||
|
||||
final double fBalance = balance;
|
||||
return fBalance;
|
||||
return getAccountBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -203,4 +200,9 @@ public class Economy_iConomy5 implements Economy {
|
||||
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() {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.event.Event.Priority;
|
||||
@ -196,5 +197,9 @@ public class Economy_iConomy6 implements Economy {
|
||||
else
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
29
src/net/milkbowl/vault/regions/Regions.java
Normal file
29
src/net/milkbowl/vault/regions/Regions.java
Normal 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);
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user