mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-11-23 11:05:48 +01:00
revert abstracting the interface.
This commit is contained in:
parent
f76441fdf4
commit
7ff0b98b94
@ -22,25 +22,25 @@ import java.util.List;
|
||||
* The main economy API
|
||||
*
|
||||
*/
|
||||
public abstract class Economy {
|
||||
public interface Economy {
|
||||
|
||||
/**
|
||||
* Checks if economy method is enabled.
|
||||
* @return Success or Failure
|
||||
*/
|
||||
public abstract boolean isEnabled();
|
||||
public boolean isEnabled();
|
||||
|
||||
/**
|
||||
* Gets name of permission method
|
||||
* @return Name of Permission Method
|
||||
*/
|
||||
public abstract String getName();
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Returns true if the given implementation supports banks.
|
||||
* @return true if the implementation supports banks
|
||||
*/
|
||||
public abstract boolean hasBankSupport();
|
||||
public boolean hasBankSupport();
|
||||
|
||||
/**
|
||||
* Some economy plugins round off after a certain number of digits.
|
||||
@ -48,7 +48,7 @@ public abstract class Economy {
|
||||
* or -1 if no rounding occurs.
|
||||
* @return number of digits after the decimal point kept
|
||||
*/
|
||||
public abstract int fractionalDigits();
|
||||
public int fractionalDigits();
|
||||
|
||||
/**
|
||||
* Format amount into a human readable String This provides translation into
|
||||
@ -57,7 +57,7 @@ public abstract class Economy {
|
||||
* @param amount
|
||||
* @return Human readable string describing amount
|
||||
*/
|
||||
public abstract String format(double amount);
|
||||
public String format(double amount);
|
||||
|
||||
/**
|
||||
* Returns the name of the currency in plural form.
|
||||
@ -65,7 +65,7 @@ public abstract class Economy {
|
||||
*
|
||||
* @return name of the currency (plural)
|
||||
*/
|
||||
public abstract String currencyNamePlural();
|
||||
public String currencyNamePlural();
|
||||
|
||||
|
||||
/**
|
||||
@ -74,7 +74,7 @@ public abstract class Economy {
|
||||
*
|
||||
* @return name of the currency (singular)
|
||||
*/
|
||||
public abstract String currencyNameSingular();
|
||||
public String currencyNameSingular();
|
||||
|
||||
/**
|
||||
* Checks if this player has an account on the server yet
|
||||
@ -83,7 +83,7 @@ public abstract class Economy {
|
||||
* @param playerName
|
||||
* @return if the player has an account
|
||||
*/
|
||||
public abstract boolean hasAccount(String playerName);
|
||||
public boolean hasAccount(String playerName);
|
||||
|
||||
|
||||
/**
|
||||
@ -91,7 +91,7 @@ public abstract class Economy {
|
||||
* @param playerName
|
||||
* @return Amount currently held in players account
|
||||
*/
|
||||
public abstract double getBalance(String playerName);
|
||||
public double getBalance(String playerName);
|
||||
|
||||
/**
|
||||
* Checks if the player account has the amount - DO NOT USE NEGATIVE AMOUNTS
|
||||
@ -100,7 +100,7 @@ public abstract class Economy {
|
||||
* @param amount
|
||||
* @return True if <b>playerName</b> has <b>amount</b>, False else wise
|
||||
*/
|
||||
public abstract boolean has(String playerName, double amount);
|
||||
public boolean has(String playerName, double amount);
|
||||
|
||||
/**
|
||||
* Withdraw an amount from a player - DO NOT USE NEGATIVE AMOUNTS
|
||||
@ -109,7 +109,7 @@ public abstract class Economy {
|
||||
* @param amount Amount to withdraw
|
||||
* @return Detailed response of transaction
|
||||
*/
|
||||
public abstract EconomyResponse withdrawPlayer(String playerName, double amount);
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount);
|
||||
|
||||
/**
|
||||
* Deposit an amount to a player - DO NOT USE NEGATIVE AMOUNTS
|
||||
@ -118,7 +118,7 @@ public abstract class Economy {
|
||||
* @param amount Amount to deposit
|
||||
* @return Detailed response of transaction
|
||||
*/
|
||||
public abstract EconomyResponse depositPlayer(String playerName, double amount);
|
||||
public EconomyResponse depositPlayer(String playerName, double amount);
|
||||
|
||||
/**
|
||||
* Creates a bank account with the specified name and the player as the owner
|
||||
@ -126,21 +126,21 @@ public abstract class Economy {
|
||||
* @param player
|
||||
* @return EconomyResponse Object
|
||||
*/
|
||||
public abstract EconomyResponse createBank(String name, String player);
|
||||
public EconomyResponse createBank(String name, String player);
|
||||
|
||||
/**
|
||||
* Deletes a bank account with the specified name.
|
||||
* @param name
|
||||
* @return if the operation completed successfully
|
||||
*/
|
||||
public abstract EconomyResponse deleteBank(String name);
|
||||
public EconomyResponse deleteBank(String name);
|
||||
|
||||
/**
|
||||
* Returns the amount the bank has
|
||||
* @param name
|
||||
* @return EconomyResponse Object
|
||||
*/
|
||||
public abstract EconomyResponse bankBalance(String name);
|
||||
public EconomyResponse bankBalance(String name);
|
||||
|
||||
/**
|
||||
* Returns true or false whether the bank has the amount specified - DO NOT USE NEGATIVE AMOUNTS
|
||||
@ -149,7 +149,7 @@ public abstract class Economy {
|
||||
* @param amount
|
||||
* @return EconomyResponse Object
|
||||
*/
|
||||
public abstract EconomyResponse bankHas(String name, double amount);
|
||||
public EconomyResponse bankHas(String name, double amount);
|
||||
|
||||
/**
|
||||
* Withdraw an amount from a bank account - DO NOT USE NEGATIVE AMOUNTS
|
||||
@ -158,7 +158,7 @@ public abstract class Economy {
|
||||
* @param amount
|
||||
* @return EconomyResponse Object
|
||||
*/
|
||||
public abstract EconomyResponse bankWithdraw(String name, double amount);
|
||||
public EconomyResponse bankWithdraw(String name, double amount);
|
||||
|
||||
/**
|
||||
* Deposit an amount into a bank account - DO NOT USE NEGATIVE AMOUNTS
|
||||
@ -167,7 +167,7 @@ public abstract class Economy {
|
||||
* @param amount
|
||||
* @return EconomyResponse Object
|
||||
*/
|
||||
public abstract EconomyResponse bankDeposit(String name, double amount);
|
||||
public EconomyResponse bankDeposit(String name, double amount);
|
||||
|
||||
/**
|
||||
* Check if a player is the owner of a bank account
|
||||
@ -175,7 +175,7 @@ public abstract class Economy {
|
||||
* @param playerName
|
||||
* @return EconomyResponse Object
|
||||
*/
|
||||
public abstract EconomyResponse isBankOwner(String name, String playerName);
|
||||
public EconomyResponse isBankOwner(String name, String playerName);
|
||||
|
||||
/**
|
||||
* Check if the player is a member of the bank account
|
||||
@ -183,17 +183,17 @@ public abstract class Economy {
|
||||
* @param playerName
|
||||
* @return EconomyResponse Object
|
||||
*/
|
||||
public abstract EconomyResponse isBankMember(String name, String playerName);
|
||||
public EconomyResponse isBankMember(String name, String playerName);
|
||||
|
||||
/**
|
||||
* Gets the list of banks
|
||||
* @return the List of Banks
|
||||
*/
|
||||
public abstract List<String> getBanks();
|
||||
public List<String> getBanks();
|
||||
|
||||
/**
|
||||
* Attempts to create a player account for the given player
|
||||
* @return if the account creation was successful
|
||||
*/
|
||||
public abstract boolean createPlayerAccount(String playerName);
|
||||
public boolean createPlayerAccount(String playerName);
|
||||
}
|
@ -34,7 +34,7 @@ import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Economy_3co extends Economy {
|
||||
public class Economy_3co implements Economy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "3co";
|
||||
|
@ -35,7 +35,7 @@ import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.neocraft.AEco.AEco;
|
||||
|
||||
public class Economy_AEco extends Economy {
|
||||
public class Economy_AEco implements Economy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "AEco";
|
||||
|
@ -34,7 +34,7 @@ import org.bukkit.plugin.Plugin;
|
||||
import cosine.boseconomy.BOSEconomy;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class Economy_BOSE6 extends Economy {
|
||||
public class Economy_BOSE6 implements Economy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "BOSEconomy";
|
||||
|
@ -32,7 +32,7 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
import cosine.boseconomy.BOSEconomy;
|
||||
|
||||
public class Economy_BOSE7 extends Economy {
|
||||
public class Economy_BOSE7 implements Economy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "BOSEconomy";
|
||||
|
@ -18,7 +18,7 @@ import com.github.zathrus_writer.commandsex.api.economy.Economy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||
|
||||
public class Economy_CommandsEX extends net.milkbowl.vault.economy.Economy {
|
||||
public class Economy_CommandsEX implements net.milkbowl.vault.economy.Economy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "CommandsEX Economy";
|
||||
|
@ -38,7 +38,7 @@ import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Economy_Craftconomy extends Economy {
|
||||
public class Economy_Craftconomy implements Economy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "Craftconomy";
|
||||
|
@ -38,7 +38,7 @@ import com.greatmancode.craftconomy3.account.Account;
|
||||
import com.greatmancode.craftconomy3.currency.CurrencyManager;
|
||||
import com.greatmancode.craftconomy3.database.tables.AccountTable;
|
||||
|
||||
public class Economy_Craftconomy3 extends Economy {
|
||||
public class Economy_Craftconomy3 implements Economy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "Craftconomy3";
|
||||
|
@ -33,7 +33,7 @@ import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Economy_CurrencyCore extends Economy {
|
||||
public class Economy_CurrencyCore implements Economy {
|
||||
|
||||
private Currency currency;
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
@ -26,7 +26,7 @@ import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
|
||||
|
||||
public class Economy_Dosh extends Economy {
|
||||
public class Economy_Dosh implements Economy {
|
||||
|
||||
|
||||
Plugin plugin;
|
||||
|
@ -35,7 +35,7 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
import ca.agnate.EconXP.EconXP;
|
||||
|
||||
public class Economy_EconXP extends Economy {
|
||||
public class Economy_EconXP implements Economy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "EconXP";
|
||||
|
@ -35,7 +35,7 @@ import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.api.NoLoanPermittedException;
|
||||
import com.earth2me.essentials.api.UserDoesNotExistException;
|
||||
|
||||
public class Economy_Essentials extends Economy {
|
||||
public class Economy_Essentials implements Economy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "Essentials Economy";
|
||||
|
@ -33,7 +33,7 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.flobi.GoldIsMoney.GoldIsMoney;
|
||||
|
||||
public class Economy_GoldIsMoney extends Economy {
|
||||
public class Economy_GoldIsMoney implements Economy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "GoldIsMoney";
|
||||
|
@ -32,7 +32,7 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.flobi.GoldIsMoney2.GoldIsMoney;
|
||||
|
||||
public class Economy_GoldIsMoney2 extends Economy {
|
||||
public class Economy_GoldIsMoney2 implements Economy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "GoldIsMoney";
|
||||
|
@ -34,7 +34,7 @@ import org.gestern.gringotts.Account;
|
||||
import org.gestern.gringotts.AccountHolder;
|
||||
import org.gestern.gringotts.Gringotts;
|
||||
|
||||
public class Economy_Gringotts extends Economy {
|
||||
public class Economy_Gringotts implements Economy {
|
||||
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
|
@ -33,7 +33,7 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
import boardinggamer.mcmoney.McMoneyAPI;
|
||||
|
||||
public class Economy_McMoney extends Economy {
|
||||
public class Economy_McMoney implements Economy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "McMoney";
|
||||
|
@ -36,7 +36,7 @@ import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Economy_MineConomy extends Economy {
|
||||
public class Economy_MineConomy implements Economy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "MineConomy";
|
||||
|
@ -33,7 +33,7 @@ import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Economy_MultiCurrency extends Economy {
|
||||
public class Economy_MultiCurrency implements Economy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "MultiCurrency";
|
||||
|
@ -31,7 +31,7 @@ import com.github.omwah.SDFEconomy.SDFEconomyAPI;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
|
||||
public class Economy_SDFEconomy extends Economy {
|
||||
public class Economy_SDFEconomy implements Economy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private Plugin plugin = null;
|
||||
|
||||
|
@ -35,324 +35,325 @@ import com.gmail.mirelatrue.xpbank.API;
|
||||
import com.gmail.mirelatrue.xpbank.Account;
|
||||
import com.gmail.mirelatrue.xpbank.GroupBank;
|
||||
import com.gmail.mirelatrue.xpbank.XPBank;
|
||||
|
||||
public class Economy_XPBank implements Economy {
|
||||
|
||||
public class Economy_XPBank extends Economy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
|
||||
private final String name = "XPBank";
|
||||
private Plugin plugin = null;
|
||||
private XPBank XPB = null;
|
||||
private API api = null;
|
||||
|
||||
public Economy_XPBank (Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (XPB == null) {
|
||||
Plugin economy = plugin.getServer().getPluginManager().getPlugin("XPBank");
|
||||
if (economy != null && economy.isEnabled()) {
|
||||
XPB = (XPBank) economy;
|
||||
api = XPB.getAPI();
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
Economy_XPBank economy = null;
|
||||
|
||||
public EconomyServerListener (Economy_XPBank economy_XPBank) {
|
||||
this.economy = economy_XPBank;
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable (PluginEnableEvent event) {
|
||||
if (economy.XPB == null) {
|
||||
Plugin eco = plugin.getServer().getPluginManager().getPlugin("XPBank");
|
||||
|
||||
if (eco != null && eco.isEnabled()) {
|
||||
economy.XPB = (XPBank) eco;
|
||||
api = XPB.getAPI();
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable (PluginDisableEvent event) {
|
||||
if (economy.XPB != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("XPBank")) {
|
||||
economy.XPB = null;
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled () {
|
||||
return this.XPB != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName () {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport () {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits () {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format (double amount) {
|
||||
return String.format("%d %s", (int) amount, api.currencyName((int) amount));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural () {
|
||||
return api.getMsg("CurrencyNamePlural");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular () {
|
||||
return api.getMsg("currencyName");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount (String playerName) {
|
||||
Account account = api.getAccount(playerName);
|
||||
|
||||
if (account != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance (String playerName) {
|
||||
Account account = api.getAccount(playerName);
|
||||
|
||||
return account.getBalance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has (String playerName, double amount) {
|
||||
Account account = api.getAccount(playerName);
|
||||
|
||||
if (account.getBalance() >= (int) amount) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
private final String name = "XPBank";
|
||||
private Plugin plugin = null;
|
||||
private XPBank XPB = null;
|
||||
private API api = null;
|
||||
|
||||
public Economy_XPBank (Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (XPB == null) {
|
||||
Plugin economy = plugin.getServer().getPluginManager().getPlugin("XPBank");
|
||||
if (economy != null && economy.isEnabled()) {
|
||||
XPB = (XPBank) economy;
|
||||
api = XPB.getAPI();
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
Economy_XPBank economy = null;
|
||||
|
||||
public EconomyServerListener (Economy_XPBank economy_XPBank) {
|
||||
this.economy = economy_XPBank;
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable (PluginEnableEvent event) {
|
||||
if (economy.XPB == null) {
|
||||
Plugin eco = plugin.getServer().getPluginManager().getPlugin("XPBank");
|
||||
|
||||
if (eco != null && eco.isEnabled()) {
|
||||
economy.XPB = (XPBank) eco;
|
||||
api = XPB.getAPI();
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable (PluginDisableEvent event) {
|
||||
if (economy.XPB != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("XPBank")) {
|
||||
economy.XPB = null;
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled () {
|
||||
return this.XPB != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName () {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport () {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits () {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format (double amount) {
|
||||
return String.format("%d %s", (int) amount, api.currencyName((int) amount));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural () {
|
||||
return api.getMsg("CurrencyNamePlural");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular () {
|
||||
return api.getMsg("currencyName");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount (String playerName) {
|
||||
Account account = api.getAccount(playerName);
|
||||
|
||||
if (account != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance (String playerName) {
|
||||
Account account = api.getAccount(playerName);
|
||||
|
||||
return account.getBalance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has (String playerName, double amount) {
|
||||
Account account = api.getAccount(playerName);
|
||||
|
||||
if (account.getBalance() >= (int) amount) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer (String playerName, double amount) {
|
||||
Account account = api.getAccount(playerName);
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer (String playerName, double amount) {
|
||||
Account account = api.getAccount(playerName);
|
||||
|
||||
if (account == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("Player doesn't exist."));
|
||||
}
|
||||
if (account == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("Player doesn't exist."));
|
||||
}
|
||||
|
||||
int value = (int) amount;
|
||||
int balance = account.getBalance();
|
||||
int value = (int) amount;
|
||||
int balance = account.getBalance();
|
||||
|
||||
if (value < 1) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, api.getMsg("LessThanZero"));
|
||||
}
|
||||
if (value < 1) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, api.getMsg("LessThanZero"));
|
||||
}
|
||||
|
||||
if (value > balance) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, String.format(api.getMsg("InsufficientXP"), api.currencyName(value)));
|
||||
}
|
||||
if (value > balance) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, String.format(api.getMsg("InsufficientXP"), api.currencyName(value)));
|
||||
}
|
||||
|
||||
account.modifyBalance(-value);
|
||||
account.modifyBalance(-value);
|
||||
|
||||
return new EconomyResponse(value, balance - value, ResponseType.SUCCESS, null);
|
||||
}
|
||||
return new EconomyResponse(value, balance - value, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer (String playerName, double amount) {
|
||||
Account account = api.getAccount(playerName);
|
||||
@Override
|
||||
public EconomyResponse depositPlayer (String playerName, double amount) {
|
||||
Account account = api.getAccount(playerName);
|
||||
|
||||
if (account == null) {
|
||||
// Stupid plugins that use fake players without creating them first...
|
||||
// return new EconomyResponse(0, 0, ResponseType.FAILURE, "Player doesn't exist");
|
||||
this.createPlayerAccount(playerName);
|
||||
}
|
||||
if (account == null) {
|
||||
// Stupid plugins that use fake players without creating them first...
|
||||
// return new EconomyResponse(0, 0, ResponseType.FAILURE, "Player doesn't exist");
|
||||
this.createPlayerAccount(playerName);
|
||||
}
|
||||
|
||||
int value = (int) amount;
|
||||
int balance = account.getBalance();
|
||||
int value = (int) amount;
|
||||
int balance = account.getBalance();
|
||||
|
||||
if (value < 1) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, api.getMsg("LessThanZero"));
|
||||
}
|
||||
if (value < 1) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, api.getMsg("LessThanZero"));
|
||||
}
|
||||
|
||||
account.addTaxableIncome(value);
|
||||
account.addTaxableIncome(value);
|
||||
|
||||
return new EconomyResponse(value, balance + value, ResponseType.SUCCESS, null);
|
||||
}
|
||||
return new EconomyResponse(value, balance + value, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank (String name, String player) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
@Override
|
||||
public EconomyResponse createBank (String name, String player) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
|
||||
if (groupBank != null) {
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, String.format(api.getMsg("GroupBankExists"), name));
|
||||
}
|
||||
if (groupBank != null) {
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, String.format(api.getMsg("GroupBankExists"), name));
|
||||
}
|
||||
|
||||
Account account = api.getAccount(player);
|
||||
Account account = api.getAccount(player);
|
||||
|
||||
groupBank = api.createGroupBank(name, account);
|
||||
groupBank = api.createGroupBank(name, account);
|
||||
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.SUCCESS, null);
|
||||
}
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank (String name) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
@Override
|
||||
public EconomyResponse deleteBank (String name) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
|
||||
if (groupBank == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
|
||||
}
|
||||
if (groupBank == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
|
||||
}
|
||||
|
||||
api.deleteGroupBank(groupBank, String.format(api.getMsg("Disbanded"), groupBank.getName()));
|
||||
api.deleteGroupBank(groupBank, String.format(api.getMsg("Disbanded"), groupBank.getName()));
|
||||
|
||||
return new EconomyResponse(0, 0, ResponseType.SUCCESS, null);
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance (String name) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
@Override
|
||||
public EconomyResponse bankBalance (String name) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
|
||||
if (groupBank == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
|
||||
}
|
||||
if (groupBank == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
|
||||
}
|
||||
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.SUCCESS, null);
|
||||
}
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas (String name, double amount) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
@Override
|
||||
public EconomyResponse bankHas (String name, double amount) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
|
||||
if (groupBank == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
|
||||
}
|
||||
if (groupBank == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
|
||||
}
|
||||
|
||||
int value = (int) amount;
|
||||
int balance = groupBank.getBalance();
|
||||
int value = (int) amount;
|
||||
int balance = groupBank.getBalance();
|
||||
|
||||
if (balance >= value) {
|
||||
return new EconomyResponse(0, balance, ResponseType.SUCCESS, null);
|
||||
}
|
||||
if (balance >= value) {
|
||||
return new EconomyResponse(0, balance, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, String.format(api.getMsg("InsufficientXP"), api.currencyName(value)));
|
||||
}
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, String.format(api.getMsg("InsufficientXP"), api.currencyName(value)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw (String name, double amount) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw (String name, double amount) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
|
||||
if (groupBank == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
|
||||
}
|
||||
if (groupBank == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
|
||||
}
|
||||
|
||||
int value = (int) amount;
|
||||
int balance = groupBank.getBalance();
|
||||
int value = (int) amount;
|
||||
int balance = groupBank.getBalance();
|
||||
|
||||
if (value < 1) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, api.getMsg("LessThanZero"));
|
||||
}
|
||||
if (value < 1) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, api.getMsg("LessThanZero"));
|
||||
}
|
||||
|
||||
if (value > balance) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, String.format(api.getMsg("InsufficientXP"), api.currencyName(value)));
|
||||
}
|
||||
if (value > balance) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, String.format(api.getMsg("InsufficientXP"), api.currencyName(value)));
|
||||
}
|
||||
|
||||
groupBank.modifyBalance(-value);
|
||||
groupBank.modifyBalance(-value);
|
||||
|
||||
return new EconomyResponse(value, balance - value, ResponseType.SUCCESS, null);
|
||||
}
|
||||
return new EconomyResponse(value, balance - value, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit (String name, double amount) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
@Override
|
||||
public EconomyResponse bankDeposit (String name, double amount) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
|
||||
if (groupBank == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
|
||||
}
|
||||
if (groupBank == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
|
||||
}
|
||||
|
||||
int value = (int) amount;
|
||||
int balance = groupBank.getBalance();
|
||||
int value = (int) amount;
|
||||
int balance = groupBank.getBalance();
|
||||
|
||||
if (value < 1) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, api.getMsg("LessThanZero"));
|
||||
}
|
||||
if (value < 1) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, api.getMsg("LessThanZero"));
|
||||
}
|
||||
|
||||
groupBank.modifyBalance(value);
|
||||
groupBank.modifyBalance(value);
|
||||
|
||||
return new EconomyResponse(value, balance + value, ResponseType.SUCCESS, null);
|
||||
}
|
||||
return new EconomyResponse(value, balance + value, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner (String name, String playerName) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
@Override
|
||||
public EconomyResponse isBankOwner (String name, String playerName) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
|
||||
if (groupBank == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
|
||||
}
|
||||
if (groupBank == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
|
||||
}
|
||||
|
||||
Account account = api.getAccount(name);
|
||||
Account account = api.getAccount(name);
|
||||
|
||||
if (account == null) {
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, api.getMsg("PlayerNotExist"));
|
||||
}
|
||||
if (account == null) {
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, api.getMsg("PlayerNotExist"));
|
||||
}
|
||||
|
||||
if (groupBank.getOwner().equalsIgnoreCase(name)) {
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.SUCCESS, null);
|
||||
}
|
||||
if (groupBank.getOwner().equalsIgnoreCase(name)) {
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, String.format(api.getMsg("PlayerNotOwner"), account.getName(), groupBank.getName()));
|
||||
}
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, String.format(api.getMsg("PlayerNotOwner"), account.getName(), groupBank.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember (String name, String playerName) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
@Override
|
||||
public EconomyResponse isBankMember (String name, String playerName) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
|
||||
if (groupBank == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
|
||||
}
|
||||
if (groupBank == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
|
||||
}
|
||||
|
||||
Account account = api.getAccount(name);
|
||||
Account account = api.getAccount(name);
|
||||
|
||||
if (account == null) {
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, api.getMsg("PlayerNotExist"));
|
||||
}
|
||||
if (account == null) {
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, api.getMsg("PlayerNotExist"));
|
||||
}
|
||||
|
||||
if (groupBank.groupMembers.getMembers().containsKey(playerName)) {
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.SUCCESS, null);
|
||||
}
|
||||
if (groupBank.groupMembers.getMembers().containsKey(playerName)) {
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, String.format(api.getMsg("NotAMemberOf"), groupBank.getName(), account.getName()));
|
||||
}
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, String.format(api.getMsg("NotAMemberOf"), groupBank.getName(), account.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks () {
|
||||
return api.getAllGroupBanks();
|
||||
}
|
||||
@Override
|
||||
public List<String> getBanks () {
|
||||
return api.getAllGroupBanks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount (String playerName) {
|
||||
api.createAccount(playerName);
|
||||
@Override
|
||||
public boolean createPlayerAccount (String playerName) {
|
||||
api.createAccount(playerName);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Economy_eWallet extends Economy {
|
||||
public class Economy_eWallet implements Economy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "eWallet";
|
||||
|
@ -35,7 +35,7 @@ import org.bukkit.plugin.Plugin;
|
||||
import com.nijiko.coelho.iConomy.iConomy;
|
||||
import com.nijiko.coelho.iConomy.system.Account;
|
||||
|
||||
public class Economy_iConomy4 extends Economy {
|
||||
public class Economy_iConomy4 implements Economy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "iConomy 4";
|
||||
|
@ -35,7 +35,7 @@ import com.iConomy.iConomy;
|
||||
import com.iConomy.system.Holdings;
|
||||
import com.iConomy.util.Constants;
|
||||
|
||||
public class Economy_iConomy5 extends Economy {
|
||||
public class Economy_iConomy5 implements Economy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "iConomy 5";
|
||||
|
@ -35,7 +35,7 @@ import com.iCo6.iConomy;
|
||||
import com.iCo6.system.Accounts;
|
||||
import com.iCo6.system.Holdings;
|
||||
|
||||
public class Economy_iConomy6 extends Economy {
|
||||
public class Economy_iConomy6 implements Economy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private String name = "iConomy ";
|
||||
|
Loading…
Reference in New Issue
Block a user