mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-20 15:11:25 +01:00
[trunk] revert
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1557 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
d313d0dc87
commit
be89986b4e
@ -6,7 +6,6 @@ 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.
|
||||||
@ -15,146 +14,113 @@ import org.bukkit.plugin.PluginManager;
|
|||||||
* @copyright: Copyright (C) 2011
|
* @copyright: Copyright (C) 2011
|
||||||
* @license: GNUv3 Affero License <http://www.gnu.org/licenses/agpl-3.0.html>
|
* @license: GNUv3 Affero License <http://www.gnu.org/licenses/agpl-3.0.html>
|
||||||
*/
|
*/
|
||||||
public class Methods
|
public class Methods {
|
||||||
{
|
private boolean self = false;
|
||||||
private boolean self = false;
|
private Method Method = null;
|
||||||
private Method Method = null;
|
|
||||||
private String preferred = "";
|
private String preferred = "";
|
||||||
private Set<Method> Methods = new HashSet<Method>();
|
private Set<Method> Methods = new HashSet<Method>();
|
||||||
private Set<String> Dependencies = new HashSet<String>();
|
private Set<String> Dependencies = new HashSet<String>();
|
||||||
private Set<Method> Attachables = new HashSet<Method>();
|
private Set<Method> Attachables = new HashSet<Method>();
|
||||||
|
|
||||||
public Methods()
|
public 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() {
|
||||||
{
|
return Dependencies;
|
||||||
return Dependencies;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Method createMethod(Plugin plugin)
|
public Method createMethod(Plugin plugin) {
|
||||||
{
|
for (Method method: Methods) {
|
||||||
for (Method method : Methods)
|
if (method.isCompatible(plugin)) {
|
||||||
{
|
method.setPlugin(plugin);
|
||||||
if (method.isCompatible(plugin))
|
return method;
|
||||||
{
|
}
|
||||||
method.setPlugin(plugin);
|
}
|
||||||
return method;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addMethod(String name, Method method)
|
private void addMethod(String name, Method method) {
|
||||||
{
|
Dependencies.add(name);
|
||||||
Dependencies.add(name);
|
Methods.add(method);
|
||||||
Methods.add(method);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasMethod()
|
public boolean hasMethod() {
|
||||||
{
|
return (Method != null);
|
||||||
return (Method != null);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean setMethod(Plugin method)
|
public boolean setMethod(Plugin method) {
|
||||||
{
|
if(hasMethod()) return true;
|
||||||
if (hasMethod()) return true;
|
if(self) { self = false; return false; }
|
||||||
if (self)
|
|
||||||
{
|
|
||||||
self = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
boolean match = false;
|
boolean match = false;
|
||||||
Plugin plugin = null;
|
Plugin plugin = null;
|
||||||
PluginManager manager = method.getServer().getPluginManager();
|
PluginManager manager = method.getServer().getPluginManager();
|
||||||
|
|
||||||
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 (method.getDescription().getName().equals(name)) plugin = method;
|
if(plugin == null) continue;
|
||||||
else plugin = manager.getPlugin(name);
|
|
||||||
if (plugin == null) continue;
|
|
||||||
|
|
||||||
if (!plugin.isEnabled())
|
if(!plugin.isEnabled()) {
|
||||||
{
|
this.self = true;
|
||||||
this.self = true;
|
manager.enablePlugin(plugin);
|
||||||
if (!plugin.getDescription().getName().toLowerCase().equals("essentials"))
|
}
|
||||||
{
|
|
||||||
manager.enablePlugin(plugin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plugin == null) continue;
|
if(plugin == null) continue;
|
||||||
|
|
||||||
Method current = this.createMethod(plugin);
|
Method current = this.createMethod(plugin);
|
||||||
if (current == null) continue;
|
if(current == null) continue;
|
||||||
|
|
||||||
if (this.preferred.isEmpty())
|
if(this.preferred.isEmpty())
|
||||||
this.Method = current;
|
this.Method = current;
|
||||||
else
|
else {
|
||||||
{
|
this.Attachables.add(current);
|
||||||
this.Attachables.add(current);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.preferred.isEmpty())
|
if(!this.preferred.isEmpty()) {
|
||||||
{
|
do {
|
||||||
do
|
if(hasMethod()) {
|
||||||
{
|
match = true;
|
||||||
if (hasMethod())
|
} else {
|
||||||
{
|
for(Method attached: this.Attachables) {
|
||||||
match = true;
|
if(attached == null) continue;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (Method attached : this.Attachables)
|
|
||||||
{
|
|
||||||
if (attached == null) continue;
|
|
||||||
|
|
||||||
if (hasMethod())
|
if(hasMethod()) {
|
||||||
{
|
match = true;
|
||||||
match = true;
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (this.preferred.isEmpty()) this.Method = attached;
|
if(this.preferred.isEmpty()) this.Method = attached;
|
||||||
|
|
||||||
if (count == 0)
|
if(count == 0) {
|
||||||
{
|
if(this.preferred.equalsIgnoreCase(attached.getName()))
|
||||||
if (this.preferred.equalsIgnoreCase(attached.getName()))
|
this.Method = attached;
|
||||||
this.Method = attached;
|
} else {
|
||||||
}
|
this.Method = attached;
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
this.Method = attached;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
} while(!match);
|
||||||
while (!match);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return hasMethod();
|
return hasMethod();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Method getMethod()
|
public Method getMethod() {
|
||||||
{
|
return Method;
|
||||||
return Method;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkDisabled(Plugin method)
|
public boolean checkDisabled(Plugin method) {
|
||||||
{
|
if(!hasMethod()) return true;
|
||||||
if (!hasMethod()) return true;
|
if (Method.isCompatible(method)) Method = null;
|
||||||
if (Method.isCompatible(method)) Method = null;
|
return (Method == null);
|
||||||
return (Method == null);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user