package com.LRFLEW.register.payment.forChestShop;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import java.util.HashSet;
import java.util.Set;
/**
* The Methods
initializes Methods that utilize the Method interface
* based on a "first come, first served" basis.
*
* * @author: Nijikokun* economy=iConomy *
_init
method.
*
* @return Set
- Array of payment methods that are loaded.
*/
public static Setboolean
* @see #checkDisabled(org.bukkit.plugin.Plugin)
*/
public static boolean hasMethod() {
return (Method != null);
}
/**
* Checks Plugin Class against a multitude of checks to verify it's usability
* as a payment method.
*
* @return boolean
True on success, False on failure.
*/
public static boolean setMethod(PluginManager manager) {
if (hasMethod()) return true;
if (self) { self = false; return false; }
int count = 0;
boolean match = false;
Plugin plugin;
for (String name : Dependencies) {
if (hasMethod()) break;
plugin = manager.getPlugin(name);
if (plugin == null) continue;
Method current = createMethod(plugin);
if (current == null) continue;
if (preferred.isEmpty())
Method = current;
else {
Attachables.add(current);
}
}
if (!preferred.isEmpty()) {
do {
if (hasMethod()) {
match = true;
} else {
for (Method attached : Attachables) {
if (attached == null) continue;
if (hasMethod()) {
match = true;
break;
}
if (preferred.isEmpty()) Method = attached;
if (count == 0) {
if (preferred.equalsIgnoreCase(attached.getName()))
Method = attached;
} else {
Method = attached;
}
}
count++;
}
} while (!match);
}
return hasMethod();
}
/**
* Grab the existing and initialized (hopefully) Method Class.
*
* @return Method
or Null
*/
public static Method getMethod() {
return Method;
}
/**
* 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 static boolean checkDisabled(Plugin method) {
if (!hasMethod()) return true;
if (Method.isCompatible(method)) Method = null;
return (Method == null);
}
}