[trunk] Register 1.5

git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1503 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
ementalo 2011-05-16 20:48:19 +00:00
parent 80f6c58dad
commit 139a3a128a

View File

@ -6,7 +6,7 @@ import java.util.Set;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
/** /***
* Methods.java * Methods.java
* Controls the getting / setting of methods & the method of payment used. * Controls the getting / setting of methods & the method of payment used.
* *
@ -24,6 +24,7 @@ public class Methods {
this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo4()); 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.iCo5());
this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE()); this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE());
} }
public Set<String> getDependencies() { public Set<String> getDependencies() {
@ -51,23 +52,19 @@ public class Methods {
} }
public boolean setMethod(Plugin method) { public boolean setMethod(Plugin method) {
PluginManager manager = method.getServer().getPluginManager(); if(hasMethod()) return true;
PluginManager manager = method.getServer().getPluginManager();
Plugin plugin = null;
if (method != null && method.isEnabled()) {
Method plugin = this.createMethod(method);
if (plugin != null) Method = plugin;
} else {
for(String name: this.getDependencies()) { for(String name: this.getDependencies()) {
if(hasMethod()) break; if(hasMethod()) break;
if(method.getDescription().getName().equals(name)) plugin = method; else plugin = manager.getPlugin(name);
if(plugin == null) continue;
if(!plugin.isEnabled()) continue;
method = manager.getPlugin(name); Method current = this.createMethod(plugin);
if(method == null) continue; if (current != null) this.Method = current;
if(!method.isEnabled()) manager.enablePlugin(method);
if(!method.isEnabled()) continue;
Method plugin = this.createMethod(method);
if (plugin != null) Method = plugin;
}
} }
return hasMethod(); return hasMethod();