Methods
initializes Methods that utilize the Method interface
+ * based on a "first come, first served" basis.
*
- * @author: Nijikokun+ * + * Methods also allows you to set a preferred method of payment before it captures + * payment plugins in the initialization process. + * + *+ * Methods methods = new Methods(); + *
+ * + * @author: Nijikokun+ * Methods methods = new Methods("iConomy"); + *
Methods
class utilizing a "preferred" payment method check before
+ * returning the first method that was initialized.
+ *
+ * @param preferred Payment method that is most preferred for this setup.
+ */
+ public Methods(String preferred)
+ {
+ this._init();
- if(this.Dependencies.contains(preferred)) {
- this.preferred = preferred;
- }
- }
+ if (this.Dependencies.contains(preferred))
+ {
+ this.preferred = preferred;
+ }
+ }
- private void _init() {
- this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo4());
- this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo5());
- this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE6());
- this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE7());
- }
+ /**
+ * Implement all methods along with their respective name & class.
+ *
+ * @see #Methods()
+ * @see #Methods(java.lang.String)
+ */
+ private void _init()
+ {
+ this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo4());
+ this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo5());
+ this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo6());
+ this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE6());
+ this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE7());
+ this.addMethod("MultiCurrency", new com.earth2me.essentials.register.payment.methods.MCUR());
+ }
- public Set_init
method.
+ *
+ * @return Set
- Array of payment methods that are loaded.
+ * @see #setMethod(org.bukkit.plugin.Plugin)
+ */
+ public Setboolean
+ * @see #setMethod(org.bukkit.plugin.Plugin)
+ * @see #checkDisabled(org.bukkit.plugin.Plugin)
+ */
+ public boolean hasMethod()
+ {
+ return (Method != null);
+ }
- public boolean setMethod(Plugin method) {
- if(hasMethod()) return true;
- if(self) { self = false; return false; }
+ /**
+ * Checks Plugin Class against a multitude of checks to verify it's usability
+ * as a payment method.
+ *
+ * @param method Plugin data from bukkit, Internal Class file.
+ * @return boolean
True on success, False on failure.
+ */
+ public boolean setMethod(Plugin method)
+ {
+ if (hasMethod())
+ {
+ return true;
+ }
+ if (self)
+ {
+ self = false;
+ return false;
+ }
- int count = 0;
- boolean match = false;
- Plugin plugin;
- PluginManager manager = method.getServer().getPluginManager();
+ int count = 0;
+ boolean match = false;
+ Plugin plugin = null;
+ PluginManager manager = method.getServer().getPluginManager();
- for(String name: this.getDependencies()) {
- if(hasMethod()) break;
- if(method.getDescription().getName().equals(name)) plugin = method; else plugin = manager.getPlugin(name);
- if(plugin == null) continue;
+ for (String name : this.getDependencies())
+ {
+ if (hasMethod())
+ {
+ break;
+ }
+ if (method.getDescription().getName().equals(name))
+ {
+ plugin = method;
+ }
+ else
+ {
+ plugin = manager.getPlugin(name);
+ }
+ if (plugin == null)
+ {
+ continue;
+ }
- Method current = this.createMethod(plugin);
- if(current == null) continue;
+ Method current = this.createMethod(plugin);
+ if (current == null)
+ {
+ continue;
+ }
- if(this.preferred.isEmpty())
- this.Method = current;
- else {
- this.Attachables.add(current);
- }
- }
+ if (this.preferred.isEmpty())
+ {
+ this.Method = current;
+ }
+ else
+ {
+ this.Attachables.add(current);
+ }
+ }
- if(!this.preferred.isEmpty()) {
- do {
- if(hasMethod()) {
- match = true;
- } else {
- for(Method attached: this.Attachables) {
- if(attached == null) continue;
+ if (!this.preferred.isEmpty())
+ {
+ do
+ {
+ if (hasMethod())
+ {
+ match = true;
+ }
+ else
+ {
+ for (Method attached : this.Attachables)
+ {
+ if (attached == null)
+ {
+ continue;
+ }
- if(hasMethod()) {
- match = true;
- break;
- }
+ if (hasMethod())
+ {
+ match = true;
+ break;
+ }
- if(this.preferred.isEmpty()) this.Method = attached;
+ if (this.preferred.isEmpty())
+ {
+ this.Method = attached;
+ }
- if(count == 0) {
- if(this.preferred.equalsIgnoreCase(attached.getName()))
- this.Method = attached;
- } else {
- this.Method = attached;
- }
- }
+ if (count == 0)
+ {
+ if (this.preferred.equalsIgnoreCase(attached.getName()))
+ {
+ this.Method = attached;
+ }
+ }
+ else
+ {
+ this.Method = attached;
+ }
+ }
- count++;
- }
- } while(!match);
- }
+ count++;
+ }
+ }
+ while (!match);
+ }
- return hasMethod();
- }
+ return hasMethod();
+ }
- public Method getMethod() {
- return Method;
- }
+ /**
+ * Grab the existing and initialized (hopefully) Method Class.
+ *
+ * @return Method
or Null
+ */
+ public Method getMethod()
+ {
+ return Method;
+ }
- public boolean checkDisabled(Plugin method) {
- if(!hasMethod()) return true;
- if (Method.isCompatible(method)) Method = null;
- return (Method == null);
- }
+ /**
+ * Verify is a plugin is disabled, only does this if we there is an existing payment
+ * method initialized in Register.
+ *
+ * @param method Plugin data from bukkit, Internal Class file.
+ * @return boolean
+ */
+ public boolean checkDisabled(Plugin method)
+ {
+ if (!hasMethod())
+ {
+ return true;
+ }
+ if (Method.isCompatible(method))
+ {
+ Method = null;
+ }
+ return (Method == null);
+ }
}
diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/MCUR.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/MCUR.java
new file mode 100644
index 000000000..8ea709c19
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/MCUR.java
@@ -0,0 +1,120 @@
+package com.earth2me.essentials.register.payment.methods;
+
+import com.earth2me.essentials.register.payment.Method;
+
+import me.ashtheking.currency.Currency;
+import me.ashtheking.currency.CurrencyList;
+
+import org.bukkit.plugin.Plugin;
+
+/**
+ * MultiCurrency Method implementation.
+ *
+ * @author Acrobot
+ * @copyright (c) 2011
+ * @license AOL license