mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 20:29:20 +00:00
Merge branch 'master' into release
This commit is contained in:
commit
d9a93d8dff
7 changed files with 235 additions and 40 deletions
|
@ -26,7 +26,7 @@ dist.jar=${dist.dir}/Essentials.jar
|
||||||
dist.javadoc.dir=${dist.dir}/javadoc
|
dist.javadoc.dir=${dist.dir}/javadoc
|
||||||
endorsed.classpath=
|
endorsed.classpath=
|
||||||
excludes=
|
excludes=
|
||||||
file.reference.BOSEconomy.jar=../lib/BOSEconomy.jar
|
file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar
|
||||||
file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar
|
file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar
|
||||||
file.reference.iCo4.jar=../lib/iCo4.jar
|
file.reference.iCo4.jar=../lib/iCo4.jar
|
||||||
file.reference.iCo5.jar=../lib/iCo5.jar
|
file.reference.iCo5.jar=../lib/iCo5.jar
|
||||||
|
@ -37,9 +37,9 @@ jar.compress=false
|
||||||
javac.classpath=\
|
javac.classpath=\
|
||||||
${file.reference.Permissions3.jar}:\
|
${file.reference.Permissions3.jar}:\
|
||||||
${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\
|
${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\
|
||||||
${file.reference.BOSEconomy.jar}:\
|
|
||||||
${file.reference.iCo4.jar}:\
|
${file.reference.iCo4.jar}:\
|
||||||
${file.reference.iCo5.jar}
|
${file.reference.iCo5.jar}:\
|
||||||
|
${file.reference.BOSEconomy7.jar}
|
||||||
# Space-separated list of extra javac options
|
# Space-separated list of extra javac options
|
||||||
javac.compilerargs=
|
javac.compilerargs=
|
||||||
javac.deprecation=false
|
javac.deprecation=false
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
package com.earth2me.essentials.register.payment;
|
package com.earth2me.essentials.register.payment;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
/***
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
* 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.
|
||||||
*
|
*
|
||||||
|
@ -25,9 +23,27 @@ public class Methods {
|
||||||
private Set<Method> Attachables = new HashSet<Method>();
|
private Set<Method> Attachables = new HashSet<Method>();
|
||||||
|
|
||||||
public Methods() {
|
public Methods() {
|
||||||
|
this._init();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows you to set which economy plugin is most preferred.
|
||||||
|
*
|
||||||
|
* @param preferred - preferred economy plugin
|
||||||
|
*/
|
||||||
|
public Methods(String preferred) {
|
||||||
|
this._init();
|
||||||
|
|
||||||
|
if(this.Dependencies.contains(preferred)) {
|
||||||
|
this.preferred = preferred;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void _init() {
|
||||||
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.BOSE6());
|
||||||
|
this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE7());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getDependencies() {
|
public Set<String> getDependencies() {
|
||||||
|
@ -60,7 +76,7 @@ public class Methods {
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
boolean match = false;
|
boolean match = false;
|
||||||
Plugin plugin = null;
|
Plugin plugin;
|
||||||
PluginManager manager = method.getServer().getPluginManager();
|
PluginManager manager = method.getServer().getPluginManager();
|
||||||
|
|
||||||
for(String name: this.getDependencies()) {
|
for(String name: this.getDependencies()) {
|
||||||
|
@ -68,14 +84,6 @@ public class Methods {
|
||||||
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()) {
|
|
||||||
this.self = true;
|
|
||||||
//Logger.getLogger("Minecraft").log(Level.SEVERE, name + " Plugin was found, but not enabled before Essentials. Read the Essentials thread for help.");
|
|
||||||
//manager.enablePlugin(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(plugin == null) continue;
|
|
||||||
|
|
||||||
Method current = this.createMethod(plugin);
|
Method current = this.createMethod(plugin);
|
||||||
if(current == null) continue;
|
if(current == null) continue;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import com.earth2me.essentials.register.payment.Method;
|
||||||
import cosine.boseconomy.BOSEconomy;
|
import cosine.boseconomy.BOSEconomy;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
public class BOSE implements Method {
|
public class BOSE6 implements Method {
|
||||||
private BOSEconomy BOSEconomy;
|
private BOSEconomy BOSEconomy;
|
||||||
|
|
||||||
public BOSEconomy getPlugin() {
|
public BOSEconomy getPlugin() {
|
||||||
|
@ -38,7 +38,7 @@ public class BOSE implements Method {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBankAccount(String bank, String name) {
|
public boolean hasBankAccount(String bank, String name) {
|
||||||
return this.BOSEconomy.isBankOwner(bank, name);
|
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MethodAccount getAccount(String name) {
|
public MethodAccount getAccount(String name) {
|
||||||
|
@ -47,11 +47,12 @@ public class BOSE implements Method {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||||
return new BOSEBankAccount(bank, name, BOSEconomy);
|
if(!hasBankAccount(bank, name)) return null;
|
||||||
|
return new BOSEBankAccount(bank, BOSEconomy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCompatible(Plugin plugin) {
|
public boolean isCompatible(Plugin plugin) {
|
||||||
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy;
|
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy && plugin.getDescription().getVersion().equals("0.6.2");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlugin(Plugin plugin) {
|
public void setPlugin(Plugin plugin) {
|
||||||
|
@ -122,11 +123,9 @@ public class BOSE implements Method {
|
||||||
|
|
||||||
public class BOSEBankAccount implements MethodBankAccount {
|
public class BOSEBankAccount implements MethodBankAccount {
|
||||||
private String bank;
|
private String bank;
|
||||||
private String name;
|
|
||||||
private BOSEconomy BOSEconomy;
|
private BOSEconomy BOSEconomy;
|
||||||
|
|
||||||
public BOSEBankAccount(String bank, String name, BOSEconomy bOSEconomy) {
|
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) {
|
||||||
this.name = name;
|
|
||||||
this.bank = bank;
|
this.bank = bank;
|
||||||
this.BOSEconomy = bOSEconomy;
|
this.BOSEconomy = bOSEconomy;
|
||||||
}
|
}
|
||||||
|
@ -140,36 +139,36 @@ public class BOSE implements Method {
|
||||||
}
|
}
|
||||||
|
|
||||||
public double balance() {
|
public double balance() {
|
||||||
return Double.valueOf(this.BOSEconomy.getBankMoney(name));
|
return Double.valueOf(this.BOSEconomy.getBankMoney(bank));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean set(double amount) {
|
public boolean set(double amount) {
|
||||||
int IntAmount = (int)Math.ceil(amount);
|
int IntAmount = (int)Math.ceil(amount);
|
||||||
return this.BOSEconomy.setBankMoney(name, IntAmount, true);
|
return this.BOSEconomy.setBankMoney(bank, IntAmount, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean add(double amount) {
|
public boolean add(double amount) {
|
||||||
int IntAmount = (int)Math.ceil(amount);
|
int IntAmount = (int)Math.ceil(amount);
|
||||||
int balance = (int)this.balance();
|
int balance = (int)this.balance();
|
||||||
return this.BOSEconomy.setBankMoney(this.name, (balance + IntAmount), false);
|
return this.BOSEconomy.setBankMoney(bank, (balance + IntAmount), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean subtract(double amount) {
|
public boolean subtract(double amount) {
|
||||||
int IntAmount = (int)Math.ceil(amount);
|
int IntAmount = (int)Math.ceil(amount);
|
||||||
int balance = (int)this.balance();
|
int balance = (int)this.balance();
|
||||||
return this.BOSEconomy.setBankMoney(this.name, (balance - IntAmount), false);
|
return this.BOSEconomy.setBankMoney(bank, (balance - IntAmount), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean multiply(double amount) {
|
public boolean multiply(double amount) {
|
||||||
int IntAmount = (int)Math.ceil(amount);
|
int IntAmount = (int)Math.ceil(amount);
|
||||||
int balance = (int)this.balance();
|
int balance = (int)this.balance();
|
||||||
return this.BOSEconomy.setBankMoney(this.name, (balance * IntAmount), false);
|
return this.BOSEconomy.setBankMoney(bank, (balance * IntAmount), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean divide(double amount) {
|
public boolean divide(double amount) {
|
||||||
int IntAmount = (int)Math.ceil(amount);
|
int IntAmount = (int)Math.ceil(amount);
|
||||||
int balance = (int)this.balance();
|
int balance = (int)this.balance();
|
||||||
return this.BOSEconomy.setBankMoney(this.name, (balance / IntAmount), false);
|
return this.BOSEconomy.setBankMoney(bank, (balance / IntAmount), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasEnough(double amount) {
|
public boolean hasEnough(double amount) {
|
|
@ -0,0 +1,188 @@
|
||||||
|
package com.earth2me.essentials.register.payment.methods;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.register.payment.Method;
|
||||||
|
import cosine.boseconomy.BOSEconomy;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Acrobot
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class BOSE7 implements Method {
|
||||||
|
private BOSEconomy BOSEconomy;
|
||||||
|
|
||||||
|
public BOSEconomy getPlugin() {
|
||||||
|
return this.BOSEconomy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "BOSEconomy";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersion() {
|
||||||
|
return "0.7.0";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String format(double amount) {
|
||||||
|
String currency = this.BOSEconomy.getMoneyNamePlural();
|
||||||
|
if(amount == 1) currency = this.BOSEconomy.getMoneyName();
|
||||||
|
return amount + " " + currency;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasBanks() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasBank(String bank) {
|
||||||
|
return this.BOSEconomy.bankExists(bank);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasAccount(String name) {
|
||||||
|
return this.BOSEconomy.playerRegistered(name, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasBankAccount(String bank, String name) {
|
||||||
|
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MethodAccount getAccount(String name) {
|
||||||
|
if(!hasAccount(name)) return null;
|
||||||
|
return new BOSEAccount(name, this.BOSEconomy);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||||
|
if(!hasBankAccount(bank, name)) return null;
|
||||||
|
return new BOSEBankAccount(bank, BOSEconomy);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCompatible(Plugin plugin) {
|
||||||
|
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy && !plugin.getDescription().getVersion().equals("0.6.2");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlugin(Plugin plugin) {
|
||||||
|
BOSEconomy = (BOSEconomy)plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BOSEAccount implements MethodAccount {
|
||||||
|
private String name;
|
||||||
|
private BOSEconomy BOSEconomy;
|
||||||
|
|
||||||
|
public BOSEAccount(String name, BOSEconomy bOSEconomy) {
|
||||||
|
this.name = name;
|
||||||
|
this.BOSEconomy = bOSEconomy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double balance() {
|
||||||
|
return this.BOSEconomy.getPlayerMoneyDouble(this.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean set(double amount) {
|
||||||
|
return this.BOSEconomy.setPlayerMoney(this.name, amount, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean add(double amount) {
|
||||||
|
return this.BOSEconomy.addPlayerMoney(this.name, amount, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean subtract(double amount) {
|
||||||
|
double balance = this.balance();
|
||||||
|
return this.BOSEconomy.setPlayerMoney(this.name, (balance - amount), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean multiply(double amount) {
|
||||||
|
double balance = this.balance();
|
||||||
|
return this.BOSEconomy.setPlayerMoney(this.name, (balance * amount), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean divide(double amount) {
|
||||||
|
double balance = this.balance();
|
||||||
|
return this.BOSEconomy.setPlayerMoney(this.name, (balance / amount), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasEnough(double amount) {
|
||||||
|
return (this.balance() >= amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasOver(double amount) {
|
||||||
|
return (this.balance() > amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasUnder(double amount) {
|
||||||
|
return (this.balance() < amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNegative() {
|
||||||
|
return (this.balance() < 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean remove() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BOSEBankAccount implements MethodBankAccount {
|
||||||
|
private String bank;
|
||||||
|
private BOSEconomy BOSEconomy;
|
||||||
|
|
||||||
|
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) {
|
||||||
|
this.bank = bank;
|
||||||
|
this.BOSEconomy = bOSEconomy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBankName() {
|
||||||
|
return this.bank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBankId() {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double balance() {
|
||||||
|
return this.BOSEconomy.getBankMoneyDouble(bank);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean set(double amount) {
|
||||||
|
return this.BOSEconomy.setBankMoney(bank, amount, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean add(double amount) {
|
||||||
|
double balance = this.balance();
|
||||||
|
return this.BOSEconomy.setBankMoney(bank, (balance + amount), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean subtract(double amount) {
|
||||||
|
double balance = this.balance();
|
||||||
|
return this.BOSEconomy.setBankMoney(bank, (balance - amount), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean multiply(double amount) {
|
||||||
|
double balance = this.balance();
|
||||||
|
return this.BOSEconomy.setBankMoney(bank, (balance * amount), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean divide(double amount) {
|
||||||
|
double balance = this.balance();
|
||||||
|
return this.BOSEconomy.setBankMoney(bank, (balance / amount), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasEnough(double amount) {
|
||||||
|
return (this.balance() >= amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasOver(double amount) {
|
||||||
|
return (this.balance() > amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasUnder(double amount) {
|
||||||
|
return (this.balance() < amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNegative() {
|
||||||
|
return (this.balance() < 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean remove() {
|
||||||
|
return this.BOSEconomy.removeBank(bank);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
BIN
lib/BOSEconomy7.jar
Normal file
BIN
lib/BOSEconomy7.jar
Normal file
Binary file not shown.
Loading…
Reference in a new issue