mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-04-27 08:59:45 +00:00
[trunk] Register 1.7
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1539 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
0b8f6e2694
commit
faa830ef2d
2 changed files with 52 additions and 8 deletions
|
@ -15,16 +15,17 @@ import org.bukkit.plugin.PluginManager;
|
||||||
* @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 Method Method = null;
|
private Method Method = null;
|
||||||
|
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>();
|
||||||
|
|
||||||
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() {
|
||||||
|
@ -53,18 +54,61 @@ public class Methods {
|
||||||
|
|
||||||
public boolean setMethod(Plugin method) {
|
public boolean setMethod(Plugin method) {
|
||||||
if(hasMethod()) return true;
|
if(hasMethod()) return true;
|
||||||
|
if(self) { self = false; return false; }
|
||||||
|
|
||||||
PluginManager manager = method.getServer().getPluginManager();
|
int count = 0;
|
||||||
|
boolean match = false;
|
||||||
Plugin plugin = null;
|
Plugin plugin = null;
|
||||||
|
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; else plugin = manager.getPlugin(name);
|
||||||
if(plugin == null) continue;
|
if(plugin == null) continue;
|
||||||
if(!plugin.isEnabled()) continue;
|
|
||||||
|
if(!plugin.isEnabled()) {
|
||||||
|
this.self = true;
|
||||||
|
manager.enablePlugin(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(plugin == null) continue;
|
||||||
|
|
||||||
Method current = this.createMethod(plugin);
|
Method current = this.createMethod(plugin);
|
||||||
if (current != null) this.Method = current;
|
if(current == null) continue;
|
||||||
|
|
||||||
|
if(this.preferred.isEmpty())
|
||||||
|
this.Method = current;
|
||||||
|
else {
|
||||||
|
this.Attachables.add(current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!this.preferred.isEmpty()) {
|
||||||
|
do {
|
||||||
|
if(hasMethod()) {
|
||||||
|
match = true;
|
||||||
|
} else {
|
||||||
|
for(Method attached: this.Attachables) {
|
||||||
|
if(attached == null) continue;
|
||||||
|
|
||||||
|
if(hasMethod()) {
|
||||||
|
match = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.preferred.isEmpty()) this.Method = attached;
|
||||||
|
|
||||||
|
if(count == 0) {
|
||||||
|
if(this.preferred.equalsIgnoreCase(attached.getName()))
|
||||||
|
this.Method = attached;
|
||||||
|
} else {
|
||||||
|
this.Method = attached;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
} while(!match);
|
||||||
}
|
}
|
||||||
|
|
||||||
return hasMethod();
|
return hasMethod();
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class iCo5 implements Method {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBankAccount(String bank, String name) {
|
public boolean hasBankAccount(String bank, String name) {
|
||||||
return (hasBank(bank)) ? false : this.iConomy.getBank(name).hasAccount(name);
|
return (!hasBank(bank)) ? false : this.iConomy.getBank(bank).hasAccount(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MethodAccount getAccount(String name) {
|
public MethodAccount getAccount(String name) {
|
||||||
|
|
Loading…
Reference in a new issue