summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-05-15 15:23:31 +0000
committersnowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-05-15 15:23:31 +0000
commitfb818a611da658f95b45607a81986d247070ff4c (patch)
tree90e46bb817f8f261899d419bbe7a6d018633fd6f
parent403963cf968cc3ee82ca6ce5b9f264f3a655417d (diff)
downloadEssentials-fb818a611da658f95b45607a81986d247070ff4c.tar
Essentials-fb818a611da658f95b45607a81986d247070ff4c.tar.gz
Essentials-fb818a611da658f95b45607a81986d247070ff4c.tar.lz
Essentials-fb818a611da658f95b45607a81986d247070ff4c.tar.xz
Essentials-fb818a611da658f95b45607a81986d247070ff4c.zip
Register v1.2
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1488 e251c2fe-e539-e718-e476-b85c1f46cddb
-rw-r--r--Essentials/src/com/earth2me/essentials/register/payment/Method.java8
-rw-r--r--Essentials/src/com/earth2me/essentials/register/payment/MethodFactory.java31
-rw-r--r--Essentials/src/com/earth2me/essentials/register/payment/Methods.java61
-rw-r--r--Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/register/payment/methods/iCo4.java9
-rw-r--r--Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java9
6 files changed, 64 insertions, 60 deletions
diff --git a/Essentials/src/com/earth2me/essentials/register/payment/Method.java b/Essentials/src/com/earth2me/essentials/register/payment/Method.java
index 6d6426c36..d892ea5da 100644
--- a/Essentials/src/com/earth2me/essentials/register/payment/Method.java
+++ b/Essentials/src/com/earth2me/essentials/register/payment/Method.java
@@ -2,6 +2,14 @@ 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>
+ */
public interface Method {
public Object getPlugin();
public String getName();
diff --git a/Essentials/src/com/earth2me/essentials/register/payment/MethodFactory.java b/Essentials/src/com/earth2me/essentials/register/payment/MethodFactory.java
deleted file mode 100644
index 655d392e8..000000000
--- a/Essentials/src/com/earth2me/essentials/register/payment/MethodFactory.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.earth2me.essentials.register.payment;
-
-import java.util.HashSet;
-import java.util.Set;
-import org.bukkit.plugin.Plugin;
-
-public class MethodFactory {
-
- private static Set<Method> Methods = new HashSet<Method>();
- private static Set<String> Dependencies = new HashSet<String>();
-
- public static Method createMethod(Plugin plugin) {
- for (Method method: Methods) {
- if (method.isCompatible(plugin)) {
- method.setPlugin(plugin);
- return method;
- }
- }
-
- return null;
- }
-
- public static void addMethod(String name, Method method) {
- Dependencies.add(name);
- Methods.add(method);
- }
-
- public static Set<String> getDependencies() {
- return Dependencies;
- }
-}
diff --git a/Essentials/src/com/earth2me/essentials/register/payment/Methods.java b/Essentials/src/com/earth2me/essentials/register/payment/Methods.java
index f93b29a6e..6bef3c6b8 100644
--- a/Essentials/src/com/earth2me/essentials/register/payment/Methods.java
+++ b/Essentials/src/com/earth2me/essentials/register/payment/Methods.java
@@ -1,20 +1,63 @@
package com.earth2me.essentials.register.payment;
+import java.util.HashSet;
+import java.util.Set;
+
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
+/**
+ * Methods.java
+ * Controls the getting / setting of methods & the method of payment used.
+ *
+ * @author: Nijikokun<nijikokun@gmail.com> (@nijikokun)
+ * @copyright: Copyright (C) 2011
+ * @license: GNUv3 Affero License <http://www.gnu.org/licenses/agpl-3.0.html>
+ */
public class Methods {
private Method Method = null;
+ private Set<Method> Methods = new HashSet<Method>();
+ private Set<String> Dependencies = new HashSet<String>();
+
+ public Methods() {
+ 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.BOSE());
+ }
+
+ public Set<String> getDependencies() {
+ return Dependencies;
+ }
+
+ public Method createMethod(Plugin plugin) {
+ for (Method method: Methods) {
+ if (method.isCompatible(plugin)) {
+ method.setPlugin(plugin);
+ return method;
+ }
+ }
+
+ return null;
+ }
+
+ private void addMethod(String name, Method method) {
+ Dependencies.add(name);
+ Methods.add(method);
+ }
+
+ public boolean hasMethod() {
+ return (Method != null);
+ }
public boolean setMethod(Plugin method) {
PluginManager manager = method.getServer().getPluginManager();
if (method != null && method.isEnabled()) {
- Method plugin = MethodFactory.createMethod(method);
+ Method plugin = this.createMethod(method);
if (plugin != null) Method = plugin;
} else {
- for(String name: MethodFactory.getDependencies()) {
+ for(String name: this.getDependencies()) {
if(hasMethod()) break;
method = manager.getPlugin(name);
@@ -22,7 +65,7 @@ public class Methods {
if(!method.isEnabled()) manager.enablePlugin(method);
if(!method.isEnabled()) continue;
- Method plugin = MethodFactory.createMethod(method);
+ Method plugin = this.createMethod(method);
if (plugin != null) Method = plugin;
}
}
@@ -30,17 +73,13 @@ public class Methods {
return hasMethod();
}
+ public Method getMethod() {
+ return Method;
+ }
+
public boolean checkDisabled(Plugin method) {
if(!hasMethod()) return true;
if (Method.isCompatible(method)) Method = null;
return (Method == null);
}
-
- public boolean hasMethod() {
- return (Method != null);
- }
-
- public Method getMethod() {
- return Method;
- }
}
diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE.java
index ba7b727b7..444735b65 100644
--- a/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE.java
+++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE.java
@@ -1,18 +1,12 @@
package com.earth2me.essentials.register.payment.methods;
import com.earth2me.essentials.register.payment.Method;
-import com.earth2me.essentials.register.payment.MethodFactory;
import cosine.boseconomy.BOSEconomy;
import org.bukkit.plugin.Plugin;
public class BOSE implements Method {
private BOSEconomy BOSEconomy;
- static {
- MethodFactory.addMethod("BOSEconomy", new BOSE());
-
- }
-
public BOSEconomy getPlugin() {
return this.BOSEconomy;
}
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 5eb3ae9a9..27c71d362 100644
--- a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo4.java
+++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo4.java
@@ -2,17 +2,14 @@ package com.earth2me.essentials.register.payment.methods;
import com.nijiko.coelho.iConomy.iConomy;
import com.nijiko.coelho.iConomy.system.Account;
+
import com.earth2me.essentials.register.payment.Method;
-import com.earth2me.essentials.register.payment.MethodFactory;
+
import org.bukkit.plugin.Plugin;
public class iCo4 implements Method {
private iConomy iConomy;
- static {
- MethodFactory.addMethod("iConomy", new iCo4());
- }
-
public iConomy getPlugin() {
return this.iConomy;
}
@@ -54,7 +51,7 @@ public class iCo4 implements Method {
}
public boolean isCompatible(Plugin plugin) {
- return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin instanceof iConomy;
+ return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && !plugin.getClass().getName().equals("com.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 0956e0556..5cf62cfb9 100644
--- a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java
+++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java
@@ -5,17 +5,14 @@ import com.iConomy.system.Account;
import com.iConomy.system.BankAccount;
import com.iConomy.system.Holdings;
import com.iConomy.util.Constants;
+
import com.earth2me.essentials.register.payment.Method;
-import com.earth2me.essentials.register.payment.MethodFactory;
+
import org.bukkit.plugin.Plugin;
public class iCo5 implements Method {
private iConomy iConomy;
- static {
- MethodFactory.addMethod("iConomy", new iCo5());
- }
-
public iConomy getPlugin() {
return this.iConomy;
}
@@ -57,7 +54,7 @@ public class iCo5 implements Method {
}
public boolean isCompatible(Plugin plugin) {
- return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin instanceof iConomy;
+ return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.iConomy.iConomy") && plugin instanceof iConomy;
}
public void setPlugin(Plugin plugin) {