Updating register to latest build.

This commit is contained in:
KHobbits 2011-08-08 10:20:04 +01:00
parent 614b7b84f7
commit 65702ea0bf
5 changed files with 443 additions and 212 deletions

View file

@ -2,61 +2,184 @@ package com.earth2me.essentials.register.payment;
import org.bukkit.plugin.Plugin;
/**
* Method.java
* Interface for all sub-methods for payment.
*
* @author: Nijikokun<nijikokun@gmail.com> (@nijikokun)
* @copyright: Copyright (C) 2011
* @license: GNUv3 Affero License <http://www.gnu.org/licenses/agpl-3.0.html>
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
* @copyright Copyright (C) 2011
* @license AOL license <http://aol.nexua.org>
*/
public interface Method {
public Object getPlugin();
public String getName();
public String getVersion();
public String format(double amount);
public boolean hasBanks();
public boolean hasBank(String bank);
public boolean hasAccount(String name);
public boolean hasBankAccount(String bank, String name);
public MethodAccount getAccount(String name);
public MethodBankAccount getBankAccount(String bank, String name);
public boolean isCompatible(Plugin plugin);
public void setPlugin(Plugin plugin);
public interface Method
{
/**
* Encodes the Plugin into an Object disguised as the Plugin.
* If you want the original Plugin Class you must cast it to the correct
* Plugin, to do so you have to verify the name and or version then cast.
*
* <pre>
* if(method.getName().equalsIgnoreCase("iConomy"))
* iConomy plugin = ((iConomy)method.getPlugin());</pre>
*
* @return <code>Object</code>
* @see #getName()
* @see #getVersion()
*/
public Object getPlugin();
public interface MethodAccount {
public double balance();
public boolean set(double amount);
public boolean add(double amount);
public boolean subtract(double amount);
public boolean multiply(double amount);
public boolean divide(double amount);
public boolean hasEnough(double amount);
public boolean hasOver(double amount);
public boolean hasUnder(double amount);
public boolean isNegative();
public boolean remove();
/**
* Returns the actual name of this method.
*
* @return <code>String</code> Plugin name.
*/
public String getName();
@Override
public String toString();
}
/**
* Returns the actual version of this method.
*
* @return <code>String</code> Plugin version.
*/
public String getVersion();
public interface MethodBankAccount {
public double balance();
public String getBankName();
public int getBankId();
public boolean set(double amount);
public boolean add(double amount);
public boolean subtract(double amount);
public boolean multiply(double amount);
public boolean divide(double amount);
public boolean hasEnough(double amount);
public boolean hasOver(double amount);
public boolean hasUnder(double amount);
public boolean isNegative();
public boolean remove();
/**
* Formats amounts into this payment methods style of currency display.
*
* @param amount Double
* @return <code>String</code> - Formatted Currency Display.
*/
public String format(double amount);
@Override
public String toString();
}
/**
* Allows the verification of bank API existence in this payment method.
*
* @return <code>boolean</code>
*/
public boolean hasBanks();
/**
* Determines the existence of a bank via name.
*
* @param bank Bank name
* @return <code>boolean</code>
* @see #hasBanks
*/
public boolean hasBank(String bank);
/**
* Determines the existence of an account via name.
*
* @param name Account name
* @return <code>boolean</code>
*/
public boolean hasAccount(String name);
/**
* Check to see if an account <code>name</code> is tied to a <code>bank</code>.
*
* @param bank Bank name
* @param name Account name
* @return <code>boolean</code>
*/
public boolean hasBankAccount(String bank, String name);
/**
* Returns a <code>MethodAccount</code> class for an account <code>name</code>.
*
* @param name Account name
* @return <code>MethodAccount</code> <em>or</em> <code>Null</code>
*/
public MethodAccount getAccount(String name);
/**
* Returns a <code>MethodBankAccount</code> class for an account <code>name</code>.
*
* @param bank Bank name
* @param name Account name
* @return <code>MethodBankAccount</code> <em>or</em> <code>Null</code>
*/
public MethodBankAccount getBankAccount(String bank, String name);
/**
* Checks to verify the compatibility between this Method and a plugin.
* Internal usage only, for the most part.
*
* @param plugin Plugin
* @return <code>boolean</code>
*/
public boolean isCompatible(Plugin plugin);
/**
* Set Plugin data.
*
* @param plugin Plugin
*/
public void setPlugin(Plugin plugin);
/**
* Contains Calculator and Balance functions for Accounts.
*/
public interface MethodAccount
{
public double balance();
public boolean set(double amount);
public boolean add(double amount);
public boolean subtract(double amount);
public boolean multiply(double amount);
public boolean divide(double amount);
public boolean hasEnough(double amount);
public boolean hasOver(double amount);
public boolean hasUnder(double amount);
public boolean isNegative();
public boolean remove();
@Override
public String toString();
}
/**
* Contains Calculator and Balance functions for Bank Accounts.
*/
public interface MethodBankAccount
{
public double balance();
public String getBankName();
public int getBankId();
public boolean set(double amount);
public boolean add(double amount);
public boolean subtract(double amount);
public boolean multiply(double amount);
public boolean divide(double amount);
public boolean hasEnough(double amount);
public boolean hasOver(double amount);
public boolean hasUnder(double amount);
public boolean isNegative();
public boolean remove();
@Override
public String toString();
}
}

View file

@ -4,6 +4,13 @@ import com.earth2me.essentials.register.payment.Method;
import cosine.boseconomy.BOSEconomy;
import org.bukkit.plugin.Plugin;
/**
* BOSEconomy 6 Implementation of Method
*
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
* @copyright (c) 2011
* @license AOL license <http://aol.nexua.org>
*/
public class BOSE6 implements Method {
private BOSEconomy BOSEconomy;
@ -69,7 +76,7 @@ public class BOSE6 implements Method {
}
public double balance() {
return Double.valueOf(this.BOSEconomy.getPlayerMoney(this.name));
return (double) this.BOSEconomy.getPlayerMoney(this.name);
}
public boolean set(double amount) {
@ -122,8 +129,8 @@ public class BOSE6 implements Method {
}
public class BOSEBankAccount implements MethodBankAccount {
private String bank;
private BOSEconomy BOSEconomy;
private final String bank;
private final BOSEconomy BOSEconomy;
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) {
this.bank = bank;
@ -139,7 +146,7 @@ public class BOSE6 implements Method {
}
public double balance() {
return Double.valueOf(this.BOSEconomy.getBankMoney(bank));
return (double) this.BOSEconomy.getBankMoney(bank);
}
public boolean set(double amount) {

View file

@ -5,7 +5,12 @@ import cosine.boseconomy.BOSEconomy;
import org.bukkit.plugin.Plugin;
/**
* BOSEconomy 7 Implementation of Method
*
* @author Acrobot
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
* @copyright (c) 2011
* @license AOL license <http://aol.nexua.org>
*/
public class BOSE7 implements Method {

View file

@ -7,6 +7,13 @@ import com.earth2me.essentials.register.payment.Method;
import org.bukkit.plugin.Plugin;
/**
* iConomy 4 Implementation of Method
*
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
* @copyright (c) 2011
* @license AOL license <http://aol.nexua.org>
*/
public class iCo4 implements Method {
private iConomy iConomy;
@ -51,7 +58,7 @@ public class iCo4 implements Method {
}
public boolean isCompatible(Plugin plugin) {
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && !plugin.getClass().getName().equals("com.iConomy.iConomy") && plugin instanceof iConomy;
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.nijiko.coelho.iConomy.iConomy") && plugin instanceof iConomy;
}
public void setPlugin(Plugin plugin) {

View file

@ -10,202 +10,291 @@ import com.earth2me.essentials.register.payment.Method;
import org.bukkit.plugin.Plugin;
public class iCo5 implements Method {
private iConomy iConomy;
public iConomy getPlugin() {
return this.iConomy;
}
/**
* iConomy 5 Implementation of Method
*
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
* @copyright (c) 2011
* @license AOL license <http://aol.nexua.org>
*/
public class iCo5 implements Method
{
private iConomy iConomy;
public String getName() {
return "iConomy";
}
public iConomy getPlugin()
{
return this.iConomy;
}
public String getVersion() {
return "5";
}
public String getName()
{
return "iConomy";
}
public String format(double amount) {
return this.iConomy.format(amount);
}
public String getVersion()
{
return "5";
}
public boolean hasBanks() {
return Constants.Banking;
}
public String format(double amount)
{
return this.iConomy.format(amount);
}
public boolean hasBank(String bank) {
return (!hasBanks()) ? false : this.iConomy.Banks.exists(bank);
}
public boolean hasBanks()
{
return Constants.Banking;
}
public boolean hasAccount(String name) {
return this.iConomy.hasAccount(name);
}
public boolean hasBank(String bank)
{
return (hasBanks()) && this.iConomy.Banks.exists(bank);
}
public boolean hasBankAccount(String bank, String name) {
return (!hasBank(bank)) ? false : this.iConomy.getBank(bank).hasAccount(name);
}
public boolean hasAccount(String name)
{
return this.iConomy.hasAccount(name);
}
public MethodAccount getAccount(String name) {
return new iCoAccount(this.iConomy.getAccount(name));
}
public boolean hasBankAccount(String bank, String name)
{
return (hasBank(bank)) && this.iConomy.getBank(bank).hasAccount(name);
}
public MethodBankAccount getBankAccount(String bank, String name) {
return new iCoBankAccount(this.iConomy.getBank(bank).getAccount(name));
}
public boolean isCompatible(Plugin plugin) {
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.iConomy.iConomy") && plugin instanceof iConomy;
}
public MethodAccount getAccount(String name)
{
return new iCoAccount(this.iConomy.getAccount(name));
}
public void setPlugin(Plugin plugin) {
iConomy = (iConomy)plugin;
}
public MethodBankAccount getBankAccount(String bank, String name)
{
return new iCoBankAccount(this.iConomy.getBank(bank).getAccount(name));
}
public class iCoAccount implements MethodAccount {
private Account account;
private Holdings holdings;
public boolean isCompatible(Plugin plugin)
{
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.iConomy.iConomy") && plugin instanceof iConomy;
}
public iCoAccount(Account account) {
this.account = account;
this.holdings = account.getHoldings();
}
public void setPlugin(Plugin plugin)
{
iConomy = (iConomy)plugin;
}
public Account getiCoAccount() {
return account;
}
public double balance() {
return this.holdings.balance();
}
public class iCoAccount implements MethodAccount
{
private Account account;
private Holdings holdings;
public boolean set(double amount) {
if(this.holdings == null) return false;
this.holdings.set(amount);
return true;
}
public iCoAccount(Account account)
{
this.account = account;
this.holdings = account.getHoldings();
}
public boolean add(double amount) {
if(this.holdings == null) return false;
this.holdings.add(amount);
return true;
}
public Account getiCoAccount()
{
return account;
}
public boolean subtract(double amount) {
if(this.holdings == null) return false;
this.holdings.subtract(amount);
return true;
}
public double balance()
{
return this.holdings.balance();
}
public boolean multiply(double amount) {
if(this.holdings == null) return false;
this.holdings.multiply(amount);
return true;
}
public boolean set(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.set(amount);
return true;
}
public boolean divide(double amount) {
if(this.holdings == null) return false;
this.holdings.divide(amount);
return true;
}
public boolean add(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.add(amount);
return true;
}
public boolean hasEnough(double amount) {
return this.holdings.hasEnough(amount);
}
public boolean subtract(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.subtract(amount);
return true;
}
public boolean hasOver(double amount) {
return this.holdings.hasOver(amount);
}
public boolean multiply(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.multiply(amount);
return true;
}
public boolean hasUnder(double amount) {
return this.holdings.hasUnder(amount);
}
public boolean divide(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.divide(amount);
return true;
}
public boolean isNegative() {
return this.holdings.isNegative();
}
public boolean hasEnough(double amount)
{
return this.holdings.hasEnough(amount);
}
public boolean remove() {
if(this.account == null) return false;
this.account.remove();
return true;
}
}
public boolean hasOver(double amount)
{
return this.holdings.hasOver(amount);
}
public class iCoBankAccount implements MethodBankAccount {
private BankAccount account;
private Holdings holdings;
public boolean hasUnder(double amount)
{
return this.holdings.hasUnder(amount);
}
public iCoBankAccount(BankAccount account) {
this.account = account;
this.holdings = account.getHoldings();
}
public boolean isNegative()
{
return this.holdings.isNegative();
}
public BankAccount getiCoBankAccount() {
return account;
}
public boolean remove()
{
if (this.account == null)
{
return false;
}
this.account.remove();
return true;
}
}
public String getBankName() {
return this.account.getBankName();
}
public int getBankId() {
return this.account.getBankId();
}
public class iCoBankAccount implements MethodBankAccount
{
private BankAccount account;
private Holdings holdings;
public double balance() {
return this.holdings.balance();
}
public iCoBankAccount(BankAccount account)
{
this.account = account;
this.holdings = account.getHoldings();
}
public boolean set(double amount) {
if(this.holdings == null) return false;
this.holdings.set(amount);
return true;
}
public BankAccount getiCoBankAccount()
{
return account;
}
public boolean add(double amount) {
if(this.holdings == null) return false;
this.holdings.add(amount);
return true;
}
public String getBankName()
{
return this.account.getBankName();
}
public boolean subtract(double amount) {
if(this.holdings == null) return false;
this.holdings.subtract(amount);
return true;
}
public int getBankId()
{
return this.account.getBankId();
}
public boolean multiply(double amount) {
if(this.holdings == null) return false;
this.holdings.multiply(amount);
return true;
}
public double balance()
{
return this.holdings.balance();
}
public boolean divide(double amount) {
if(this.holdings == null) return false;
this.holdings.divide(amount);
return true;
}
public boolean set(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.set(amount);
return true;
}
public boolean hasEnough(double amount) {
return this.holdings.hasEnough(amount);
}
public boolean add(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.add(amount);
return true;
}
public boolean hasOver(double amount) {
return this.holdings.hasOver(amount);
}
public boolean subtract(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.subtract(amount);
return true;
}
public boolean hasUnder(double amount) {
return this.holdings.hasUnder(amount);
}
public boolean multiply(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.multiply(amount);
return true;
}
public boolean isNegative() {
return this.holdings.isNegative();
}
public boolean divide(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.divide(amount);
return true;
}
public boolean remove() {
if(this.account == null) return false;
this.account.remove();
return true;
}
}
}
public boolean hasEnough(double amount)
{
return this.holdings.hasEnough(amount);
}
public boolean hasOver(double amount)
{
return this.holdings.hasOver(amount);
}
public boolean hasUnder(double amount)
{
return this.holdings.hasUnder(amount);
}
public boolean isNegative()
{
return this.holdings.isNegative();
}
public boolean remove()
{
if (this.account == null)
{
return false;
}
this.account.remove();
return true;
}
}
}