diff options
author | KHobbits <rob@khobbits.co.uk> | 2011-08-08 10:20:04 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2011-08-08 10:20:04 +0100 |
commit | 65702ea0bfad5bf0ddd5f12209d75800e4de0bb0 (patch) | |
tree | 4d6516a33c9394737bd9fbf50f147616f5e74185 | |
parent | 614b7b84f779a725fdebb64618764cab01a53844 (diff) | |
download | Essentials-65702ea0bfad5bf0ddd5f12209d75800e4de0bb0.tar Essentials-65702ea0bfad5bf0ddd5f12209d75800e4de0bb0.tar.gz Essentials-65702ea0bfad5bf0ddd5f12209d75800e4de0bb0.tar.lz Essentials-65702ea0bfad5bf0ddd5f12209d75800e4de0bb0.tar.xz Essentials-65702ea0bfad5bf0ddd5f12209d75800e4de0bb0.zip |
Updating register to latest build.
5 files changed, 488 insertions, 257 deletions
diff --git a/Essentials/src/com/earth2me/essentials/register/payment/Method.java b/Essentials/src/com/earth2me/essentials/register/payment/Method.java index d892ea5da..7394f6b2f 100644 --- a/Essentials/src/com/earth2me/essentials/register/payment/Method.java +++ b/Essentials/src/com/earth2me/essentials/register/payment/Method.java @@ -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 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(); - } - - 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(); - } +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(); + + /** + * Returns the actual name of this method. + * + * @return <code>String</code> Plugin name. + */ + public String getName(); + + /** + * Returns the actual version of this method. + * + * @return <code>String</code> Plugin version. + */ + public String getVersion(); + + /** + * 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); + + /** + * 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(); + } } diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE6.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE6.java index 6293f81be..8400eebd0 100644 --- a/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE6.java +++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE6.java @@ -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) { diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE7.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE7.java index 3612c89e4..3b0f53c4d 100644 --- a/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE7.java +++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE7.java @@ -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 { diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo4.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo4.java index 27c71d362..933959586 100644 --- a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo4.java +++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo4.java @@ -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) { diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java index 28931eac2..bcd6deb6d 100644 --- a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java +++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java @@ -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; - } - - public String getName() { - return "iConomy"; - } - - public String getVersion() { - return "5"; - } - - public String format(double amount) { - return this.iConomy.format(amount); - } - - public boolean hasBanks() { - return Constants.Banking; - } - - public boolean hasBank(String bank) { - return (!hasBanks()) ? false : this.iConomy.Banks.exists(bank); - } - - public boolean hasAccount(String name) { - return this.iConomy.hasAccount(name); - } - - public boolean hasBankAccount(String bank, String name) { - return (!hasBank(bank)) ? false : this.iConomy.getBank(bank).hasAccount(name); - } - - public MethodAccount getAccount(String name) { - return new iCoAccount(this.iConomy.getAccount(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 void setPlugin(Plugin plugin) { - iConomy = (iConomy)plugin; - } - - public class iCoAccount implements MethodAccount { - private Account account; - private Holdings holdings; - - public iCoAccount(Account account) { - this.account = account; - this.holdings = account.getHoldings(); - } - - public Account getiCoAccount() { - return account; - } - - public double balance() { - return this.holdings.balance(); - } - - public boolean set(double amount) { - if(this.holdings == null) return false; - this.holdings.set(amount); - return true; - } - - public boolean add(double amount) { - if(this.holdings == null) return false; - this.holdings.add(amount); - return true; - } - - public boolean subtract(double amount) { - if(this.holdings == null) return false; - this.holdings.subtract(amount); - return true; - } - - public boolean multiply(double amount) { - if(this.holdings == null) return false; - this.holdings.multiply(amount); - return true; - } - - public boolean divide(double amount) { - if(this.holdings == null) return false; - this.holdings.divide(amount); - 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; - } - } - - public class iCoBankAccount implements MethodBankAccount { - private BankAccount account; - private Holdings holdings; - - public iCoBankAccount(BankAccount account) { - this.account = account; - this.holdings = account.getHoldings(); - } - - public BankAccount getiCoBankAccount() { - return account; - } - - public String getBankName() { - return this.account.getBankName(); - } - - public int getBankId() { - return this.account.getBankId(); - } - - public double balance() { - return this.holdings.balance(); - } - - public boolean set(double amount) { - if(this.holdings == null) return false; - this.holdings.set(amount); - return true; - } - - public boolean add(double amount) { - if(this.holdings == null) return false; - this.holdings.add(amount); - return true; - } - - public boolean subtract(double amount) { - if(this.holdings == null) return false; - this.holdings.subtract(amount); - return true; - } - - public boolean multiply(double amount) { - if(this.holdings == null) return false; - this.holdings.multiply(amount); - return true; - } - - public boolean divide(double amount) { - if(this.holdings == null) return false; - this.holdings.divide(amount); - 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; - } - } -} + +/** + * 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 iConomy getPlugin() + { + return this.iConomy; + } + + public String getName() + { + return "iConomy"; + } + + public String getVersion() + { + return "5"; + } + + public String format(double amount) + { + return this.iConomy.format(amount); + } + + public boolean hasBanks() + { + return Constants.Banking; + } + + public boolean hasBank(String bank) + { + return (hasBanks()) && this.iConomy.Banks.exists(bank); + } + + public boolean hasAccount(String name) + { + return this.iConomy.hasAccount(name); + } + + public boolean hasBankAccount(String bank, String name) + { + return (hasBank(bank)) && this.iConomy.getBank(bank).hasAccount(name); + } + + public MethodAccount getAccount(String name) + { + return new iCoAccount(this.iConomy.getAccount(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 void setPlugin(Plugin plugin) + { + iConomy = (iConomy)plugin; + } + + + public class iCoAccount implements MethodAccount + { + private Account account; + private Holdings holdings; + + public iCoAccount(Account account) + { + this.account = account; + this.holdings = account.getHoldings(); + } + + public Account getiCoAccount() + { + return account; + } + + public double balance() + { + return this.holdings.balance(); + } + + public boolean set(double amount) + { + if (this.holdings == null) + { + return false; + } + this.holdings.set(amount); + return true; + } + + public boolean add(double amount) + { + if (this.holdings == null) + { + return false; + } + this.holdings.add(amount); + return true; + } + + public boolean subtract(double amount) + { + if (this.holdings == null) + { + return false; + } + this.holdings.subtract(amount); + return true; + } + + public boolean multiply(double amount) + { + if (this.holdings == null) + { + return false; + } + this.holdings.multiply(amount); + return true; + } + + public boolean divide(double amount) + { + if (this.holdings == null) + { + return false; + } + this.holdings.divide(amount); + 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; + } + } + + + public class iCoBankAccount implements MethodBankAccount + { + private BankAccount account; + private Holdings holdings; + + public iCoBankAccount(BankAccount account) + { + this.account = account; + this.holdings = account.getHoldings(); + } + + public BankAccount getiCoBankAccount() + { + return account; + } + + public String getBankName() + { + return this.account.getBankName(); + } + + public int getBankId() + { + return this.account.getBankId(); + } + + public double balance() + { + return this.holdings.balance(); + } + + public boolean set(double amount) + { + if (this.holdings == null) + { + return false; + } + this.holdings.set(amount); + return true; + } + + public boolean add(double amount) + { + if (this.holdings == null) + { + return false; + } + this.holdings.add(amount); + return true; + } + + public boolean subtract(double amount) + { + if (this.holdings == null) + { + return false; + } + this.holdings.subtract(amount); + return true; + } + + public boolean multiply(double amount) + { + if (this.holdings == null) + { + return false; + } + this.holdings.multiply(amount); + return true; + } + + public boolean divide(double amount) + { + if (this.holdings == null) + { + return false; + } + this.holdings.divide(amount); + 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; + } + } +}
\ No newline at end of file |