mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-11-27 04:25:14 +01:00
- Added support for BOSEconomy 7
- Speeded up shop recognition - Better item durability checking - Added choice of preffered economy plugin
This commit is contained in:
parent
e27cdfb70c
commit
770b8e88cd
@ -1,31 +1,27 @@
|
|||||||
package com.Acrobot.ChestShop.Config;
|
package com.Acrobot.ChestShop.Config;
|
||||||
|
|
||||||
import com.Acrobot.ChestShop.ChestShop;
|
|
||||||
import com.Acrobot.ChestShop.Logging.Logging;
|
import com.Acrobot.ChestShop.Logging.Logging;
|
||||||
import org.bukkit.util.config.Configuration;
|
import org.bukkit.util.config.Configuration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class Config {
|
public class Config {
|
||||||
private static File configFile = new File(ChestShop.folder, "config.yml");
|
private static File configFile = new File("plugins/ChestShop", "config.yml");
|
||||||
private static File langFile = new File(ChestShop.folder, "local.yml");
|
private static File langFile = new File("plugins/ChestShop", "local.yml");
|
||||||
|
|
||||||
private static Configuration config = new Configuration(configFile);
|
private static Configuration config = new Configuration(configFile);
|
||||||
private static Configuration language = new Configuration(langFile);
|
private static Configuration language = new Configuration(langFile);
|
||||||
|
|
||||||
public static HashMap<String, Object> defaultValues = new HashMap<String, Object>();
|
|
||||||
|
|
||||||
|
|
||||||
public static void setUp() {
|
public static void setUp() {
|
||||||
config.load();
|
config.load();
|
||||||
for (Property def : com.Acrobot.ChestShop.Config.Property.values()) {
|
for (Property def : Property.values()) {
|
||||||
if (config.getProperty(def.name()) == null) {
|
if (config.getProperty(def.name()) == null) {
|
||||||
writeToFile(def.name() + ": " + def.getValue() + " #" + def.getComment(), configFile);
|
writeToFile(def.name() + ": " + def.getValue() + "\n#" + def.getComment(), configFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
config.load();
|
config.load();
|
||||||
@ -76,4 +72,9 @@ public class Config {
|
|||||||
private static Object getValue(String node) {
|
private static Object getValue(String node) {
|
||||||
return config.getProperty(node);
|
return config.getProperty(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getPreferred() {
|
||||||
|
config.load();
|
||||||
|
return getString(Property.PREFERRED_ECONOMY_PLUGIN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ package com.Acrobot.ChestShop.Config;
|
|||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public enum Property {
|
public enum Property {
|
||||||
|
PREFERRED_ECONOMY_PLUGIN("", "Preferred economy plugin (iConomy, BOSEconomy, Essentials). If you do not want to specify this, leave it blank."),
|
||||||
REVERSE_BUTTONS(false, "If true, people will buy with left-click and sell with right-click."),
|
REVERSE_BUTTONS(false, "If true, people will buy with left-click and sell with right-click."),
|
||||||
SERVER_ECONOMY_ACCOUNT("", "Economy account's name you want Admin Shops to be assigned to"),
|
SERVER_ECONOMY_ACCOUNT("", "Economy account's name you want Admin Shops to be assigned to"),
|
||||||
ADMIN_SHOP_NAME("Admin Shop", "First line of your admin shop should look like this"),
|
ADMIN_SHOP_NAME("Admin Shop", "First line of your admin shop should look like this"),
|
||||||
|
@ -20,22 +20,26 @@ public class DataValue {
|
|||||||
|
|
||||||
MaterialData materialData = null;
|
MaterialData materialData = null;
|
||||||
|
|
||||||
switch (material) {
|
try {
|
||||||
case SAPLING:
|
switch (material) {
|
||||||
case LOG:
|
case SAPLING:
|
||||||
materialData = new Tree(TreeSpecies.valueOf(arg));
|
case LOG:
|
||||||
break;
|
materialData = new Tree(TreeSpecies.valueOf(arg));
|
||||||
case STEP:
|
break;
|
||||||
case DOUBLE_STEP:
|
case STEP:
|
||||||
materialData = new Step(Items.getMat(arg));
|
case DOUBLE_STEP:
|
||||||
break;
|
materialData = new Step(Items.getMaterial(arg));
|
||||||
case WOOL:
|
break;
|
||||||
case INK_SACK:
|
case WOOL:
|
||||||
materialData = new Wool(DyeColor.valueOf(arg));
|
case INK_SACK:
|
||||||
break;
|
materialData = new Wool(DyeColor.valueOf(arg));
|
||||||
case COAL:
|
break;
|
||||||
materialData = new Coal(CoalType.valueOf(arg));
|
case COAL:
|
||||||
break;
|
materialData = new Coal(CoalType.valueOf(arg));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (materialData == null ? 0 : materialData.getData());
|
return (materialData == null ? 0 : materialData.getData());
|
||||||
|
@ -10,10 +10,9 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
*/
|
*/
|
||||||
public class Items {
|
public class Items {
|
||||||
|
|
||||||
public static Material getMat(String itemName) {
|
public static Material getMaterial(String itemName) {
|
||||||
if (uNumber.isInteger(itemName)) {
|
if (uNumber.isInteger(itemName)) return Material.getMaterial(Integer.parseInt(itemName));
|
||||||
return Material.getMaterial(Integer.parseInt(itemName));
|
|
||||||
}
|
|
||||||
int length = 256;
|
int length = 256;
|
||||||
Material finalMat = null;
|
Material finalMat = null;
|
||||||
itemName = itemName.toLowerCase().replace("_", "").replace(" ", "");
|
itemName = itemName.toLowerCase().replace("_", "").replace(" ", "");
|
||||||
@ -28,30 +27,55 @@ public class Items {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack getItemStack(String itemName) {
|
public static ItemStack getItemStack(String itemName) {
|
||||||
if (Odd.isInitialized()) {
|
ItemStack toReturn;
|
||||||
ItemStack odd = Odd.returnItemStack(itemName.replace(":", ";"));
|
if ((toReturn = getFromOddItem(itemName)) != null) {
|
||||||
if (odd != null) {
|
return toReturn;
|
||||||
return odd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String[] split = itemName.split(":");
|
|
||||||
itemName = split[0];
|
|
||||||
short dataValue = (short) (split.length > 1 && uNumber.isInteger(split[1]) ? Integer.parseInt(split[1]) : 0);
|
|
||||||
|
|
||||||
Material mat;
|
|
||||||
|
|
||||||
String[] data = itemName.split(" ");
|
|
||||||
if (data.length >= 2) {
|
|
||||||
mat = getMat(itemName.substring(itemName.indexOf(' ')));
|
|
||||||
byte argData = DataValue.get(data[0], mat);
|
|
||||||
|
|
||||||
if (argData != 0) {
|
|
||||||
dataValue = argData;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mat = getMat(itemName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (mat != null ? new ItemStack(mat, 1, dataValue) : null);
|
Material material = getMaterial(itemName);
|
||||||
|
if(material != null) return new ItemStack(material, 1);
|
||||||
|
|
||||||
|
return getItemStackWithDataValue(itemName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ItemStack getFromOddItem(String itemName) {
|
||||||
|
if (!Odd.isInitialized()) return null;
|
||||||
|
return Odd.returnItemStack(itemName.replace(":", ";"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ItemStack getItemStackWithDataValue(String itemName){
|
||||||
|
if(!itemName.contains(":")) return getItemStackWithDataValueFromWord(itemName);
|
||||||
|
|
||||||
|
String[] word = itemName.split(":");
|
||||||
|
if(word.length < 2 || !uNumber.isInteger(word[1])) return null;
|
||||||
|
|
||||||
|
Material item = getMaterial(word[0]);
|
||||||
|
if(item == null) return null;
|
||||||
|
|
||||||
|
short dataValue = Short.parseShort(word[1]);
|
||||||
|
return new ItemStack(item, 1, dataValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ItemStack getItemStackWithDataValueFromWord(String itemName) {
|
||||||
|
if (!itemName.contains(" ") || getMaterial(itemName) != null) return null;
|
||||||
|
String[] word = itemName.split(" ");
|
||||||
|
if(word.length < 2) return null;
|
||||||
|
|
||||||
|
String dataValue = word[0];
|
||||||
|
|
||||||
|
String material[] = new String[word.length - 1];
|
||||||
|
System.arraycopy(word, 1, material, 0, word.length - 1);
|
||||||
|
StringBuilder mat = new StringBuilder();
|
||||||
|
|
||||||
|
for(String s : material){
|
||||||
|
mat.append(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
Material item = getMaterial(mat.toString());
|
||||||
|
|
||||||
|
return item == null ? null : new ItemStack(item, 1, DataValue.get(dataValue, item));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.Acrobot.ChestShop.Listeners;
|
package com.Acrobot.ChestShop.Listeners;
|
||||||
|
|
||||||
import com.Acrobot.ChestShop.ChestShop;
|
import com.Acrobot.ChestShop.ChestShop;
|
||||||
|
import com.Acrobot.ChestShop.Config.Config;
|
||||||
import com.Acrobot.ChestShop.Economy;
|
import com.Acrobot.ChestShop.Economy;
|
||||||
import com.Acrobot.ChestShop.Items.Odd;
|
import com.Acrobot.ChestShop.Items.Odd;
|
||||||
import com.Acrobot.ChestShop.Permission;
|
import com.Acrobot.ChestShop.Permission;
|
||||||
@ -22,7 +23,7 @@ import org.yi.acru.bukkit.Lockette.Lockette;
|
|||||||
*/
|
*/
|
||||||
public class pluginEnable extends ServerListener {
|
public class pluginEnable extends ServerListener {
|
||||||
|
|
||||||
public static Methods methods = new Methods();
|
public static Methods methods = new Methods(Config.getPreferred());
|
||||||
|
|
||||||
|
|
||||||
public void onPluginEnable(PluginEnableEvent event) {
|
public void onPluginEnable(PluginEnableEvent event) {
|
||||||
|
@ -2,17 +2,27 @@ package com.Acrobot.ChestShop.Utils;
|
|||||||
|
|
||||||
import com.Acrobot.ChestShop.Config.Config;
|
import com.Acrobot.ChestShop.Config.Config;
|
||||||
import com.Acrobot.ChestShop.Config.Property;
|
import com.Acrobot.ChestShop.Config.Property;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class uSign {
|
public class uSign {
|
||||||
|
|
||||||
|
//static Pattern firstLine = Pattern.compile("^[A-Za-z0-9].+$");
|
||||||
|
|
||||||
|
static Pattern[] patterns = {
|
||||||
|
Pattern.compile("^$|^\\w.+$"),
|
||||||
|
Pattern.compile("[0-9]+"),
|
||||||
|
Pattern.compile(".+"),
|
||||||
|
Pattern.compile("[\\w :]+")
|
||||||
|
};
|
||||||
|
|
||||||
public static boolean isSign(Block block) {
|
public static boolean isSign(Block block) {
|
||||||
return (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN);
|
return block.getState() instanceof Sign;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAdminShop(String owner) {
|
public static boolean isAdminShop(String owner) {
|
||||||
@ -31,10 +41,14 @@ public class uSign {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isValidPreparedSign(String[] line) {
|
public static boolean isValidPreparedSign(String[] lines){
|
||||||
try {
|
try{
|
||||||
return !line[0].startsWith("[") && !line[0].endsWith("]") && !line[0].startsWith(":") && !line[3].split(":")[0].isEmpty() && uNumber.isInteger(line[1]) && line[2].split(":").length <= 2;
|
boolean toReturn = true;
|
||||||
} catch (Exception e) {
|
for(int i = 0; i < 4; i++){
|
||||||
|
toReturn = toReturn && patterns[i].matcher(lines[i]).matches();
|
||||||
|
}
|
||||||
|
return toReturn;
|
||||||
|
} catch (Exception e){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package com.nijikokun.register.payment.forChestShop;
|
package com.nijikokun.register.payment.forChestShop;
|
||||||
|
|
||||||
|
import com.nijikokun.register.payment.forChestShop.methods.BOSE6;
|
||||||
|
import com.nijikokun.register.payment.forChestShop.methods.BOSE7;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.plugin.PluginManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Methods.java
|
* Methods.java
|
||||||
* Controls the getting / setting of methods & the method of payment used.
|
* Controls the getting / setting of methods & the method of payment used.
|
||||||
@ -29,7 +31,7 @@ public class Methods {
|
|||||||
/**
|
/**
|
||||||
* Allows you to set which economy plugin is most preferred.
|
* Allows you to set which economy plugin is most preferred.
|
||||||
*
|
*
|
||||||
* @param preferred
|
* @param preferred - preferred economy plugin
|
||||||
*/
|
*/
|
||||||
public Methods(String preferred) {
|
public Methods(String preferred) {
|
||||||
this._init();
|
this._init();
|
||||||
@ -42,7 +44,8 @@ public class Methods {
|
|||||||
private void _init() {
|
private void _init() {
|
||||||
this.addMethod("iConomy", new com.nijikokun.register.payment.forChestShop.methods.iCo4());
|
this.addMethod("iConomy", new com.nijikokun.register.payment.forChestShop.methods.iCo4());
|
||||||
this.addMethod("iConomy", new com.nijikokun.register.payment.forChestShop.methods.iCo5());
|
this.addMethod("iConomy", new com.nijikokun.register.payment.forChestShop.methods.iCo5());
|
||||||
this.addMethod("BOSEconomy", new com.nijikokun.register.payment.forChestShop.methods.BOSE());
|
this.addMethod("BOSEconomy", new BOSE6());
|
||||||
|
this.addMethod("BOSEconomy", new BOSE7());
|
||||||
this.addMethod("Essentials", new com.nijikokun.register.payment.forChestShop.methods.EE17());
|
this.addMethod("Essentials", new com.nijikokun.register.payment.forChestShop.methods.EE17());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +79,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()) {
|
||||||
|
@ -4,7 +4,7 @@ import com.nijikokun.register.payment.forChestShop.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) {
|
188
com/nijikokun/register/payment/forChestShop/methods/BOSE7.java
Normal file
188
com/nijikokun/register/payment/forChestShop/methods/BOSE7.java
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
package com.nijikokun.register.payment.forChestShop.methods;
|
||||||
|
|
||||||
|
import com.nijikokun.register.payment.forChestShop.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,7 @@ name: ChestShop
|
|||||||
main: com.Acrobot.ChestShop.ChestShop
|
main: com.Acrobot.ChestShop.ChestShop
|
||||||
|
|
||||||
database: true
|
database: true
|
||||||
version: 3.00 BETA 8
|
version: 3.00 BETA 9
|
||||||
|
|
||||||
|
|
||||||
author: Acrobot
|
author: Acrobot
|
||||||
|
Loading…
Reference in New Issue
Block a user