summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Essentials/nbproject/project.properties6
-rw-r--r--Essentials/src/com/earth2me/essentials/register/payment/Methods.java48
-rw-r--r--Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE6.java (renamed from Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE.java)25
-rw-r--r--Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE7.java188
-rw-r--r--Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java2
-rw-r--r--lib/BOSEconomy.jarbin130814 -> 0 bytes
-rw-r--r--lib/BOSEconomy7.jarbin0 -> 155916 bytes
7 files changed, 232 insertions, 37 deletions
diff --git a/Essentials/nbproject/project.properties b/Essentials/nbproject/project.properties
index 850d0d4d8..f8b41cf41 100644
--- a/Essentials/nbproject/project.properties
+++ b/Essentials/nbproject/project.properties
@@ -26,7 +26,7 @@ dist.jar=${dist.dir}/Essentials.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
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.iCo4.jar=../lib/iCo4.jar
file.reference.iCo5.jar=../lib/iCo5.jar
@@ -37,9 +37,9 @@ jar.compress=false
javac.classpath=\
${file.reference.Permissions3.jar}:\
${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\
- ${file.reference.BOSEconomy.jar}:\
${file.reference.iCo4.jar}:\
- ${file.reference.iCo5.jar}
+ ${file.reference.iCo5.jar}:\
+ ${file.reference.BOSEconomy7.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
diff --git a/Essentials/src/com/earth2me/essentials/register/payment/Methods.java b/Essentials/src/com/earth2me/essentials/register/payment/Methods.java
index 71e0adae0..0ebbcfb84 100644
--- a/Essentials/src/com/earth2me/essentials/register/payment/Methods.java
+++ b/Essentials/src/com/earth2me/essentials/register/payment/Methods.java
@@ -1,14 +1,12 @@
package com.earth2me.essentials.register.payment;
+import org.bukkit.plugin.Plugin;
+import org.bukkit.plugin.PluginManager;
+
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.PluginManager;
-
-/***
+/**
* Methods.java
* Controls the getting / setting of methods & the method of payment used.
*
@@ -19,18 +17,36 @@ import org.bukkit.plugin.PluginManager;
public class Methods {
private boolean self = false;
private Method Method = null;
- private String preferred = "";
+ private String preferred = "";
private Set<Method> Methods = new HashSet<Method>();
private Set<String> Dependencies = new HashSet<String>();
- private Set<Method> Attachables = new HashSet<Method>();
+ private Set<Method> Attachables = new HashSet<Method>();
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.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() {
return Dependencies;
}
@@ -60,7 +76,7 @@ public class Methods {
int count = 0;
boolean match = false;
- Plugin plugin = null;
+ Plugin plugin;
PluginManager manager = method.getServer().getPluginManager();
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(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);
if(current == null) continue;
@@ -86,7 +94,7 @@ public class Methods {
}
}
- if(!this.preferred.isEmpty()) {
+ if(!this.preferred.isEmpty()) {
do {
if(hasMethod()) {
match = true;
diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE6.java
index cce5691b9..6293f81be 100644
--- a/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE.java
+++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE6.java
@@ -4,7 +4,7 @@ import com.earth2me.essentials.register.payment.Method;
import cosine.boseconomy.BOSEconomy;
import org.bukkit.plugin.Plugin;
-public class BOSE implements Method {
+public class BOSE6 implements Method {
private BOSEconomy BOSEconomy;
public BOSEconomy getPlugin() {
@@ -38,7 +38,7 @@ public class BOSE implements Method {
}
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) {
@@ -47,11 +47,12 @@ public class BOSE implements Method {
}
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) {
- 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) {
@@ -122,11 +123,9 @@ public class BOSE implements Method {
public class BOSEBankAccount implements MethodBankAccount {
private String bank;
- private String name;
private BOSEconomy BOSEconomy;
- public BOSEBankAccount(String bank, String name, BOSEconomy bOSEconomy) {
- this.name = name;
+ public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) {
this.bank = bank;
this.BOSEconomy = bOSEconomy;
}
@@ -140,36 +139,36 @@ public class BOSE implements Method {
}
public double balance() {
- return Double.valueOf(this.BOSEconomy.getBankMoney(name));
+ return Double.valueOf(this.BOSEconomy.getBankMoney(bank));
}
public boolean set(double 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) {
int IntAmount = (int)Math.ceil(amount);
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) {
int IntAmount = (int)Math.ceil(amount);
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) {
int IntAmount = (int)Math.ceil(amount);
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) {
int IntAmount = (int)Math.ceil(amount);
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) {
diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE7.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE7.java
new file mode 100644
index 000000000..3612c89e4
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE7.java
@@ -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);
+ }
+ }
+} \ No newline at end of file
diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java
index f30af7dde..28931eac2 100644
--- a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java
+++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java
@@ -208,4 +208,4 @@ public class iCo5 implements Method {
return true;
}
}
-} \ No newline at end of file
+}
diff --git a/lib/BOSEconomy.jar b/lib/BOSEconomy.jar
deleted file mode 100644
index bba5231f9..000000000
--- a/lib/BOSEconomy.jar
+++ /dev/null
Binary files differ
diff --git a/lib/BOSEconomy7.jar b/lib/BOSEconomy7.jar
new file mode 100644
index 000000000..2ce672afa
--- /dev/null
+++ b/lib/BOSEconomy7.jar
Binary files differ