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; import org.bukkit.plugin.Plugin;
/** /**
* Method.java * Method.java
* Interface for all sub-methods for payment.
* *
* @author: Nijikokun<nijikokun@gmail.com> (@nijikokun) * @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
* @copyright: Copyright (C) 2011 * @copyright Copyright (C) 2011
* @license: GNUv3 Affero License <http://www.gnu.org/licenses/agpl-3.0.html> * @license AOL license <http://aol.nexua.org>
*/ */
public interface Method { public interface Method
public Object getPlugin(); {
public String getName(); /**
public String getVersion(); * Encodes the Plugin into an Object disguised as the Plugin.
public String format(double amount); * If you want the original Plugin Class you must cast it to the correct
public boolean hasBanks(); * Plugin, to do so you have to verify the name and or version then cast.
public boolean hasBank(String bank); *
public boolean hasAccount(String name); * <pre>
public boolean hasBankAccount(String bank, String name); * if(method.getName().equalsIgnoreCase("iConomy"))
public MethodAccount getAccount(String name); * iConomy plugin = ((iConomy)method.getPlugin());</pre>
public MethodBankAccount getBankAccount(String bank, String name); *
public boolean isCompatible(Plugin plugin); * @return <code>Object</code>
public void setPlugin(Plugin plugin); * @see #getName()
* @see #getVersion()
*/
public Object getPlugin();
public interface MethodAccount { /**
public double balance(); * Returns the actual name of this method.
public boolean set(double amount); *
public boolean add(double amount); * @return <code>String</code> Plugin name.
public boolean subtract(double amount); */
public boolean multiply(double amount); public String getName();
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(); * Returns the actual version of this method.
} *
* @return <code>String</code> Plugin version.
*/
public String getVersion();
public interface MethodBankAccount { /**
public double balance(); * Formats amounts into this payment methods style of currency display.
public String getBankName(); *
public int getBankId(); * @param amount Double
public boolean set(double amount); * @return <code>String</code> - Formatted Currency Display.
public boolean add(double amount); */
public boolean subtract(double amount); public String format(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(); * 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 cosine.boseconomy.BOSEconomy;
import org.bukkit.plugin.Plugin; 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 { public class BOSE6 implements Method {
private BOSEconomy BOSEconomy; private BOSEconomy BOSEconomy;
@ -69,7 +76,7 @@ public class BOSE6 implements Method {
} }
public double balance() { public double balance() {
return Double.valueOf(this.BOSEconomy.getPlayerMoney(this.name)); return (double) this.BOSEconomy.getPlayerMoney(this.name);
} }
public boolean set(double amount) { public boolean set(double amount) {
@ -122,8 +129,8 @@ public class BOSE6 implements Method {
} }
public class BOSEBankAccount implements MethodBankAccount { public class BOSEBankAccount implements MethodBankAccount {
private String bank; private final String bank;
private BOSEconomy BOSEconomy; private final BOSEconomy BOSEconomy;
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) { public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) {
this.bank = bank; this.bank = bank;
@ -139,7 +146,7 @@ public class BOSE6 implements Method {
} }
public double balance() { public double balance() {
return Double.valueOf(this.BOSEconomy.getBankMoney(bank)); return (double) this.BOSEconomy.getBankMoney(bank);
} }
public boolean set(double amount) { public boolean set(double amount) {

View file

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

View file

@ -7,6 +7,13 @@ import com.earth2me.essentials.register.payment.Method;
import org.bukkit.plugin.Plugin; 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 { public class iCo4 implements Method {
private iConomy iConomy; private iConomy iConomy;
@ -51,7 +58,7 @@ public class iCo4 implements Method {
} }
public boolean isCompatible(Plugin plugin) { 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) { public void setPlugin(Plugin plugin) {

View file

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