diff --git a/BOSEconomy.jar b/BOSEconomy.jar deleted file mode 100644 index c099feb..0000000 Binary files a/BOSEconomy.jar and /dev/null differ diff --git a/BOSEconomy7.jar b/BOSEconomy7.jar deleted file mode 100644 index 2ce672a..0000000 Binary files a/BOSEconomy7.jar and /dev/null differ diff --git a/Essentials.jar b/Essentials.jar deleted file mode 100644 index 2175c49..0000000 Binary files a/Essentials.jar and /dev/null differ diff --git a/MultiCurrency.jar b/MultiCurrency.jar deleted file mode 100644 index 6a0a02d..0000000 Binary files a/MultiCurrency.jar and /dev/null differ diff --git a/Vault.jar b/Vault.jar new file mode 100644 index 0000000..04d5719 Binary files /dev/null and b/Vault.jar differ diff --git a/iCo4.jar b/iCo4.jar deleted file mode 100644 index 6cb256b..0000000 Binary files a/iCo4.jar and /dev/null differ diff --git a/iCo5.jar b/iCo5.jar deleted file mode 100644 index 71a5d71..0000000 Binary files a/iCo5.jar and /dev/null differ diff --git a/iCo6.jar b/iCo6.jar deleted file mode 100644 index da3a867..0000000 Binary files a/iCo6.jar and /dev/null differ diff --git a/nbproject/project.properties b/nbproject/project.properties index 79924ea..a25f096 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -26,14 +26,9 @@ dist.jar=${dist.dir}/Catacombs.jar dist.javadoc.dir=${dist.dir}/javadoc endorsed.classpath= excludes= -file.reference.BOSEconomy7.jar=BOSEconomy7.jar +file.reference.Vault.jar=Vault.jar file.reference.bpermissions.jar=bpermissions.jar file.reference.craftbukkit-1.2.5-R1.0.jar=craftbukkit-1.2.5-R1.0.jar -file.reference.Essentials.jar=Essentials.jar -file.reference.iCo4.jar=iCo4.jar -file.reference.iCo5.jar=iCo5.jar -file.reference.iCo6.jar=iCo6.jar -file.reference.MultiCurrency.jar=MultiCurrency.jar file.reference.mysql-connector-java-5.1.17-bin.jar=../../../../Users/User/Downloads/mysql-connector-java-5.1.17-bin.jar file.reference.Permissions.jar=Permissions.jar file.reference.PermissionsEx.jar=PermissionsEx.jar @@ -43,15 +38,10 @@ jar.compress=false jar.index=${jnlp.enabled} javac.classpath=\ ${file.reference.mysql-connector-java-5.1.17-bin.jar}:\ - ${file.reference.iCo4.jar}:\ - ${file.reference.iCo5.jar}:\ - ${file.reference.iCo6.jar}:\ - ${file.reference.MultiCurrency.jar}:\ - ${file.reference.Essentials.jar}:\ - ${file.reference.BOSEconomy7.jar}:\ ${file.reference.PermissionsEx.jar}:\ ${file.reference.Permissions.jar}:\ ${file.reference.bpermissions.jar}:\ + ${file.reference.Vault.jar}:\ ${file.reference.craftbukkit-1.2.5-R1.0.jar} # Space-separated list of extra javac options javac.compilerargs=-Xlint:unchecked -Xlint:deprecation diff --git a/src/com/nijikokun/catacombsregister/payment/Method.java b/src/com/nijikokun/catacombsregister/payment/Method.java deleted file mode 100644 index 13af33e..0000000 --- a/src/com/nijikokun/catacombsregister/payment/Method.java +++ /dev/null @@ -1,183 +0,0 @@ -package com.nijikokun.catacombsregister.payment; - -import org.bukkit.plugin.Plugin; - -/** - * Interface to be implemented by a payment method. - * - * @author Nijikokun (@nijikokun) - * @copyright Copyright (C) 2011 - * @license AOL license - */ -public interface Method { - /** - * Encodes the Plugin into an Object disguised as the Plugin. - * If you want the original Plugin Class you must cast it to the correct - * Plugin, to do so you have to verify the name and or version then cast. - * - *
-     *  if(method.getName().equalsIgnoreCase("iConomy"))
-     *   iConomy plugin = ((iConomy)method.getPlugin());
- * - * @return Object - * @see #getName() - * @see #getVersion() - */ - public Object getPlugin(); - - /** - * Returns the actual name of this method. - * - * @return String Plugin name. - */ - public String getName(); - - /** - * Returns the actual version of this method. - * - * @return String Plugin version. - */ - public String getVersion(); - - /** - * Returns the amount of decimal places that get stored - * NOTE: it will return -1 if there is no rounding - * - * @return int for each decimal place - */ - public int fractionalDigits(); - - /** - * Formats amounts into this payment methods style of currency display. - * - * @param amount Double - * @return String - Formatted Currency Display. - */ - public String format(double amount); - - /** - * Allows the verification of bank API existence in this payment method. - * - * @return boolean - */ - public boolean hasBanks(); - - /** - * Determines the existence of a bank via name. - * - * @param bank Bank name - * @return boolean - * @see #hasBanks - */ - public boolean hasBank(String bank); - - /** - * Determines the existence of an account via name. - * - * @param name Account name - * @return boolean - */ - public boolean hasAccount(String name); - - /** - * Check to see if an account name is tied to a bank. - * - * @param bank Bank name - * @param name Account name - * @return boolean - */ - public boolean hasBankAccount(String bank, String name); - - /** - * Forces an account creation - * - * @param name Account name - * @return boolean - */ - public boolean createAccount(String name); - - /** - * Forces an account creation - * - * @param name Account name - * @param balance Initial account balance - * @return boolean - */ - public boolean createAccount(String name, Double balance); - - /** - * Returns a MethodAccount class for an account name. - * - * @param name Account name - * @return MethodAccount or Null - */ - public MethodAccount getAccount(String name); - - - /** - * Returns a MethodBankAccount class for an account name. - * - * @param bank Bank name - * @param name Account name - * @return MethodBankAccount or Null - */ - public MethodBankAccount getBankAccount(String bank, String name); - - /** - * Checks to verify the compatibility between this Method and a plugin. - * Internal usage only, for the most part. - * - * @param plugin Plugin - * @return boolean - */ - public boolean isCompatible(Plugin plugin); - - /** - * Set Plugin data. - * - * @param plugin Plugin - */ - public void setPlugin(Plugin plugin); - - /** - * Contains Calculator and Balance functions for Accounts. - */ - public interface MethodAccount { - public double balance(); - public boolean set(double amount); - public boolean add(double amount); - public boolean subtract(double amount); - public boolean multiply(double amount); - public boolean divide(double amount); - public boolean hasEnough(double amount); - public boolean hasOver(double amount); - public boolean hasUnder(double amount); - public boolean isNegative(); - public boolean remove(); - - @Override - public String toString(); - } - - /** - * Contains Calculator and Balance functions for Bank Accounts. - */ - public interface MethodBankAccount { - public double balance(); - public String getBankName(); - public int getBankId(); - public boolean set(double amount); - public boolean add(double amount); - public boolean subtract(double amount); - public boolean multiply(double amount); - public boolean divide(double amount); - public boolean hasEnough(double amount); - public boolean hasOver(double amount); - public boolean hasUnder(double amount); - public boolean isNegative(); - public boolean remove(); - - @Override - public String toString(); - } -} diff --git a/src/com/nijikokun/catacombsregister/payment/Methods.java b/src/com/nijikokun/catacombsregister/payment/Methods.java deleted file mode 100644 index 3f95edd..0000000 --- a/src/com/nijikokun/catacombsregister/payment/Methods.java +++ /dev/null @@ -1,243 +0,0 @@ -package com.nijikokun.catacombsregister.payment; - -import java.util.HashSet; -import java.util.Set; - -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.PluginManager; - -/** - * The Methods initializes Methods that utilize the Method interface - * based on a "first come, first served" basis. - * - * Allowing you to check whether a payment method exists or not. - * - * Methods also allows you to set a preferred method of payment before it captures - * payment plugins in the initialization process. - * - * in bukkit.yml: - *
- *  economy:
- *      preferred: "iConomy"
- * 
- * - * @author: Nijikokun (@nijikokun) - * @copyright: Copyright (C) 2011 - * @license: AOL license - */ -public class Methods { - private static String version = null; - private static boolean self = false; - private static Method Method = null; - private static String preferred = ""; - private static Set Methods = new HashSet(); - private static Set Dependencies = new HashSet(); - private static Set Attachables = new HashSet(); - - static { - _init(); - } - - /** - * Implement all methods along with their respective name & class. - */ - private static void _init() { - addMethod("iConomy", new com.nijikokun.catacombsregister.payment.methods.iCo6()); - addMethod("iConomy", new com.nijikokun.catacombsregister.payment.methods.iCo5()); - addMethod("iConomy", new com.nijikokun.catacombsregister.payment.methods.iCo4()); - addMethod("BOSEconomy", new com.nijikokun.catacombsregister.payment.methods.BOSE6()); - addMethod("BOSEconomy", new com.nijikokun.catacombsregister.payment.methods.BOSE7()); - addMethod("Essentials", new com.nijikokun.catacombsregister.payment.methods.EE17()); - addMethod("Currency", new com.nijikokun.catacombsregister.payment.methods.MCUR()); - Dependencies.add("MultiCurrency"); - } - - /** - * Used by the plugin to setup version - * - * @param v version - */ - public static void setVersion(String v) { - version = v; - } - - /** - * Use to reset methods during disable - */ - public static void reset() { - version = null; - self = false; - Method = null; - preferred = ""; - Attachables.clear(); - } - - /** - * Use to get version of Register plugin - * @return version - */ - public static String getVersion() { - return version; - } - - /** - * Returns an array of payment method names that have been loaded - * through the _init method. - * - * @return Set - Array of payment methods that are loaded. - * @see #setMethod(org.bukkit.plugin.Plugin) - */ - public static Set getDependencies() { - // for(String s : Dependencies) { - // System.out.println(" dep="+s); - // } - return Dependencies; - } - - /** - * Interprets Plugin class data to verify whether it is compatible with an existing payment - * method to use for payments and other various economic activity. - * - * @param plugin Plugin data from bukkit, Internal Class file. - * @return Method or Null - */ - public static Method createMethod(Plugin plugin) { - for (Method method: Methods) - if (method.isCompatible(plugin)) { - method.setPlugin(plugin); - return method; - } - - return null; - } - - private static void addMethod(String name, Method method) { - Dependencies.add(name); - Methods.add(method); - } - - /** - * Verifies if Register has set a payment method for usage yet. - * - * @return boolean - * @see #setMethod(org.bukkit.plugin.Plugin) - * @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. - * - * @param PluginManager the plugin manager for the server - * @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 = null; - - for (String name : getDependencies()) { - if (hasMethod()) - break; - - plugin = manager.getPlugin(name); - if (plugin == null || !plugin.isEnabled()) - 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(); - } - - /** - * Sets the preferred economy - * - * @return boolean - */ - public static boolean setPreferred(String check) { - if (getDependencies().contains(check)) { - // System.out.println(" set preferred="+check); - preferred = check; - return true; - } - - return false; - } - public static String getPreferred() { - return preferred; - } - /** - * 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); - } -} diff --git a/src/com/nijikokun/catacombsregister/payment/methods/BOSE6.java b/src/com/nijikokun/catacombsregister/payment/methods/BOSE6.java deleted file mode 100644 index 7827f78..0000000 --- a/src/com/nijikokun/catacombsregister/payment/methods/BOSE6.java +++ /dev/null @@ -1,234 +0,0 @@ -package com.nijikokun.catacombsregister.payment.methods; - -import com.nijikokun.catacombsregister.payment.Method; - -import cosine.boseconomy.BOSEconomy; -import org.bukkit.plugin.Plugin; - -/** - * BOSEconomy 6 Implementation of Method - * - * @author Nijikokun (@nijikokun) - * @copyright (c) 2011 - * @license AOL license - */ -@SuppressWarnings("deprecation") -public class BOSE6 implements Method { - private BOSEconomy BOSEconomy; - - public BOSEconomy getPlugin() { - return this.BOSEconomy; - } - - public String getName() { - return "BOSEconomy"; - } - - public String getVersion() { - return "0.6.2"; - } - - public int fractionalDigits() { - return 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 boolean createAccount(String name) { - if(hasAccount(name)) - return false; - - this.BOSEconomy.registerPlayer(name); - return true; - } - - public boolean createAccount(String name, Double balance) { - if(hasAccount(name)) - return false; - - this.BOSEconomy.registerPlayer(name); - this.BOSEconomy.setPlayerMoney(name, balance, false); - return true; - } - - 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 final String name; - private final BOSEconomy BOSEconomy; - - public BOSEAccount(String name, BOSEconomy bOSEconomy) { - this.name = name; - this.BOSEconomy = bOSEconomy; - } - - public double balance() { - return (double) this.BOSEconomy.getPlayerMoney(this.name); - } - - public boolean set(double amount) { - int IntAmount = (int)Math.ceil(amount); - return this.BOSEconomy.setPlayerMoney(this.name, IntAmount, false); - } - - public boolean add(double amount) { - int IntAmount = (int)Math.ceil(amount); - return this.BOSEconomy.addPlayerMoney(this.name, IntAmount, false); - } - - public boolean subtract(double amount) { - int IntAmount = (int)Math.ceil(amount); - int balance = (int)this.balance(); - return this.BOSEconomy.setPlayerMoney(this.name, (balance - IntAmount), false); - } - - public boolean multiply(double amount) { - int IntAmount = (int)Math.ceil(amount); - int balance = (int)this.balance(); - return this.BOSEconomy.setPlayerMoney(this.name, (balance * IntAmount), false); - } - - public boolean divide(double amount) { - int IntAmount = (int)Math.ceil(amount); - int balance = (int)this.balance(); - return this.BOSEconomy.setPlayerMoney(this.name, (balance / IntAmount), 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 final String bank; - private final 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 (double) this.BOSEconomy.getBankMoney(bank); - } - - public boolean set(double amount) { - int IntAmount = (int)Math.ceil(amount); - 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(bank, (balance + IntAmount), false); - } - - public boolean subtract(double amount) { - int IntAmount = (int)Math.ceil(amount); - int balance = (int)this.balance(); - 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(bank, (balance * IntAmount), false); - } - - public boolean divide(double amount) { - int IntAmount = (int)Math.ceil(amount); - int balance = (int)this.balance(); - return this.BOSEconomy.setBankMoney(bank, (balance / IntAmount), 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/src/com/nijikokun/catacombsregister/payment/methods/BOSE7.java b/src/com/nijikokun/catacombsregister/payment/methods/BOSE7.java deleted file mode 100644 index 6c68cb8..0000000 --- a/src/com/nijikokun/catacombsregister/payment/methods/BOSE7.java +++ /dev/null @@ -1,223 +0,0 @@ -package com.nijikokun.catacombsregister.payment.methods; - -import com.nijikokun.catacombsregister.payment.Method; - -import cosine.boseconomy.BOSEconomy; -import org.bukkit.plugin.Plugin; - -/** - * BOSEconomy 7 Implementation of Method - * - * @author Acrobot - * @author Nijikokun (@nijikokun) - * @copyright (c) 2011 - * @license AOL license - */ -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 int fractionalDigits() { - return this.BOSEconomy.getFractionalDigits(); - } - - 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 boolean createAccount(String name) { - if(hasAccount(name)) - return false; - - this.BOSEconomy.registerPlayer(name); - return true; - } - - public boolean createAccount(String name, Double balance) { - if(hasAccount(name)) - return false; - - this.BOSEconomy.registerPlayer(name); - this.BOSEconomy.setPlayerMoney(name, balance, false); - return true; - } - - 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/src/com/nijikokun/catacombsregister/payment/methods/EE17.java b/src/com/nijikokun/catacombsregister/payment/methods/EE17.java deleted file mode 100644 index fbb26d7..0000000 --- a/src/com/nijikokun/catacombsregister/payment/methods/EE17.java +++ /dev/null @@ -1,223 +0,0 @@ -package com.nijikokun.catacombsregister.payment.methods; - -import com.nijikokun.catacombsregister.payment.Method; -import com.earth2me.essentials.Essentials; -import com.earth2me.essentials.api.Economy; - -import org.bukkit.plugin.Plugin; - -/** - * Essentials 17 Implementation of Method - * - * @author Nijikokun (@nijikokun) - * @author Snowleo - * @author Acrobot - * @author KHobbits - * @copyright (c) 2011 - * @license AOL license - */ -public class EE17 implements Method { - private Essentials Essentials; - - public Essentials getPlugin() { - return this.Essentials; - } - - public String getName() { - return "Essentials"; - } - - public String getVersion() { - return "2.2"; - } - - public int fractionalDigits() { - return -1; - } - - public String format(double amount) { - return Economy.format(amount); - } - - public boolean hasBanks() { - return false; - } - - public boolean hasBank(String bank) { - return false; - } - - public boolean hasAccount(String name) { - return Economy.playerExists(name); - } - - public boolean hasBankAccount(String bank, String name) { - return false; - } - - public boolean createAccount(String name) { - if(hasAccount(name)) - return false; - - Economy.createNPC(name); - return true; - } - - public boolean createAccount(String name, Double balance) { - if(hasAccount(name)) - return false; - - Economy.createNPC(name); - - try { - Economy.setMoney(name, balance); - } catch (Exception ex) { - System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage()); - return false; - } - - return true; - } - - public MethodAccount getAccount(String name) { - if(!hasAccount(name)) - return null; - - return new EEcoAccount(name); - } - - public MethodBankAccount getBankAccount(String bank, String name) { - return null; - } - - public boolean isCompatible(Plugin plugin) { - try { Class.forName("com.earth2me.essentials.api.Economy"); } - catch(Exception e) { return false; } - - return plugin.getDescription().getName().equalsIgnoreCase("essentials") - && plugin instanceof Essentials; - } - - public void setPlugin(Plugin plugin) { - Essentials = (Essentials)plugin; - } - - public class EEcoAccount implements MethodAccount { - private String name; - - public EEcoAccount(String name) { - this.name = name; - } - - public double balance() { - Double balance = 0.0; - - try { - balance = Economy.getMoney(this.name); - } catch (Exception ex) { - System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage()); - } - - return balance; - } - - public boolean set(double amount) { - try { - Economy.setMoney(name, amount); - } catch (Exception ex) { - System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage()); - return false; - } - - return true; - } - - public boolean add(double amount) { - try { - Economy.add(name, amount); - } catch (Exception ex) { - System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage()); - return false; - } - - return true; - } - - public boolean subtract(double amount) { - try { - Economy.subtract(name, amount); - } catch (Exception ex) { - System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage()); - return false; - } - - return true; - } - - public boolean multiply(double amount) { - try { - Economy.multiply(name, amount); - } catch (Exception ex) { - System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage()); - return false; - } - - return true; - } - - public boolean divide(double amount) { - try { - Economy.divide(name, amount); - } catch (Exception ex) { - System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage()); - return false; - } - - return true; - } - - public boolean hasEnough(double amount) { - try { - return Economy.hasEnough(name, amount); - } catch (Exception ex) { - System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage()); - } - - return false; - } - - public boolean hasOver(double amount) { - try { - return Economy.hasMore(name, amount); - } catch (Exception ex) { - System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage()); - } - - return false; - } - - public boolean hasUnder(double amount) { - try { - return Economy.hasLess(name, amount); - } catch (Exception ex) { - System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage()); - } - - return false; - } - - public boolean isNegative() { - try { - return Economy.isNegative(name); - } catch (Exception ex) { - System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage()); - } - - return false; - } - - public boolean remove() { - return false; - } - } -} \ No newline at end of file diff --git a/src/com/nijikokun/catacombsregister/payment/methods/MCUR.java b/src/com/nijikokun/catacombsregister/payment/methods/MCUR.java deleted file mode 100644 index 99b0fd1..0000000 --- a/src/com/nijikokun/catacombsregister/payment/methods/MCUR.java +++ /dev/null @@ -1,136 +0,0 @@ -package com.nijikokun.catacombsregister.payment.methods; - -import com.nijikokun.catacombsregister.payment.Method; - -import me.ashtheking.currency.Currency; -import me.ashtheking.currency.CurrencyList; - -import org.bukkit.plugin.Plugin; - -/** - * MultiCurrency Method implementation. - * - * @author Acrobot - * @copyright (c) 2011 - * @license AOL license - */ -public class MCUR implements Method { - private Currency currencyList; - - public Object getPlugin() { - return this.currencyList; - } - - public String getName() { - return "MultiCurrency"; - } - - public String getVersion() { - return "0.09"; - } - - public int fractionalDigits() { - return -1; - } - - public String format(double amount) { - return amount + " Currency"; - } - - public boolean hasBanks() { - return false; - } - - public boolean hasBank(String bank) { - return false; - } - - public boolean hasAccount(String name) { - return true; - } - - public boolean hasBankAccount(String bank, String name) { - return false; - } - - public boolean createAccount(String name) { - CurrencyList.setValue((String) CurrencyList.maxCurrency(name)[0], name, 0); - return true; - } - - public boolean createAccount(String name, Double balance) { - CurrencyList.setValue((String) CurrencyList.maxCurrency(name)[0], name, balance); - return true; - } - - public MethodAccount getAccount(String name) { - return new MCurrencyAccount(name); - } - - public MethodBankAccount getBankAccount(String bank, String name) { - return null; - } - - public boolean isCompatible(Plugin plugin) { - return (plugin.getDescription().getName().equalsIgnoreCase("Currency") - || plugin.getDescription().getName().equalsIgnoreCase("MultiCurrency")) - && plugin instanceof Currency; - } - - public void setPlugin(Plugin plugin) { - currencyList = (Currency) plugin; - } - - public class MCurrencyAccount implements MethodAccount{ - private String name; - - public MCurrencyAccount(String name) { - this.name = name; - } - - public double balance() { - return CurrencyList.getValue((String) CurrencyList.maxCurrency(name)[0], name); - } - - public boolean set(double amount) { - CurrencyList.setValue((String) CurrencyList.maxCurrency(name)[0], name, amount); - return true; - } - - public boolean add(double amount) { - return CurrencyList.add(name, amount); - } - - public boolean subtract(double amount) { - return CurrencyList.subtract(name, amount); - } - - public boolean multiply(double amount) { - return CurrencyList.multiply(name, amount); - } - - public boolean divide(double amount) { - return CurrencyList.divide(name, amount); - } - - public boolean hasEnough(double amount) { - return CurrencyList.hasEnough(name, amount); - } - - public boolean hasOver(double amount) { - return CurrencyList.hasOver(name, amount); - } - - public boolean hasUnder(double amount) { - return CurrencyList.hasUnder(name, amount); - } - - public boolean isNegative() { - return CurrencyList.isNegative(name); - } - - public boolean remove() { - return CurrencyList.remove(name); - } - } -} diff --git a/src/com/nijikokun/catacombsregister/payment/methods/iCo4.java b/src/com/nijikokun/catacombsregister/payment/methods/iCo4.java deleted file mode 100644 index 7df652b..0000000 --- a/src/com/nijikokun/catacombsregister/payment/methods/iCo4.java +++ /dev/null @@ -1,167 +0,0 @@ -package com.nijikokun.catacombsregister.payment.methods; - -import com.nijikokun.catacombsregister.payment.Method; -import com.nijiko.coelho.iConomy.iConomy; -import com.nijiko.coelho.iConomy.system.Account; - - -import org.bukkit.plugin.Plugin; - -/** - * iConomy 4 Implementation of Method - * - * @author Nijikokun (@nijikokun) - * @copyright (c) 2011 - * @license AOL license - */ -public class iCo4 implements Method { - private iConomy iConomy; - - public iConomy getPlugin() { - return this.iConomy; - } - - public String getName() { - return "iConomy"; - } - - public String getVersion() { - return "4"; - } - - public int fractionalDigits() { - return 2; - } - - public String format(double amount) { - return com.nijiko.coelho.iConomy.iConomy.getBank().format(amount); - } - - public boolean hasBanks() { - return false; - } - - public boolean hasBank(String bank) { - return false; - } - - public boolean hasAccount(String name) { - return com.nijiko.coelho.iConomy.iConomy.getBank().hasAccount(name); - } - - public boolean hasBankAccount(String bank, String name) { - return false; - } - - public boolean createAccount(String name) { - if(hasAccount(name)) - return false; - - try { - com.nijiko.coelho.iConomy.iConomy.getBank().addAccount(name); - } catch(Exception E) { - return false; - } - - return true; - } - - public boolean createAccount(String name, Double balance) { - if(hasAccount(name)) - return false; - - try { - com.nijiko.coelho.iConomy.iConomy.getBank().addAccount(name, balance); - } catch(Exception E) { - return false; - } - - return true; - } - - public MethodAccount getAccount(String name) { - return new iCoAccount(com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(name)); - } - - public MethodBankAccount getBankAccount(String bank, String name) { - return null; - } - - public boolean isCompatible(Plugin plugin) { - return plugin.getDescription().getName().equalsIgnoreCase("iconomy") - && plugin.getClass().getName().equals("com.nijiko.coelho.iConomy.iConomy") - && plugin instanceof iConomy; - } - - public void setPlugin(Plugin plugin) { - iConomy = (iConomy)plugin; - } - - public class iCoAccount implements MethodAccount { - private Account account; - - public iCoAccount(Account account) { - this.account = account; - } - - public Account getiCoAccount() { - return account; - } - - public double balance() { - return this.account.getBalance(); - } - - public boolean set(double amount) { - if(this.account == null) return false; - this.account.setBalance(amount); - return true; - } - - public boolean add(double amount) { - if(this.account == null) return false; - this.account.add(amount); - return true; - } - - public boolean subtract(double amount) { - if(this.account == null) return false; - this.account.subtract(amount); - return true; - } - - public boolean multiply(double amount) { - if(this.account == null) return false; - this.account.multiply(amount); - return true; - } - - public boolean divide(double amount) { - if(this.account == null) return false; - this.account.divide(amount); - return true; - } - - public boolean hasEnough(double amount) { - return this.account.hasEnough(amount); - } - - public boolean hasOver(double amount) { - return this.account.hasOver(amount); - } - - public boolean hasUnder(double amount) { - return (this.balance() < amount); - } - - public boolean isNegative() { - return this.account.isNegative(); - } - - public boolean remove() { - if(this.account == null) return false; - this.account.remove(); - return true; - } - } -} diff --git a/src/com/nijikokun/catacombsregister/payment/methods/iCo5.java b/src/com/nijikokun/catacombsregister/payment/methods/iCo5.java deleted file mode 100644 index ff3bb68..0000000 --- a/src/com/nijikokun/catacombsregister/payment/methods/iCo5.java +++ /dev/null @@ -1,243 +0,0 @@ -package com.nijikokun.catacombsregister.payment.methods; - -import com.nijikokun.catacombsregister.payment.Method; -import com.iConomy.iConomy; -import com.iConomy.system.Account; -import com.iConomy.system.BankAccount; -import com.iConomy.system.Holdings; -import com.iConomy.util.Constants; - - -import org.bukkit.plugin.Plugin; - -/** - * iConomy 5 Implementation of Method - * - * @author Nijikokun (@nijikokun) - * @copyright (c) 2011 - * @license AOL license - */ -public class iCo5 implements Method { - private iConomy iConomy; - - public iConomy getPlugin() { - return this.iConomy; - } - - public String getName() { - return "iConomy"; - } - - public String getVersion() { - return "5"; - } - - public int fractionalDigits() { - return 2; - } - - public String format(double amount) { - return com.iConomy.iConomy.format(amount); - } - - public boolean hasBanks() { - return Constants.Banking; - } - - public boolean hasBank(String bank) { - return (hasBanks()) && com.iConomy.iConomy.Banks.exists(bank); - } - - public boolean hasAccount(String name) { - return com.iConomy.iConomy.hasAccount(name); - } - - public boolean hasBankAccount(String bank, String name) { - return (hasBank(bank)) && com.iConomy.iConomy.getBank(bank).hasAccount(name); - } - - public boolean createAccount(String name) { - if(hasAccount(name)) - return false; - - return com.iConomy.iConomy.Accounts.create(name); - } - - public boolean createAccount(String name, Double balance) { - if(hasAccount(name)) - return false; - - if(!com.iConomy.iConomy.Accounts.create(name)) - return false; - - getAccount(name).set(balance); - - return true; - } - - public MethodAccount getAccount(String name) { - return new iCoAccount(com.iConomy.iConomy.getAccount(name)); - } - - public MethodBankAccount getBankAccount(String bank, String name) { - return new iCoBankAccount(com.iConomy.iConomy.getBank(bank).getAccount(name)); - } - - public boolean isCompatible(Plugin plugin) { - return plugin.getDescription().getName().equalsIgnoreCase("iconomy") - && plugin.getClass().getName().equals("com.iConomy.iConomy") - && plugin instanceof iConomy; - } - - public void setPlugin(Plugin plugin) { - iConomy = (iConomy)plugin; - } - - public class iCoAccount implements MethodAccount { - private Account account; - private Holdings holdings; - - public iCoAccount(Account account) { - this.account = account; - this.holdings = account.getHoldings(); - } - - public Account getiCoAccount() { - return account; - } - - public double balance() { - return this.holdings.balance(); - } - - public boolean set(double amount) { - if(this.holdings == null) return false; - this.holdings.set(amount); - return true; - } - - public boolean add(double amount) { - if(this.holdings == null) return false; - this.holdings.add(amount); - return true; - } - - public boolean subtract(double amount) { - if(this.holdings == null) return false; - this.holdings.subtract(amount); - return true; - } - - public boolean multiply(double amount) { - if(this.holdings == null) return false; - this.holdings.multiply(amount); - return true; - } - - public boolean divide(double amount) { - if(this.holdings == null) return false; - this.holdings.divide(amount); - return true; - } - - public boolean hasEnough(double amount) { - return this.holdings.hasEnough(amount); - } - - public boolean hasOver(double amount) { - return this.holdings.hasOver(amount); - } - - public boolean hasUnder(double amount) { - return this.holdings.hasUnder(amount); - } - - public boolean isNegative() { - return this.holdings.isNegative(); - } - - public boolean remove() { - if(this.account == null) return false; - this.account.remove(); - return true; - } - } - - public class iCoBankAccount implements MethodBankAccount { - private BankAccount account; - private Holdings holdings; - - public iCoBankAccount(BankAccount account) { - this.account = account; - this.holdings = account.getHoldings(); - } - - public BankAccount getiCoBankAccount() { - return account; - } - - public String getBankName() { - return this.account.getBankName(); - } - - public int getBankId() { - return this.account.getBankId(); - } - - public double balance() { - return this.holdings.balance(); - } - - public boolean set(double amount) { - if(this.holdings == null) return false; - this.holdings.set(amount); - return true; - } - - public boolean add(double amount) { - if(this.holdings == null) return false; - this.holdings.add(amount); - return true; - } - - public boolean subtract(double amount) { - if(this.holdings == null) return false; - this.holdings.subtract(amount); - return true; - } - - public boolean multiply(double amount) { - if(this.holdings == null) return false; - this.holdings.multiply(amount); - return true; - } - - public boolean divide(double amount) { - if(this.holdings == null) return false; - this.holdings.divide(amount); - return true; - } - - public boolean hasEnough(double amount) { - return this.holdings.hasEnough(amount); - } - - public boolean hasOver(double amount) { - return this.holdings.hasOver(amount); - } - - public boolean hasUnder(double amount) { - return this.holdings.hasUnder(amount); - } - - public boolean isNegative() { - return this.holdings.isNegative(); - } - - public boolean remove() { - if(this.account == null) return false; - this.account.remove(); - return true; - } - } -} \ No newline at end of file diff --git a/src/com/nijikokun/catacombsregister/payment/methods/iCo6.java b/src/com/nijikokun/catacombsregister/payment/methods/iCo6.java deleted file mode 100644 index cf98c4a..0000000 --- a/src/com/nijikokun/catacombsregister/payment/methods/iCo6.java +++ /dev/null @@ -1,159 +0,0 @@ -package com.nijikokun.catacombsregister.payment.methods; - -import com.nijikokun.catacombsregister.payment.Method; -import com.iCo6.iConomy; -import com.iCo6.system.Account; -import com.iCo6.system.Accounts; -import com.iCo6.system.Holdings; - - -import org.bukkit.plugin.Plugin; - -/** - * iConomy 6 Implementation of Method - * - * @author Nijikokun (@nijikokun) - * @copyright (c) 2011 - * @license AOL license - */ -public class iCo6 implements Method { - private iConomy iConomy; - - public iConomy getPlugin() { - return this.iConomy; - } - - public String getName() { - return "iConomy"; - } - - public String getVersion() { - return "6"; - } - - public int fractionalDigits() { - return 2; - } - - public String format(double amount) { - return com.iCo6.iConomy.format(amount); - } - - public boolean hasBanks() { - return false; - } - - public boolean hasBank(String bank) { - return false; - } - - public boolean hasAccount(String name) { - return (new Accounts()).exists(name); - } - - public boolean hasBankAccount(String bank, String name) { - return false; - } - - public boolean createAccount(String name) { - if(hasAccount(name)) - return false; - - return (new Accounts()).create(name); - } - - public boolean createAccount(String name, Double balance) { - if(hasAccount(name)) - return false; - - return (new Accounts()).create(name, balance); - } - - public MethodAccount getAccount(String name) { - return new iCoAccount((new Accounts()).get(name)); - } - - public MethodBankAccount getBankAccount(String bank, String name) { - return null; - } - - public boolean isCompatible(Plugin plugin) { - return plugin.getDescription().getName().equalsIgnoreCase("iconomy") - && plugin.getClass().getName().equals("com.iCo6.iConomy") - && plugin instanceof iConomy; - } - - public void setPlugin(Plugin plugin) { - iConomy = (iConomy)plugin; - } - - public class iCoAccount implements MethodAccount { - private Account account; - private Holdings holdings; - - public iCoAccount(Account account) { - this.account = account; - this.holdings = account.getHoldings(); - } - - public Account getiCoAccount() { - return account; - } - - public double balance() { - return this.holdings.getBalance(); - } - - public boolean set(double amount) { - if(this.holdings == null) return false; - this.holdings.setBalance(amount); - return true; - } - - public boolean add(double amount) { - if(this.holdings == null) return false; - this.holdings.add(amount); - return true; - } - - public boolean subtract(double amount) { - if(this.holdings == null) return false; - this.holdings.subtract(amount); - return true; - } - - public boolean multiply(double amount) { - if(this.holdings == null) return false; - this.holdings.multiply(amount); - return true; - } - - public boolean divide(double amount) { - if(this.holdings == null) return false; - this.holdings.divide(amount); - return true; - } - - public boolean hasEnough(double amount) { - return this.holdings.hasEnough(amount); - } - - public boolean hasOver(double amount) { - return this.holdings.hasOver(amount); - } - - public boolean hasUnder(double amount) { - return this.holdings.hasUnder(amount); - } - - public boolean isNegative() { - return this.holdings.isNegative(); - } - - public boolean remove() { - if(this.account == null) return false; - this.account.remove(); - return true; - } - } -} diff --git a/src/net/steeleyes/catacombs/CatEntityListener.java b/src/net/steeleyes/catacombs/CatEntityListener.java index 5e947a7..cd5fdb2 100644 --- a/src/net/steeleyes/catacombs/CatEntityListener.java +++ b/src/net/steeleyes/catacombs/CatEntityListener.java @@ -96,7 +96,7 @@ public void onEntityDeath(EntityDeathEvent evt) { Entity damager = CatUtils.getDamager(ev); if(damager instanceof Player) { double gold = plugin.cnf.Gold(); - String bal = CatUtils.giveCash(plugin.cnf,damager,gold); + String bal = plugin.giveCash(plugin.cnf,damager,gold); if(bal!=null && gold > 0) ((Player)damager).sendMessage(gold+" coins ("+bal+")"); } diff --git a/src/net/steeleyes/catacombs/CatMob.java b/src/net/steeleyes/catacombs/CatMob.java index a8e1c7f..5d4ab68 100644 --- a/src/net/steeleyes/catacombs/CatMob.java +++ b/src/net/steeleyes/catacombs/CatMob.java @@ -204,7 +204,7 @@ public void death(EntityDeathEvent evt) { // attackers to encourage team work) for(Entity attacker : hate.attackers()) { giveExp(attacker, exp); - String bal = CatUtils.giveCash(plugin.cnf,attacker, cash); + String bal = plugin.giveCash(plugin.cnf,attacker, cash); if(bal != null) { ((Player)attacker).sendMessage(cash+" coins ("+bal+") "+this); } diff --git a/src/net/steeleyes/catacombs/CatPlayerListener.java b/src/net/steeleyes/catacombs/CatPlayerListener.java index b94f0a6..0245529 100644 --- a/src/net/steeleyes/catacombs/CatPlayerListener.java +++ b/src/net/steeleyes/catacombs/CatPlayerListener.java @@ -116,7 +116,7 @@ public void onPlayerRespawn(PlayerRespawnEvent evt) { //if(!plugin.cnf.AdvancedCombat()) return; Player player = evt.getPlayer(); if(plugin.players.hasGear(player)) { - if(plugin.cnf.DeathKeepGear() && CatUtils.takeCash(player, plugin.cnf.DeathGearCost(),"to restore your equipment")) { + if(plugin.cnf.DeathKeepGear() && plugin.takeCash(player, plugin.cnf.DeathGearCost(),"to restore your equipment")) { plugin.players.restoreGear(player); } else { plugin.players.dropGear(player); diff --git a/src/net/steeleyes/catacombs/CatServerListener.java b/src/net/steeleyes/catacombs/CatServerListener.java deleted file mode 100644 index bb17f15..0000000 --- a/src/net/steeleyes/catacombs/CatServerListener.java +++ /dev/null @@ -1,79 +0,0 @@ -/* This file is part of Catacombs. - - Catacombs is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Catacombs is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Catacombs. If not, see . - * - * @author John Keay <>(@Steeleyes, @Blockhead2) - * @copyright Copyright (C) 2011 - * @license GNU GPL -*/ -package net.steeleyes.catacombs; - -import org.bukkit.event.server.PluginDisableEvent; -import org.bukkit.event.server.PluginEnableEvent; - -import com.nijikokun.catacombsregister.payment.Methods; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; - -public class CatServerListener implements Listener { - private Catacombs plugin; - private Methods Methods = null; - - public CatServerListener(Catacombs plugin) { - this.plugin = plugin; - } - - @EventHandler(priority = EventPriority.LOW) - public void onPluginDisable(PluginDisableEvent event) { - if (this.Methods != null && this.Methods.hasMethod()) { - Boolean check = this.Methods.checkDisabled(event.getPlugin()); - - if(check) { - Methods.reset(); - System.out.println("[" + plugin.info.getName() + "] Payment method was disabled. No longer accepting payments."); - } - } - } - - private String getPreferred() { - return plugin.cnf.Economy(); - } - - private boolean hasPreferred() { - return Methods.setPreferred(getPreferred()); - } - - @EventHandler(priority = EventPriority.LOW) - public void onPluginEnable(PluginEnableEvent event) { - if (!this.Methods.hasMethod()) { - if (!hasPreferred()) { - System.out.println("[" + plugin.info.getName() + "] Preferred payment method [" + getPreferred() + "] not found, using first found."); - Methods.setVersion(plugin.info.getVersion()); - Methods.setMethod(plugin.getServer().getPluginManager()); - } else { - System.out.println("[" + plugin.info.getName() + "] attempting to get preferred payment method [" + Methods.getPreferred() + "]."); - Methods.setVersion(plugin.info.getVersion()); - Methods.setMethod(plugin.getServer().getPluginManager()); - } - if (Methods.getMethod() != null) { - System.out.println("[" + plugin.info.getName() + "] Payment method found (" + Methods.getMethod().getName() + " version: " + Methods.getMethod().getVersion() + ")"); - } else { - System.out.println("[" + plugin.info.getName() + "] No payment method found"); - } - } - - //System.out.print("[" + plugin.info.getName() + "] version " + plugin.info.getVersion()+ " is enabled"); - } -} diff --git a/src/net/steeleyes/catacombs/CatUtils.java b/src/net/steeleyes/catacombs/CatUtils.java index 86b3c51..dcd2e9c 100644 --- a/src/net/steeleyes/catacombs/CatUtils.java +++ b/src/net/steeleyes/catacombs/CatUtils.java @@ -22,9 +22,6 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -import com.nijikokun.catacombsregister.payment.Method; -import com.nijikokun.catacombsregister.payment.Method.MethodAccount; -import com.nijikokun.catacombsregister.payment.Methods; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -46,6 +43,10 @@ import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.inventory.ItemStack; +import net.milkbowl.vault.economy.Economy; +import net.milkbowl.vault.economy.EconomyResponse; + + public class CatUtils { private static Random rnd = new Random(); @@ -125,43 +126,6 @@ public static List getSStringList(FileConfiguration fcnf,String path) { return (List) getSP(fcnf,path); } - public static String giveCash(CatConfig cnf,Entity ent, double gold) { - if(cnf == null || cnf.GoldOff()) - return null; - String res = null; - if (ent instanceof Player) { - Player player = (Player) ent; - Method meth = Methods.getMethod(); - if (meth != null) { - meth.getAccount(player.getName()).add(gold); - double bal = meth.getAccount(player.getName()).balance(); - res = meth.format(bal); - } - } - return res; - } - - public static Boolean takeCash(Entity ent, int gold, String reason) { - Boolean res = false; - if (ent instanceof Player) { - Player player = (Player) ent; - Method meth = Methods.getMethod(); - if (meth != null) { - MethodAccount acc = meth.getAccount(player.getName()); - if(acc.hasEnough(gold)) { - acc.subtract(gold); - double bal = acc.balance(); - player.sendMessage("It costs you "+gold+" "+reason+" ("+meth.format(bal)+")"); - res = true; - } else { - double bal = acc.balance(); - player.sendMessage("Not enough money "+reason+" ("+meth.format(bal)+")"); - } - } - } - return res; - } - // Just a simple on surface check for the moment // ToDo: count under trees and shallow overhangs as surface too public static Boolean onSurface(Block blk) { diff --git a/src/net/steeleyes/catacombs/Catacombs.java b/src/net/steeleyes/catacombs/Catacombs.java index e90ed10..e340d6d 100644 --- a/src/net/steeleyes/catacombs/Catacombs.java +++ b/src/net/steeleyes/catacombs/Catacombs.java @@ -27,11 +27,14 @@ import org.bukkit.block.Block; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; +import org.bukkit.plugin.RegisteredServiceProvider; +import org.bukkit.entity.Entity; + +import net.milkbowl.vault.economy.Economy; +import net.milkbowl.vault.economy.EconomyResponse; import net.steeleyes.maps.Direction; -import com.nijikokun.catacombsregister.payment.Method; -import com.nijikokun.catacombsregister.payment.Methods; import org.bukkit.plugin.PluginDescriptionFile; import java.util.List; @@ -411,7 +414,7 @@ public class Catacombs extends JavaPlugin { private final CatBlockListener blockListener = new CatBlockListener(this); private final CatEntityListener entityListener = new CatEntityListener(this); private final CatPlayerListener playerListener = new CatPlayerListener(this); - private final CatServerListener serverListener = new CatServerListener(this); + private Economy economy; @Override public void onLoad() { @@ -444,7 +447,6 @@ public void onEnable(){ pm.registerEvents(blockListener, this); pm.registerEvents(entityListener, this); pm.registerEvents(playerListener, this); - pm.registerEvents(serverListener, this); handler = new BlockChangeHandler(this); this.getServer().getScheduler().scheduleSyncRepeatingTask(this,handler,40,20); @@ -460,12 +462,27 @@ public void onEnable(){ dungeons.fixSecretDoors(); } enabled = true; + + if (!setupEconomy()) { + System.out.println("[" + info.getName() + "] No economy system found."); + } } } + + private boolean setupEconomy() { + if (getServer().getPluginManager().getPlugin("Vault") == null) { + return false; + } + RegisteredServiceProvider rsp = getServer().getServicesManager().getRegistration(Economy.class); + if (rsp == null) { + return false; + } + economy = rsp.getProvider(); + return economy != null; + } @Override public void onDisable(){ - Methods.reset(); enabled = false; } @@ -568,10 +585,9 @@ public Boolean Commands(Player p,String [] args) { } else if(cmd(p,args,"gold")) { if(p!=null) { String pname = p.getName(); - Method meth = Methods.getMethod(); - if(meth != null) { - double bal = meth.getAccount(pname).balance(); - inform(p,"You have "+meth.format(bal)); + if(economy != null) { + double bal = economy.getBalance(pname); + inform(p,"You have "+economy.format(bal)); } } @@ -1014,4 +1030,38 @@ private static Direction getDirection(double rot) { return null; } } + + public String giveCash(CatConfig cnf, Entity ent, double gold) { + if(cnf == null || cnf.GoldOff()) + return null; + String res = null; + if (ent instanceof Player) { + Player player = (Player) ent; + if (economy != null) { + double bal = economy.getBalance(player.getName()); + res = economy.format(bal); + } + } + return res; + } + + public Boolean takeCash(Entity ent, int gold, String reason) { + Boolean res = false; + if (ent instanceof Player) { + Player player = (Player) ent; + if (economy != null) { + if(economy.has(player.getName(), gold)) { + EconomyResponse resp = economy.withdrawPlayer(player.getName(), gold); + double bal = resp.balance; + player.sendMessage("It costs you "+gold+" "+reason+" ("+economy.format(bal)+")"); + res = true; + } else { + double bal = economy.getBalance(player.getName()); + player.sendMessage("Not enough money "+reason+" ("+economy.format(bal)+")"); + } + } + } + return res; + } + } diff --git a/src/plugin.yml b/src/plugin.yml index 23ba537..81f8275 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -2,8 +2,8 @@ name: Catacombs main: net.steeleyes.catacombs.Catacombs version: 2.1 depend: -softdepend: [iConomy, BOSEconomy, Currency, MultiCurrency, Permissions, PermissionsEx, PermissionsBukkit] +softdepend: [Permissions, PermissionsEx, PermissionsBukkit, Vault] commands: catacombs: description: Build catacombs - aliases: ['cat'] \ No newline at end of file + aliases: ['cat'] diff --git a/test/Test/CashEssentialsEco.java b/test/Test/CashEssentialsEco.java deleted file mode 100644 index cff33cc..0000000 --- a/test/Test/CashEssentialsEco.java +++ /dev/null @@ -1,50 +0,0 @@ -package Test; - -import org.bukkit.plugin.Plugin; -import com.earth2me.essentials.api.Economy; -import com.earth2me.essentials.Essentials; -import com.earth2me.essentials.api.UserDoesNotExistException; -import com.earth2me.essentials.api.NoLoanPermittedException; - -/** - * - * @author John Keay - */ -public class CashEssentialsEco implements CashIF { - private Essentials plug = null; - - public static CashIF create(Plugin p) { - CashEssentialsEco o = new CashEssentialsEco(); - o.plug = (Essentials) p; - return (CashIF) o; - } - - public String getBalance(String name) { - if(plug != null) { - double num = 0.0; - try { - num = Economy.getMoney(name); - } catch(UserDoesNotExistException ex) { - System.out.println("[Catacombs] User does not exist in Essentials Economy: " + ex.getMessage()); - } - return Economy.format(num); - } - return "0"; - } - - public void addMajor(String name, int amount) { - if(plug!=null) { - try { - Economy.add(name, amount); - } catch (UserDoesNotExistException e) { - System.out.println("[Catacombs] User does not exist in Essentials Economy: "+e.getMessage()); - } catch (NoLoanPermittedException e) { - System.out.println("[Catacombs] No loan permitted in Essentials Economy: "+e.getMessage()); - } - } - } - - public void addMinor(String name, int amount) { - - } -} diff --git a/test/Test/CashiConomy.java b/test/Test/CashiConomy.java deleted file mode 100644 index 2e548c6..0000000 --- a/test/Test/CashiConomy.java +++ /dev/null @@ -1,42 +0,0 @@ -package Test; - -import com.iConomy.iConomy; -import com.iConomy.system.Account; -import com.iConomy.system.Holdings; -import org.bukkit.plugin.Plugin; - -/** - * - * @author John Keay - */ -public class CashiConomy implements CashIF { - public iConomy iConomy = null; - - public static CashIF create(Plugin p) { - CashiConomy o = new CashiConomy(); - o.iConomy = (iConomy) p; - return (CashIF) o; - } - - public String getBalance(String name) { - if(iConomy != null) { - return iConomy.format(name); - } - return "0"; - } - - public void addMajor(String name, int amount) { - if(iConomy!=null) { - Account acc = iConomy.getAccount(name); - if(acc != null) { - Holdings balance = acc.getHoldings(); - balance.add(amount); - } - } - } - - public void addMinor(String name, int amount) { - - } - -}