2011-10-11 13:15:53 +02:00
|
|
|
package com.nijikokun.register.payment.forChestShop;
|
2011-09-06 19:01:57 +02:00
|
|
|
|
2012-03-11 22:56:51 +01:00
|
|
|
import com.nijikokun.register.payment.forChestShop.methods.BOSE7;
|
|
|
|
import com.nijikokun.register.payment.forChestShop.methods.EE17;
|
|
|
|
import com.nijikokun.register.payment.forChestShop.methods.iCo5;
|
|
|
|
import com.nijikokun.register.payment.forChestShop.methods.iCo6;
|
2011-09-29 20:29:39 +02:00
|
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
import org.bukkit.plugin.PluginManager;
|
|
|
|
|
2011-09-06 19:01:57 +02:00
|
|
|
/**
|
2012-01-25 16:32:34 +01:00
|
|
|
* @author Acrobot
|
2011-09-06 19:01:57 +02:00
|
|
|
*/
|
|
|
|
public class Methods {
|
2012-01-25 16:32:34 +01:00
|
|
|
private static String preferred;
|
|
|
|
private static final String[] toLoad = new String[]{
|
|
|
|
"iConomy",
|
|
|
|
"BOSEconomy",
|
|
|
|
"Essentials",
|
|
|
|
};
|
|
|
|
private static final Method[] methods = new Method[]{
|
|
|
|
new iCo5(),
|
|
|
|
new iCo6(),
|
|
|
|
new BOSE7(),
|
|
|
|
new EE17()
|
|
|
|
};
|
|
|
|
|
|
|
|
public static void setPreferred(String plugin) {
|
|
|
|
preferred = plugin;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Method load(PluginManager pm) {
|
|
|
|
if (!preferred.isEmpty()){
|
|
|
|
Plugin plugin = pm.getPlugin(preferred);
|
|
|
|
if (plugin != null){
|
|
|
|
Method m = createMethod(plugin);
|
|
|
|
if (m != null) return m;
|
|
|
|
}
|
|
|
|
}
|
2012-03-11 22:56:51 +01:00
|
|
|
|
2012-01-25 16:32:34 +01:00
|
|
|
for (String plugin : toLoad){
|
|
|
|
Plugin pl = pm.getPlugin(plugin);
|
|
|
|
if (pl != null){
|
|
|
|
Method m = createMethod(pl);
|
|
|
|
if (m != null) return m;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
2011-09-06 19:01:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static Method createMethod(Plugin plugin) {
|
2012-01-09 22:39:38 +01:00
|
|
|
for (Method method : methods){
|
2011-09-06 19:01:57 +02:00
|
|
|
if (method.isCompatible(plugin)) {
|
|
|
|
method.setPlugin(plugin);
|
|
|
|
return method;
|
|
|
|
}
|
2012-01-09 22:39:38 +01:00
|
|
|
}
|
2011-09-06 19:01:57 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|