- Added option to tax all transactions
- Updated Register and BukkitEx - Can't place shops in the wilderness - Fixed CraftBukkit's piston bug - no more try/catch
This commit is contained in:
parent
4440101a3a
commit
9a6b9d0c38
|
@ -1,6 +1,6 @@
|
||||||
package com.Acrobot.ChestShop.Config;
|
package com.Acrobot.ChestShop.Config;
|
||||||
|
|
||||||
import com.nijikokun.register.payment.forChestShop.Methods;
|
import com.nijikokun.register.forChestShop.payment.Methods;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
|
|
|
@ -25,7 +25,8 @@ public enum Property {
|
||||||
SHOW_MESSAGE_OUT_OF_STOCK(true, "Do you want to show \"Out of stock\" messages?"),
|
SHOW_MESSAGE_OUT_OF_STOCK(true, "Do you want to show \"Out of stock\" messages?"),
|
||||||
SHOW_TRANSACTION_INFORMATION_CLIENT(true, "Do you want to show \"You bought/sold... \" messages?"),
|
SHOW_TRANSACTION_INFORMATION_CLIENT(true, "Do you want to show \"You bought/sold... \" messages?"),
|
||||||
SHOW_TRANSACTION_INFORMATION_OWNER(true, "Do you want to show \"Somebody bought/sold... \" messages?"),
|
SHOW_TRANSACTION_INFORMATION_OWNER(true, "Do you want to show \"Somebody bought/sold... \" messages?"),
|
||||||
TOWNY_INTEGRATION(false, "Do you want to only let people build inside shop plots?");
|
TOWNY_INTEGRATION(false, "Do you want to only let people build inside shop plots?"),
|
||||||
|
TAX_AMOUNT(0, "Percent of the price that should go to the server's account. (100 = 100 percent)");
|
||||||
|
|
||||||
|
|
||||||
private final Object value;
|
private final Object value;
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package com.Acrobot.ChestShop;
|
package com.Acrobot.ChestShop;
|
||||||
|
|
||||||
|
import com.Acrobot.ChestShop.Config.Config;
|
||||||
|
import com.Acrobot.ChestShop.Config.Property;
|
||||||
import com.Acrobot.ChestShop.Utils.uLongName;
|
import com.Acrobot.ChestShop.Utils.uLongName;
|
||||||
import com.nijikokun.register.payment.forChestShop.Method;
|
import com.nijikokun.register.forChestShop.payment.Method;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
|
@ -15,6 +17,11 @@ public class Economy {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void add(String name, float amount) {
|
public static void add(String name, float amount) {
|
||||||
|
if (Config.getFloat(Property.TAX_AMOUNT) != 0F && !Config.getString(Property.SERVER_ECONOMY_ACCOUNT).isEmpty()) {
|
||||||
|
float tax = (Config.getFloat(Property.TAX_AMOUNT) / 100F) * amount;
|
||||||
|
economy.getAccount(Config.getString(Property.SERVER_ECONOMY_ACCOUNT)).add(tax);
|
||||||
|
amount = amount - tax;
|
||||||
|
}
|
||||||
economy.getAccount(uLongName.getName(name)).add(amount);
|
economy.getAccount(uLongName.getName(name)).add(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,14 @@ import com.Acrobot.ChestShop.Utils.uBlock;
|
||||||
import com.Acrobot.ChestShop.Utils.uLongName;
|
import com.Acrobot.ChestShop.Utils.uLongName;
|
||||||
import com.Acrobot.ChestShop.Utils.uSign;
|
import com.Acrobot.ChestShop.Utils.uSign;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockListener;
|
import org.bukkit.event.block.BlockListener;
|
||||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||||
|
import org.bukkit.material.PistonBaseMaterial;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
|
@ -57,6 +59,17 @@ public class blockBreak extends BlockListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Block getRetractBlock(BlockPistonRetractEvent event) {
|
private static Block getRetractBlock(BlockPistonRetractEvent event) {
|
||||||
return (!uSign.isSign(event.getRetractLocation().getBlock()) ? event.getRetractLocation().getBlock() : null);
|
Block block = getRetractLocationBlock(event);
|
||||||
|
return (block != null && !uSign.isSign(block) ? block : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Those are fixes for CraftBukkit's piston bug, where piston appears not to be a piston.
|
||||||
|
private static BlockFace getPistonDirection(Block block) {
|
||||||
|
return block.getState().getData() instanceof PistonBaseMaterial ? ((PistonBaseMaterial) block.getState().getData()).getFacing() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Block getRetractLocationBlock(BlockPistonRetractEvent event) {
|
||||||
|
BlockFace pistonDirection = getPistonDirection(event.getBlock());
|
||||||
|
return pistonDirection != null ? event.getBlock().getRelative((pistonDirection), 2).getLocation().getBlock() : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,11 +71,8 @@ public class playerInteract extends PlayerListener {
|
||||||
|
|
||||||
Action buy = (Config.getBoolean(Property.REVERSE_BUTTONS) ? Action.LEFT_CLICK_BLOCK : Action.RIGHT_CLICK_BLOCK);
|
Action buy = (Config.getBoolean(Property.REVERSE_BUTTONS) ? Action.LEFT_CLICK_BLOCK : Action.RIGHT_CLICK_BLOCK);
|
||||||
|
|
||||||
if (action == buy) {
|
if (action == buy) ShopManagement.buy(sign, player);
|
||||||
ShopManagement.buy(sign, player);
|
else ShopManagement.sell(sign, player);
|
||||||
} else {
|
|
||||||
ShopManagement.sell(sign, player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean enoughTimeHasPassed(Player player) {
|
private static boolean enoughTimeHasPassed(Player player) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.Acrobot.ChestShop.Listeners;
|
package com.Acrobot.ChestShop.Listeners;
|
||||||
|
|
||||||
import com.Acrobot.ChestShop.Economy;
|
import com.Acrobot.ChestShop.Economy;
|
||||||
import com.nijikokun.register.payment.forChestShop.Methods;
|
import com.nijikokun.register.forChestShop.payment.Methods;
|
||||||
import org.bukkit.event.server.PluginDisableEvent;
|
import org.bukkit.event.server.PluginDisableEvent;
|
||||||
import org.bukkit.event.server.ServerListener;
|
import org.bukkit.event.server.ServerListener;
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import com.Acrobot.ChestShop.Utils.uSign;
|
||||||
import com.daemitus.deadbolt.Deadbolt;
|
import com.daemitus.deadbolt.Deadbolt;
|
||||||
import com.griefcraft.lwc.LWCPlugin;
|
import com.griefcraft.lwc.LWCPlugin;
|
||||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||||
import com.nijikokun.register.payment.forChestShop.Methods;
|
import com.nijikokun.register.forChestShop.payment.Methods;
|
||||||
import com.palmergames.bukkit.towny.Towny;
|
import com.palmergames.bukkit.towny.Towny;
|
||||||
import org.bukkit.event.server.PluginEnableEvent;
|
import org.bukkit.event.server.PluginEnableEvent;
|
||||||
import org.bukkit.event.server.ServerListener;
|
import org.bukkit.event.server.ServerListener;
|
||||||
|
@ -72,7 +72,7 @@ public class pluginEnable extends ServerListener {
|
||||||
System.out.println(ChestShop.chatPrefix + description.getName() + " version " + description.getVersion() + " loaded.");
|
System.out.println(ChestShop.chatPrefix + description.getName() + " version " + description.getVersion() + " loaded.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String generateOutdatedVersion(String pluginName, String curVersion, String neededVersion){
|
private static String generateOutdatedVersion(String pluginName, String curVersion, String neededVersion) {
|
||||||
return (new StringBuilder(7).append(ChestShop.chatPrefix).append("Your ").append(pluginName).append(" is outdated! Need version AT LEAST ").append(neededVersion).append(" - Your version is ").append(curVersion).toString());
|
return (new StringBuilder(7).append(ChestShop.chatPrefix).append("Your ").append(pluginName).append(" is outdated! Need version AT LEAST ").append(neededVersion).append(" - Your version is ").append(curVersion).toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,13 @@ public class uTowny {
|
||||||
return isBlockOwner(player, chestLocation) && isBlockOwner(player, signLocation);
|
return isBlockOwner(player, chestLocation) && isBlockOwner(player, signLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isNotInTheWilderness(Location chestLocation, Location signLocation) {
|
||||||
|
return !uSign.towny.getTownyUniverse().isWilderness(chestLocation.getBlock()) && !uSign.towny.getTownyUniverse().isWilderness(signLocation.getBlock());
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean canBuild(Player player, Location chestLocation, Location signLocation) {
|
public static boolean canBuild(Player player, Location chestLocation, Location signLocation) {
|
||||||
return !Config.getBoolean(Property.TOWNY_INTEGRATION) || (isInsideShopPlot(chestLocation, signLocation) && isPlotOwner(player, chestLocation, signLocation));
|
System.out.println(isNotInTheWilderness(chestLocation, signLocation));
|
||||||
|
return uSign.towny == null || !Config.getBoolean(Property.TOWNY_INTEGRATION) || (isNotInTheWilderness(chestLocation, signLocation) && isInsideShopPlot(chestLocation, signLocation) && isPlotOwner(player, chestLocation, signLocation));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isBlockOwner(Player player, Location location) {
|
private static boolean isBlockOwner(Player player, Location location) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public abstract class Database {
|
public abstract class Database {
|
||||||
private final JavaPlugin javaPlugin;
|
private JavaPlugin javaPlugin;
|
||||||
private ClassLoader classLoader;
|
private ClassLoader classLoader;
|
||||||
private Level loggerLevel;
|
private Level loggerLevel;
|
||||||
private boolean usingSQLite;
|
private boolean usingSQLite;
|
||||||
|
@ -31,7 +31,7 @@ public abstract class Database {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an instance of Database
|
* Create an instance of Database
|
||||||
*
|
*
|
||||||
* @param javaPlugin Plugin instancing this database
|
* @param javaPlugin Plugin instancing this database
|
||||||
*/
|
*/
|
||||||
public Database(JavaPlugin javaPlugin) {
|
public Database(JavaPlugin javaPlugin) {
|
||||||
|
@ -45,8 +45,9 @@ public abstract class Database {
|
||||||
method.setAccessible(true);
|
method.setAccessible(true);
|
||||||
|
|
||||||
//Store the ClassLoader
|
//Store the ClassLoader
|
||||||
this.classLoader = (ClassLoader) method.invoke(javaPlugin);
|
this.classLoader = (ClassLoader)method.invoke(javaPlugin);
|
||||||
} catch (Exception ex) {
|
}
|
||||||
|
catch(Exception ex ) {
|
||||||
throw new RuntimeException("Failed to retrieve the ClassLoader of the plugin using Reflection", ex);
|
throw new RuntimeException("Failed to retrieve the ClassLoader of the plugin using Reflection", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,15 +55,15 @@ public abstract class Database {
|
||||||
/**
|
/**
|
||||||
* Initialize the database using the passed arguments
|
* Initialize the database using the passed arguments
|
||||||
*
|
*
|
||||||
* @param driver Database-driver to use. For example: org.sqlite.JDBC
|
* @param driver Database-driver to use. For example: org.sqlite.JDBC
|
||||||
* @param url Location of the database. For example: jdbc:sqlite:{DIR}{NAME}.db
|
* @param url Location of the database. For example: jdbc:sqlite:{DIR}{NAME}.db
|
||||||
* @param username Username required to access the database
|
* @param username Username required to access the database
|
||||||
* @param password Password belonging to the username, may be empty
|
* @param password Password belonging to the username, may be empty
|
||||||
* @param isolation Isolation type. For example: SERIALIZABLE, also see TransactionIsolation
|
* @param isolation Isolation type. For example: SERIALIZABLE, also see TransactionIsolation
|
||||||
*/
|
*/
|
||||||
public void initializeDatabase(String driver, String url, String username, String password, String isolation) {
|
public void initializeDatabase(String driver, String url, String username, String password, String isolation) {
|
||||||
//Logging needs to be set back to the original level, no matter what happens
|
//Logging needs to be set back to the original level, no matter what happens
|
||||||
try {
|
try {
|
||||||
//Disable all logging
|
//Disable all logging
|
||||||
disableDatabaseLogging(false);
|
disableDatabaseLogging(false);
|
||||||
|
|
||||||
|
@ -73,16 +74,18 @@ public abstract class Database {
|
||||||
loadDatabase();
|
loadDatabase();
|
||||||
|
|
||||||
//Create all tables
|
//Create all tables
|
||||||
installDatabase(true);
|
installDatabase(false);
|
||||||
} catch (Exception ex) {
|
}
|
||||||
|
catch(Exception ex) {
|
||||||
throw new RuntimeException("An exception has occured while initializing the database", ex);
|
throw new RuntimeException("An exception has occured while initializing the database", ex);
|
||||||
} finally {
|
}
|
||||||
|
finally {
|
||||||
//Enable all logging
|
//Enable all logging
|
||||||
enableDatabaseLogging(false);
|
enableDatabaseLogging(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareDatabase(String driver, String url, String username, String password, String isolation) {
|
private void prepareDatabase(String driver, String url, String username, String password, String isolation) {
|
||||||
//Setup the data source
|
//Setup the data source
|
||||||
DataSourceConfig ds = new DataSourceConfig();
|
DataSourceConfig ds = new DataSourceConfig();
|
||||||
ds.setDriver(driver);
|
ds.setDriver(driver);
|
||||||
|
@ -101,7 +104,10 @@ public abstract class Database {
|
||||||
List<Class<?>> classes = getDatabaseClasses();
|
List<Class<?>> classes = getDatabaseClasses();
|
||||||
|
|
||||||
//Do a sanity check first
|
//Do a sanity check first
|
||||||
if (classes.isEmpty()) throw new RuntimeException("Database has been enabled, but no classes are registered to it");
|
if(classes.isEmpty()) {
|
||||||
|
//Exception: There is no use in continuing to load this database
|
||||||
|
throw new RuntimeException("Database has been enabled, but no classes are registered to it");
|
||||||
|
}
|
||||||
|
|
||||||
//Register them with the EbeanServer
|
//Register them with the EbeanServer
|
||||||
sc.setClasses(classes);
|
sc.setClasses(classes);
|
||||||
|
@ -116,6 +122,8 @@ public abstract class Database {
|
||||||
sc.getDatabasePlatform().getDbDdlSyntax().setIdentity("");
|
sc.getDatabasePlatform().getDbDdlSyntax().setIdentity("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prepareDatabaseAdditionalConfig(ds, sc);
|
||||||
|
|
||||||
//Finally the data source
|
//Finally the data source
|
||||||
sc.setDataSourceConfig(ds);
|
sc.setDataSourceConfig(ds);
|
||||||
|
|
||||||
|
@ -146,33 +154,34 @@ public abstract class Database {
|
||||||
|
|
||||||
//Setup Ebean based on the configuration
|
//Setup Ebean based on the configuration
|
||||||
ebeanServer = EbeanServerFactory.create(serverConfig);
|
ebeanServer = EbeanServerFactory.create(serverConfig);
|
||||||
} catch (Exception ex) {
|
}
|
||||||
|
catch(Exception ex) {
|
||||||
throw new RuntimeException("Failed to create a new instance of the EbeanServer", ex);
|
throw new RuntimeException("Failed to create a new instance of the EbeanServer", ex);
|
||||||
} finally {
|
}
|
||||||
|
finally {
|
||||||
//Revert the ClassLoader back to its original value
|
//Revert the ClassLoader back to its original value
|
||||||
if (currentClassLoader != null) Thread.currentThread().setContextClassLoader(currentClassLoader);
|
if(currentClassLoader != null) {
|
||||||
|
Thread.currentThread().setContextClassLoader(currentClassLoader);
|
||||||
|
}
|
||||||
|
|
||||||
//Revert the "defaultUseCaches"-field in URLConnection back to its original value
|
//Revert the "defaultUseCaches"-field in URLConnection back to its original value
|
||||||
try {
|
try {
|
||||||
if (cacheField != null) cacheField.setBoolean(null, cacheValue);
|
if(cacheField != null) {
|
||||||
} catch (Exception e) {
|
cacheField.setBoolean(null, cacheValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
System.out.println("Failed to revert the \"defaultUseCaches\"-field back to its original value, URLConnection-caching remains disabled.");
|
System.out.println("Failed to revert the \"defaultUseCaches\"-field back to its original value, URLConnection-caching remains disabled.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void installDatabase(boolean rebuild) {
|
private void installDatabase(boolean rebuild) {
|
||||||
//Check if the database has to be rebuild
|
//Check if the database already (partially) exists
|
||||||
if (!rebuild) return;
|
|
||||||
|
|
||||||
//Create a DDL generator
|
|
||||||
SpiEbeanServer serv = (SpiEbeanServer) ebeanServer;
|
|
||||||
DdlGenerator gen = serv.getDdlGenerator();
|
|
||||||
|
|
||||||
//Check if the database already (partially) exists
|
|
||||||
boolean databaseExists = false;
|
boolean databaseExists = false;
|
||||||
|
|
||||||
for (Class<?> aClass : getDatabaseClasses()) {
|
List<Class<?>> classes = getDatabaseClasses();
|
||||||
|
for (Class<?> aClass : classes) {
|
||||||
try {
|
try {
|
||||||
//Do a simple query which only throws an exception if the table does not exist
|
//Do a simple query which only throws an exception if the table does not exist
|
||||||
ebeanServer.find(aClass).findRowCount();
|
ebeanServer.find(aClass).findRowCount();
|
||||||
|
@ -180,33 +189,53 @@ public abstract class Database {
|
||||||
//Query passed without throwing an exception, a database therefore already exists
|
//Query passed without throwing an exception, a database therefore already exists
|
||||||
databaseExists = true;
|
databaseExists = true;
|
||||||
break;
|
break;
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ex) {
|
||||||
|
//Do nothing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(databaseExists) return;
|
//Check if the database has to be created or rebuilt
|
||||||
|
if(!rebuild && databaseExists) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Fire "before drop" event
|
//Create a DDL generator
|
||||||
|
SpiEbeanServer serv = (SpiEbeanServer) ebeanServer;
|
||||||
|
DdlGenerator gen = serv.getDdlGenerator();
|
||||||
|
|
||||||
|
//Fire "before drop" event
|
||||||
try {
|
try {
|
||||||
beforeDropDatabase();
|
beforeDropDatabase();
|
||||||
} catch (Exception ex) {
|
}
|
||||||
|
catch(Exception ex) {
|
||||||
//If the database exists, dropping has to be canceled to prevent data-loss
|
//If the database exists, dropping has to be canceled to prevent data-loss
|
||||||
if (databaseExists) throw new RuntimeException("An unexpected exception occured", ex);
|
if(databaseExists) {
|
||||||
|
throw new RuntimeException("An unexpected exception occured", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Generate a DropDDL-script
|
//Generate a DropDDL-script
|
||||||
gen.runScript(true, gen.generateDropDdl());
|
gen.runScript(true, gen.generateDropDdl());
|
||||||
|
|
||||||
//If SQLite is being used, the database has to reloaded to release all resources
|
//If SQLite is being used, the database has to reloaded to release all resources
|
||||||
if (usingSQLite) loadDatabase();
|
if(usingSQLite) {
|
||||||
|
loadDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
//Generate a CreateDDL-script
|
//Generate a CreateDDL-script
|
||||||
//If SQLite is being used, the CreateDLL-script has to be validated and potentially fixed to be valid
|
if(usingSQLite) {
|
||||||
gen.runScript(false, (usingSQLite ? validateCreateDDLSqlite(gen.generateCreateDdl()) : gen.generateCreateDdl()));
|
//If SQLite is being used, the CreateDLL-script has to be validated and potentially fixed to be valid
|
||||||
|
gen.runScript(false, validateCreateDDLSqlite(gen.generateCreateDdl()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
gen.runScript(false, gen.generateCreateDdl());
|
||||||
|
}
|
||||||
|
|
||||||
//Fire "after create" event
|
//Fire "after create" event
|
||||||
try {
|
try {
|
||||||
afterCreateDatabase();
|
afterCreateDatabase();
|
||||||
} catch (Exception ex) {
|
}
|
||||||
|
catch(Exception ex) {
|
||||||
throw new RuntimeException("An unexpected exception occured", ex);
|
throw new RuntimeException("An unexpected exception occured", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -241,11 +270,12 @@ public abstract class Database {
|
||||||
scriptLines.add(currentLine.trim());
|
scriptLines.add(currentLine.trim());
|
||||||
|
|
||||||
//Check if the current line is of any use
|
//Check if the current line is of any use
|
||||||
if (currentLine.startsWith("create table")) {
|
if(currentLine.startsWith("create table")) {
|
||||||
//Found a table, so get its name and remember the line it has been encountered on
|
//Found a table, so get its name and remember the line it has been encountered on
|
||||||
currentTable = currentLine.split(" ", 4)[2];
|
currentTable = currentLine.split(" ", 4)[2];
|
||||||
foundTables.put(currentLine.split(" ", 3)[2], scriptLines.size() - 1);
|
foundTables.put(currentLine.split(" ", 3)[2], scriptLines.size() - 1);
|
||||||
} else if (currentLine.length() > 0 && currentLine.charAt(0) == ';' && currentTable != null && !currentTable.isEmpty()) {
|
}
|
||||||
|
else if(currentLine.length() > 0 && currentLine.charAt(0) == ';' && currentTable != null && !currentTable.isEmpty()) {
|
||||||
//Found the end of a table definition, so update the entry
|
//Found the end of a table definition, so update the entry
|
||||||
int index = scriptLines.size() - 1;
|
int index = scriptLines.size() - 1;
|
||||||
foundTables.put(currentTable, index);
|
foundTables.put(currentTable, index);
|
||||||
|
@ -260,16 +290,17 @@ public abstract class Database {
|
||||||
|
|
||||||
//Reset the table-tracker
|
//Reset the table-tracker
|
||||||
currentTable = null;
|
currentTable = null;
|
||||||
} else if (currentLine.startsWith("alter table")) {
|
}
|
||||||
|
else if(currentLine.startsWith("alter table")) {
|
||||||
//Found a potentially unsupported action
|
//Found a potentially unsupported action
|
||||||
String[] alterTableLine = currentLine.split(" ", 4);
|
String[] alterTableLine = currentLine.split(" ", 4);
|
||||||
|
|
||||||
if (alterTableLine[3].startsWith("add constraint")) {
|
if(alterTableLine[3].startsWith("add constraint")) {
|
||||||
//Found an unsupported action: ALTER TABLE using ADD CONSTRAINT
|
//Found an unsupported action: ALTER TABLE using ADD CONSTRAINT
|
||||||
String[] addConstraintLine = alterTableLine[3].split(" ", 4);
|
String[] addConstraintLine = alterTableLine[3].split(" ", 4);
|
||||||
|
|
||||||
//Check if this line can be fixed somehow
|
//Check if this line can be fixed somehow
|
||||||
if (addConstraintLine[3].startsWith("foreign key")) {
|
if(addConstraintLine[3].startsWith("foreign key")) {
|
||||||
//Calculate the index of last line of the current table
|
//Calculate the index of last line of the current table
|
||||||
int tableLastLine = foundTables.get(alterTableLine[2]) + tableOffset;
|
int tableLastLine = foundTables.get(alterTableLine[2]) + tableOffset;
|
||||||
|
|
||||||
|
@ -283,7 +314,8 @@ public abstract class Database {
|
||||||
//Remove this line and raise the table offset because a line has been inserted
|
//Remove this line and raise the table offset because a line has been inserted
|
||||||
scriptLines.remove(scriptLines.size() - 1);
|
scriptLines.remove(scriptLines.size() - 1);
|
||||||
tableOffset++;
|
tableOffset++;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
//Exception: This line cannot be fixed but is known the be unsupported by SQLite
|
//Exception: This line cannot be fixed but is known the be unsupported by SQLite
|
||||||
throw new RuntimeException("Unsupported action encountered: ALTER TABLE using ADD CONSTRAINT with " + addConstraintLine[3]);
|
throw new RuntimeException("Unsupported action encountered: ALTER TABLE using ADD CONSTRAINT with " + addConstraintLine[3]);
|
||||||
}
|
}
|
||||||
|
@ -293,14 +325,15 @@ public abstract class Database {
|
||||||
|
|
||||||
//Turn all the lines back into a single string
|
//Turn all the lines back into a single string
|
||||||
StringBuilder newScript = new StringBuilder(5);
|
StringBuilder newScript = new StringBuilder(5);
|
||||||
for (String newLine : scriptLines) newScript.append(newLine).append('\n');
|
for(String newLine : scriptLines) newScript.append(newLine).append('\n');
|
||||||
|
|
||||||
//Print the new script
|
//Print the new script
|
||||||
System.out.println(newScript);
|
System.out.println(newScript);
|
||||||
|
|
||||||
//Return the fixed script
|
//Return the fixed script
|
||||||
return newScript.toString();
|
return newScript.toString();
|
||||||
} catch (Exception ex) {
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
//Exception: Failed to fix the DDL or something just went plain wrong
|
//Exception: Failed to fix the DDL or something just went plain wrong
|
||||||
throw new RuntimeException("Failed to validate the CreateDDL-script for SQLite", ex);
|
throw new RuntimeException("Failed to validate the CreateDDL-script for SQLite", ex);
|
||||||
}
|
}
|
||||||
|
@ -308,7 +341,9 @@ public abstract class Database {
|
||||||
|
|
||||||
private void disableDatabaseLogging(boolean logging) {
|
private void disableDatabaseLogging(boolean logging) {
|
||||||
//If logging is allowed, nothing has to be changed
|
//If logging is allowed, nothing has to be changed
|
||||||
if (logging) return;
|
if(logging) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Retrieve the level of the root logger
|
//Retrieve the level of the root logger
|
||||||
loggerLevel = Logger.getLogger("").getLevel();
|
loggerLevel = Logger.getLogger("").getLevel();
|
||||||
|
@ -319,7 +354,9 @@ public abstract class Database {
|
||||||
|
|
||||||
private void enableDatabaseLogging(boolean logging) {
|
private void enableDatabaseLogging(boolean logging) {
|
||||||
//If logging is allowed, nothing has to be changed
|
//If logging is allowed, nothing has to be changed
|
||||||
if (logging) return;
|
if(logging) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Set the level of the root logger back to the original value
|
//Set the level of the root logger back to the original value
|
||||||
Logger.getLogger("").setLevel(loggerLevel);
|
Logger.getLogger("").setLevel(loggerLevel);
|
||||||
|
@ -327,7 +364,7 @@ public abstract class Database {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of classes which should be registered with the EbeanServer
|
* Get a list of classes which should be registered with the EbeanServer
|
||||||
*
|
*
|
||||||
* @return List List of classes which should be registered with the EbeanServer
|
* @return List List of classes which should be registered with the EbeanServer
|
||||||
*/
|
*/
|
||||||
protected List<Class<?>> getDatabaseClasses() {
|
protected List<Class<?>> getDatabaseClasses() {
|
||||||
|
@ -337,18 +374,24 @@ public abstract class Database {
|
||||||
/**
|
/**
|
||||||
* Method called before the loaded database is being dropped
|
* Method called before the loaded database is being dropped
|
||||||
*/
|
*/
|
||||||
protected void beforeDropDatabase() {
|
protected void beforeDropDatabase() {}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method called after the loaded database has been created
|
* Method called after the loaded database has been created
|
||||||
*/
|
*/
|
||||||
protected void afterCreateDatabase() {
|
protected void afterCreateDatabase() {}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* Method called near the end of prepareDatabase, before the dataSourceConfig is attached to the serverConfig.
|
||||||
|
*
|
||||||
|
* @param dataSourceConfig
|
||||||
|
* @param serverConfig
|
||||||
|
*/
|
||||||
|
protected void prepareDatabaseAdditionalConfig(DataSourceConfig dataSourceConfig, ServerConfig serverConfig) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the instance of the EbeanServer
|
* Get the instance of the EbeanServer
|
||||||
*
|
*
|
||||||
* @return EbeanServer Instance of the EbeanServer
|
* @return EbeanServer Instance of the EbeanServer
|
||||||
*/
|
*/
|
||||||
public EbeanServer getDatabase() {
|
public EbeanServer getDatabase() {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.nijikokun.register.payment.forChestShop;
|
package com.nijikokun.register.forChestShop.payment;
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
@ -14,11 +14,11 @@ public interface Method {
|
||||||
* Encodes the Plugin into an Object disguised as the Plugin.
|
* Encodes the Plugin into an Object disguised as the Plugin.
|
||||||
* If you want the original Plugin Class you must cast it to the correct
|
* 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.
|
* Plugin, to do so you have to verify the name and or version then cast.
|
||||||
* <p/>
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* if(method.getName().equalsIgnoreCase("iConomy"))
|
* if(method.getName().equalsIgnoreCase("iConomy"))
|
||||||
* iConomy plugin = ((iConomy)method.getPlugin());</pre>
|
* iConomy plugin = ((iConomy)method.getPlugin());</pre>
|
||||||
*
|
*
|
||||||
* @return <code>Object</code>
|
* @return <code>Object</code>
|
||||||
* @see #getName()
|
* @see #getName()
|
||||||
* @see #getVersion()
|
* @see #getVersion()
|
||||||
|
@ -38,11 +38,11 @@ public interface Method {
|
||||||
* @return <code>String</code> Plugin version.
|
* @return <code>String</code> Plugin version.
|
||||||
*/
|
*/
|
||||||
public String getVersion();
|
public String getVersion();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the amount of decimal places that get stored
|
* Returns the amount of decimal places that get stored
|
||||||
* NOTE: it will return -1 if there is no rounding
|
* NOTE: it will return -1 if there is no rounding
|
||||||
*
|
*
|
||||||
* @return <code>int</code> for each decimal place
|
* @return <code>int</code> for each decimal place
|
||||||
*/
|
*/
|
||||||
public int fractionalDigits();
|
public int fractionalDigits();
|
||||||
|
@ -88,6 +88,23 @@ public interface Method {
|
||||||
*/
|
*/
|
||||||
public boolean hasBankAccount(String bank, String name);
|
public boolean hasBankAccount(String bank, String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forces an account creation
|
||||||
|
*
|
||||||
|
* @param name Account name
|
||||||
|
* @return <code>boolean</code>
|
||||||
|
*/
|
||||||
|
public boolean createAccount(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forces an account creation
|
||||||
|
*
|
||||||
|
* @param name Account name
|
||||||
|
* @param balance Initial account balance
|
||||||
|
* @return <code>boolean</code>
|
||||||
|
*/
|
||||||
|
public boolean createAccount(String name, Double balance);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a <code>MethodAccount</code> class for an account <code>name</code>.
|
* Returns a <code>MethodAccount</code> class for an account <code>name</code>.
|
||||||
*
|
*
|
||||||
|
@ -127,25 +144,15 @@ public interface Method {
|
||||||
*/
|
*/
|
||||||
public interface MethodAccount {
|
public interface MethodAccount {
|
||||||
public double balance();
|
public double balance();
|
||||||
|
|
||||||
public boolean set(double amount);
|
public boolean set(double amount);
|
||||||
|
|
||||||
public boolean add(double amount);
|
public boolean add(double amount);
|
||||||
|
|
||||||
public boolean subtract(double amount);
|
public boolean subtract(double amount);
|
||||||
|
|
||||||
public boolean multiply(double amount);
|
public boolean multiply(double amount);
|
||||||
|
|
||||||
public boolean divide(double amount);
|
public boolean divide(double amount);
|
||||||
|
|
||||||
public boolean hasEnough(double amount);
|
public boolean hasEnough(double amount);
|
||||||
|
|
||||||
public boolean hasOver(double amount);
|
public boolean hasOver(double amount);
|
||||||
|
|
||||||
public boolean hasUnder(double amount);
|
public boolean hasUnder(double amount);
|
||||||
|
|
||||||
public boolean isNegative();
|
public boolean isNegative();
|
||||||
|
|
||||||
public boolean remove();
|
public boolean remove();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -157,29 +164,17 @@ public interface Method {
|
||||||
*/
|
*/
|
||||||
public interface MethodBankAccount {
|
public interface MethodBankAccount {
|
||||||
public double balance();
|
public double balance();
|
||||||
|
|
||||||
public String getBankName();
|
public String getBankName();
|
||||||
|
|
||||||
public int getBankId();
|
public int getBankId();
|
||||||
|
|
||||||
public boolean set(double amount);
|
public boolean set(double amount);
|
||||||
|
|
||||||
public boolean add(double amount);
|
public boolean add(double amount);
|
||||||
|
|
||||||
public boolean subtract(double amount);
|
public boolean subtract(double amount);
|
||||||
|
|
||||||
public boolean multiply(double amount);
|
public boolean multiply(double amount);
|
||||||
|
|
||||||
public boolean divide(double amount);
|
public boolean divide(double amount);
|
||||||
|
|
||||||
public boolean hasEnough(double amount);
|
public boolean hasEnough(double amount);
|
||||||
|
|
||||||
public boolean hasOver(double amount);
|
public boolean hasOver(double amount);
|
||||||
|
|
||||||
public boolean hasUnder(double amount);
|
public boolean hasUnder(double amount);
|
||||||
|
|
||||||
public boolean isNegative();
|
public boolean isNegative();
|
||||||
|
|
||||||
public boolean remove();
|
public boolean remove();
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -1,20 +1,20 @@
|
||||||
package com.nijikokun.register.payment.forChestShop;
|
package com.nijikokun.register.forChestShop.payment;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The <code>Methods</code> initializes Methods that utilize the Method interface
|
* The <code>Methods</code> initializes Methods that utilize the Method interface
|
||||||
* based on a "first come, first served" basis.
|
* based on a "first come, first served" basis.
|
||||||
* <p/>
|
*
|
||||||
* Allowing you to check whether a payment method exists or not.
|
* Allowing you to check whether a payment method exists or not.
|
||||||
* <p/>
|
*
|
||||||
* Methods also allows you to set a preferred method of payment before it captures
|
* Methods also allows you to set a preferred method of payment before it captures
|
||||||
* payment plugins in the initialization process.
|
* payment plugins in the initialization process.
|
||||||
* <p/>
|
*
|
||||||
* in <code>bukkit.yml</code>:
|
* in <code>bukkit.yml</code>:
|
||||||
* <blockquote><pre>
|
* <blockquote><pre>
|
||||||
* economy:
|
* economy:
|
||||||
|
@ -29,7 +29,7 @@ public class Methods {
|
||||||
private static String version = null;
|
private static String version = null;
|
||||||
private static boolean self = false;
|
private static boolean self = false;
|
||||||
private static Method Method = null;
|
private static Method Method = null;
|
||||||
public static String preferred = "";
|
private static String preferred = "";
|
||||||
private static Set<Method> Methods = new HashSet<Method>();
|
private static Set<Method> Methods = new HashSet<Method>();
|
||||||
private static Set<String> Dependencies = new HashSet<String>();
|
private static Set<String> Dependencies = new HashSet<String>();
|
||||||
private static Set<Method> Attachables = new HashSet<Method>();
|
private static Set<Method> Attachables = new HashSet<Method>();
|
||||||
|
@ -42,13 +42,13 @@ public class Methods {
|
||||||
* Implement all methods along with their respective name & class.
|
* Implement all methods along with their respective name & class.
|
||||||
*/
|
*/
|
||||||
private static void _init() {
|
private static void _init() {
|
||||||
addMethod("iConomy", new com.nijikokun.register.payment.forChestShop.methods.iCo6());
|
addMethod("iConomy", new com.nijikokun.register.forChestShop.payment.methods.iCo6());
|
||||||
addMethod("iConomy", new com.nijikokun.register.payment.forChestShop.methods.iCo5());
|
addMethod("iConomy", new com.nijikokun.register.forChestShop.payment.methods.iCo5());
|
||||||
addMethod("iConomy", new com.nijikokun.register.payment.forChestShop.methods.iCo4());
|
addMethod("iConomy", new com.nijikokun.register.forChestShop.payment.methods.iCo4());
|
||||||
addMethod("BOSEconomy", new com.nijikokun.register.payment.forChestShop.methods.BOSE6());
|
addMethod("BOSEconomy", new com.nijikokun.register.forChestShop.payment.methods.BOSE6());
|
||||||
addMethod("BOSEconomy", new com.nijikokun.register.payment.forChestShop.methods.BOSE7());
|
addMethod("BOSEconomy", new com.nijikokun.register.forChestShop.payment.methods.BOSE7());
|
||||||
addMethod("Essentials", new com.nijikokun.register.payment.forChestShop.methods.EE17());
|
addMethod("Essentials", new com.nijikokun.register.forChestShop.payment.methods.EE17());
|
||||||
addMethod("Currency", new com.nijikokun.register.payment.forChestShop.methods.MCUR());
|
addMethod("Currency", new com.nijikokun.register.forChestShop.payment.methods.MCUR());
|
||||||
Dependencies.add("MultiCurrency");
|
Dependencies.add("MultiCurrency");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,6 @@ public class Methods {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use to get version of Register plugin
|
* Use to get version of Register plugin
|
||||||
*
|
|
||||||
* @return version
|
* @return version
|
||||||
*/
|
*/
|
||||||
public static String getVersion() {
|
public static String getVersion() {
|
||||||
|
@ -86,6 +85,7 @@ public class Methods {
|
||||||
* through the <code>_init</code> method.
|
* through the <code>_init</code> method.
|
||||||
*
|
*
|
||||||
* @return <code>Set<String></code> - Array of payment methods that are loaded.
|
* @return <code>Set<String></code> - Array of payment methods that are loaded.
|
||||||
|
* @see #setMethod(org.bukkit.plugin.Plugin)
|
||||||
*/
|
*/
|
||||||
public static Set<String> getDependencies() {
|
public static Set<String> getDependencies() {
|
||||||
return Dependencies;
|
return Dependencies;
|
||||||
|
@ -99,7 +99,7 @@ public class Methods {
|
||||||
* @return Method <em>or</em> Null
|
* @return Method <em>or</em> Null
|
||||||
*/
|
*/
|
||||||
public static Method createMethod(Plugin plugin) {
|
public static Method createMethod(Plugin plugin) {
|
||||||
for (Method method : Methods)
|
for (Method method: Methods)
|
||||||
if (method.isCompatible(plugin)) {
|
if (method.isCompatible(plugin)) {
|
||||||
method.setPlugin(plugin);
|
method.setPlugin(plugin);
|
||||||
return method;
|
return method;
|
||||||
|
@ -117,6 +117,7 @@ public class Methods {
|
||||||
* Verifies if Register has set a payment method for usage yet.
|
* Verifies if Register has set a payment method for usage yet.
|
||||||
*
|
*
|
||||||
* @return <code>boolean</code>
|
* @return <code>boolean</code>
|
||||||
|
* @see #setMethod(org.bukkit.plugin.Plugin)
|
||||||
* @see #checkDisabled(org.bukkit.plugin.Plugin)
|
* @see #checkDisabled(org.bukkit.plugin.Plugin)
|
||||||
*/
|
*/
|
||||||
public static boolean hasMethod() {
|
public static boolean hasMethod() {
|
||||||
|
@ -127,6 +128,7 @@ public class Methods {
|
||||||
* Checks Plugin Class against a multitude of checks to verify it's usability
|
* Checks Plugin Class against a multitude of checks to verify it's usability
|
||||||
* as a payment method.
|
* as a payment method.
|
||||||
*
|
*
|
||||||
|
* @param <code>PluginManager</code> the plugin manager for the server
|
||||||
* @return <code>boolean</code> True on success, False on failure.
|
* @return <code>boolean</code> True on success, False on failure.
|
||||||
*/
|
*/
|
||||||
public static boolean setMethod(PluginManager manager) {
|
public static boolean setMethod(PluginManager manager) {
|
||||||
|
@ -140,14 +142,14 @@ public class Methods {
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
boolean match = false;
|
boolean match = false;
|
||||||
Plugin plugin;
|
Plugin plugin = null;
|
||||||
|
|
||||||
for (String name : Dependencies) {
|
for (String name : getDependencies()) {
|
||||||
if (hasMethod())
|
if (hasMethod())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
plugin = manager.getPlugin(name);
|
plugin = manager.getPlugin(name);
|
||||||
if (plugin == null)
|
if (plugin == null || !plugin.isEnabled())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Method current = createMethod(plugin);
|
Method current = createMethod(plugin);
|
||||||
|
@ -170,8 +172,7 @@ public class Methods {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (hasMethod()) {
|
if (hasMethod()) {
|
||||||
match = true;
|
match = true; break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preferred.isEmpty())
|
if (preferred.isEmpty())
|
||||||
|
@ -181,8 +182,8 @@ public class Methods {
|
||||||
if (preferred.equalsIgnoreCase(attached.getName()))
|
if (preferred.equalsIgnoreCase(attached.getName()))
|
||||||
Method = attached;
|
Method = attached;
|
||||||
|
|
||||||
else
|
else
|
||||||
Method = attached;
|
Method = attached;
|
||||||
}
|
}
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
|
@ -199,7 +200,7 @@ public class Methods {
|
||||||
* @return <code>boolean</code>
|
* @return <code>boolean</code>
|
||||||
*/
|
*/
|
||||||
public static boolean setPreferred(String check) {
|
public static boolean setPreferred(String check) {
|
||||||
if (Dependencies.contains(check)) {
|
if (getDependencies().contains(check)) {
|
||||||
preferred = check;
|
preferred = check;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -224,7 +225,7 @@ public class Methods {
|
||||||
* @return <code>boolean</code>
|
* @return <code>boolean</code>
|
||||||
*/
|
*/
|
||||||
public static boolean checkDisabled(Plugin method) {
|
public static boolean checkDisabled(Plugin method) {
|
||||||
if (!hasMethod())
|
if(!hasMethod())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (Method.isCompatible(method))
|
if (Method.isCompatible(method))
|
|
@ -1,6 +1,7 @@
|
||||||
package com.nijikokun.register.payment.forChestShop.methods;
|
package com.nijikokun.register.forChestShop.payment.methods;
|
||||||
|
|
||||||
|
import com.nijikokun.register.forChestShop.payment.Method;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
@ -26,15 +27,15 @@ public class BOSE6 implements Method {
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return "0.6.2";
|
return "0.6.2";
|
||||||
}
|
}
|
||||||
|
|
||||||
public int fractionalDigits() {
|
public int fractionalDigits() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String format(double amount) {
|
public String format(double amount) {
|
||||||
String currency = this.BOSEconomy.getMoneyNamePlural();
|
String currency = this.BOSEconomy.getMoneyNamePlural();
|
||||||
|
|
||||||
if (amount == 1)
|
if(amount == 1)
|
||||||
currency = this.BOSEconomy.getMoneyName();
|
currency = this.BOSEconomy.getMoneyName();
|
||||||
|
|
||||||
return amount + " " + currency;
|
return amount + " " + currency;
|
||||||
|
@ -54,34 +55,51 @@ public class BOSE6 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);
|
|| 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) {
|
public MethodAccount getAccount(String name) {
|
||||||
if (!hasAccount(name))
|
if(!hasAccount(name))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return new BOSEAccount(name, this.BOSEconomy);
|
return new BOSEAccount(name, this.BOSEconomy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||||
if (!hasBankAccount(bank, name))
|
if(!hasBankAccount(bank, name))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return new BOSEBankAccount(bank, BOSEconomy);
|
return new BOSEBankAccount(bank, BOSEconomy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCompatible(Plugin plugin) {
|
public boolean isCompatible(Plugin plugin) {
|
||||||
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy")
|
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy")
|
||||||
&& plugin instanceof BOSEconomy
|
&& plugin instanceof BOSEconomy
|
||||||
&& plugin.getDescription().getVersion().equals("0.6.2");
|
&& plugin.getDescription().getVersion().equals("0.6.2");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlugin(Plugin plugin) {
|
public void setPlugin(Plugin plugin) {
|
||||||
BOSEconomy = (BOSEconomy) plugin;
|
BOSEconomy = (BOSEconomy) plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class BOSEAccount implements MethodAccount {
|
public class BOSEAccount implements MethodAccount {
|
||||||
private final String name;
|
private final String name;
|
||||||
private final BOSEconomy BOSEconomy;
|
private final BOSEconomy BOSEconomy;
|
||||||
|
|
||||||
|
@ -95,30 +113,30 @@ public class BOSE6 implements Method {
|
||||||
}
|
}
|
||||||
|
|
||||||
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.setPlayerMoney(this.name, IntAmount, false);
|
return this.BOSEconomy.setPlayerMoney(this.name, IntAmount, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean add(double amount) {
|
public boolean add(double amount) {
|
||||||
int IntAmount = (int) Math.ceil(amount);
|
int IntAmount = (int)Math.ceil(amount);
|
||||||
return this.BOSEconomy.addPlayerMoney(this.name, IntAmount, false);
|
return this.BOSEconomy.addPlayerMoney(this.name, 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.setPlayerMoney(this.name, (balance - IntAmount), false);
|
return this.BOSEconomy.setPlayerMoney(this.name, (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.setPlayerMoney(this.name, (balance * IntAmount), false);
|
return this.BOSEconomy.setPlayerMoney(this.name, (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.setPlayerMoney(this.name, (balance / IntAmount), false);
|
return this.BOSEconomy.setPlayerMoney(this.name, (balance / IntAmount), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +161,7 @@ public class BOSE6 implements Method {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class BOSEBankAccount implements MethodBankAccount {
|
public class BOSEBankAccount implements MethodBankAccount {
|
||||||
private final String bank;
|
private final String bank;
|
||||||
private final BOSEconomy BOSEconomy;
|
private final BOSEconomy BOSEconomy;
|
||||||
|
|
||||||
|
@ -165,31 +183,31 @@ public class BOSE6 implements Method {
|
||||||
}
|
}
|
||||||
|
|
||||||
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(bank, 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(bank, (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(bank, (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(bank, (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(bank, (balance / IntAmount), false);
|
return this.BOSEconomy.setBankMoney(bank, (balance / IntAmount), false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.nijikokun.register.payment.forChestShop.methods;
|
package com.nijikokun.register.forChestShop.payment.methods;
|
||||||
|
|
||||||
|
import com.nijikokun.register.forChestShop.payment.Method;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
@ -26,15 +27,15 @@ public class BOSE7 implements Method {
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return "0.7.0";
|
return "0.7.0";
|
||||||
}
|
}
|
||||||
|
|
||||||
public int fractionalDigits() {
|
public int fractionalDigits() {
|
||||||
return this.BOSEconomy.getFractionalDigits();
|
return this.BOSEconomy.getFractionalDigits();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String format(double amount) {
|
public String format(double amount) {
|
||||||
String currency = this.BOSEconomy.getMoneyNamePlural();
|
String currency = this.BOSEconomy.getMoneyNamePlural();
|
||||||
|
|
||||||
if (amount == 1)
|
if(amount == 1)
|
||||||
currency = this.BOSEconomy.getMoneyName();
|
currency = this.BOSEconomy.getMoneyName();
|
||||||
|
|
||||||
return amount + " " + currency;
|
return amount + " " + currency;
|
||||||
|
@ -56,31 +57,48 @@ public class BOSE7 implements Method {
|
||||||
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, 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) {
|
public MethodAccount getAccount(String name) {
|
||||||
if (!hasAccount(name))
|
if(!hasAccount(name))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return new BOSEAccount(name, this.BOSEconomy);
|
return new BOSEAccount(name, this.BOSEconomy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||||
if (!hasBankAccount(bank, name))
|
if(!hasBankAccount(bank, name))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return new BOSEBankAccount(bank, BOSEconomy);
|
return new BOSEBankAccount(bank, BOSEconomy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCompatible(Plugin plugin) {
|
public boolean isCompatible(Plugin plugin) {
|
||||||
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy")
|
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy")
|
||||||
&& plugin instanceof BOSEconomy
|
&& plugin instanceof BOSEconomy
|
||||||
&& !plugin.getDescription().getVersion().equals("0.6.2");
|
&& !plugin.getDescription().getVersion().equals("0.6.2");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlugin(Plugin plugin) {
|
public void setPlugin(Plugin plugin) {
|
||||||
BOSEconomy = (BOSEconomy) plugin;
|
BOSEconomy = (BOSEconomy)plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class BOSEAccount implements MethodAccount {
|
public class BOSEAccount implements MethodAccount {
|
||||||
private String name;
|
private String name;
|
||||||
private BOSEconomy BOSEconomy;
|
private BOSEconomy BOSEconomy;
|
||||||
|
|
||||||
|
@ -137,7 +155,7 @@ public class BOSE7 implements Method {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class BOSEBankAccount implements MethodBankAccount {
|
public class BOSEBankAccount implements MethodBankAccount {
|
||||||
private String bank;
|
private String bank;
|
||||||
private BOSEconomy BOSEconomy;
|
private BOSEconomy BOSEconomy;
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
package com.nijikokun.register.payment.forChestShop.methods;
|
package com.nijikokun.register.forChestShop.payment.methods;
|
||||||
|
|
||||||
|
import com.nijikokun.register.forChestShop.payment.Method;
|
||||||
import com.earth2me.essentials.Essentials;
|
import com.earth2me.essentials.Essentials;
|
||||||
import com.earth2me.essentials.api.Economy;
|
import com.earth2me.essentials.api.Economy;
|
||||||
import com.earth2me.essentials.api.NoLoanPermittedException;
|
|
||||||
import com.earth2me.essentials.api.UserDoesNotExistException;
|
|
||||||
import com.nijikokun.register.payment.forChestShop.Method;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,9 +30,9 @@ public class EE17 implements Method {
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return "2.2";
|
return "2.2";
|
||||||
}
|
}
|
||||||
|
|
||||||
public int fractionalDigits() {
|
public int fractionalDigits() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String format(double amount) {
|
public String format(double amount) {
|
||||||
|
@ -56,8 +55,32 @@ public class EE17 implements Method {
|
||||||
return false;
|
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) {
|
public MethodAccount getAccount(String name) {
|
||||||
if (!hasAccount(name))
|
if(!hasAccount(name))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return new EEcoAccount(name);
|
return new EEcoAccount(name);
|
||||||
|
@ -66,19 +89,20 @@ public class EE17 implements Method {
|
||||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCompatible(Plugin plugin) {
|
public boolean isCompatible(Plugin plugin) {
|
||||||
try { Class.forName("com.earth2me.essentials.api.Economy"); } catch (Exception e) { return false; }
|
try { Class.forName("com.earth2me.essentials.api.Economy"); }
|
||||||
|
catch(Exception e) { return false; }
|
||||||
|
|
||||||
return plugin.getDescription().getName().equalsIgnoreCase("essentials")
|
return plugin.getDescription().getName().equalsIgnoreCase("essentials")
|
||||||
&& plugin instanceof Essentials;
|
&& plugin instanceof Essentials;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlugin(Plugin plugin) {
|
public void setPlugin(Plugin plugin) {
|
||||||
Essentials = (Essentials) plugin;
|
Essentials = (Essentials)plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class EEcoAccount implements MethodAccount {
|
public class EEcoAccount implements MethodAccount {
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public EEcoAccount(String name) {
|
public EEcoAccount(String name) {
|
||||||
|
@ -90,8 +114,8 @@ public class EE17 implements Method {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
balance = Economy.getMoney(this.name);
|
balance = Economy.getMoney(this.name);
|
||||||
} catch (UserDoesNotExistException ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("[REGISTER] Failed to grab balance in Essentials Economy: " + ex.getMessage());
|
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return balance;
|
return balance;
|
||||||
|
@ -100,11 +124,8 @@ public class EE17 implements Method {
|
||||||
public boolean set(double amount) {
|
public boolean set(double amount) {
|
||||||
try {
|
try {
|
||||||
Economy.setMoney(name, amount);
|
Economy.setMoney(name, amount);
|
||||||
} catch (UserDoesNotExistException ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
|
||||||
return false;
|
|
||||||
} catch (NoLoanPermittedException ex) {
|
|
||||||
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,11 +135,8 @@ public class EE17 implements Method {
|
||||||
public boolean add(double amount) {
|
public boolean add(double amount) {
|
||||||
try {
|
try {
|
||||||
Economy.add(name, amount);
|
Economy.add(name, amount);
|
||||||
} catch (UserDoesNotExistException ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
|
||||||
return false;
|
|
||||||
} catch (NoLoanPermittedException ex) {
|
|
||||||
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,11 +146,8 @@ public class EE17 implements Method {
|
||||||
public boolean subtract(double amount) {
|
public boolean subtract(double amount) {
|
||||||
try {
|
try {
|
||||||
Economy.subtract(name, amount);
|
Economy.subtract(name, amount);
|
||||||
} catch (UserDoesNotExistException ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
|
||||||
return false;
|
|
||||||
} catch (NoLoanPermittedException ex) {
|
|
||||||
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,11 +157,8 @@ public class EE17 implements Method {
|
||||||
public boolean multiply(double amount) {
|
public boolean multiply(double amount) {
|
||||||
try {
|
try {
|
||||||
Economy.multiply(name, amount);
|
Economy.multiply(name, amount);
|
||||||
} catch (UserDoesNotExistException ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
|
||||||
return false;
|
|
||||||
} catch (NoLoanPermittedException ex) {
|
|
||||||
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,11 +168,8 @@ public class EE17 implements Method {
|
||||||
public boolean divide(double amount) {
|
public boolean divide(double amount) {
|
||||||
try {
|
try {
|
||||||
Economy.divide(name, amount);
|
Economy.divide(name, amount);
|
||||||
} catch (UserDoesNotExistException ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
|
||||||
return false;
|
|
||||||
} catch (NoLoanPermittedException ex) {
|
|
||||||
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,8 +179,8 @@ public class EE17 implements Method {
|
||||||
public boolean hasEnough(double amount) {
|
public boolean hasEnough(double amount) {
|
||||||
try {
|
try {
|
||||||
return Economy.hasEnough(name, amount);
|
return Economy.hasEnough(name, amount);
|
||||||
} catch (UserDoesNotExistException ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -180,8 +189,8 @@ public class EE17 implements Method {
|
||||||
public boolean hasOver(double amount) {
|
public boolean hasOver(double amount) {
|
||||||
try {
|
try {
|
||||||
return Economy.hasMore(name, amount);
|
return Economy.hasMore(name, amount);
|
||||||
} catch (UserDoesNotExistException ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -190,8 +199,8 @@ public class EE17 implements Method {
|
||||||
public boolean hasUnder(double amount) {
|
public boolean hasUnder(double amount) {
|
||||||
try {
|
try {
|
||||||
return Economy.hasLess(name, amount);
|
return Economy.hasLess(name, amount);
|
||||||
} catch (UserDoesNotExistException ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -200,8 +209,8 @@ public class EE17 implements Method {
|
||||||
public boolean isNegative() {
|
public boolean isNegative() {
|
||||||
try {
|
try {
|
||||||
return Economy.isNegative(name);
|
return Economy.isNegative(name);
|
||||||
} catch (UserDoesNotExistException ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
|
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
|
@ -1,8 +1,10 @@
|
||||||
package com.nijikokun.register.payment.forChestShop.methods;
|
package com.nijikokun.register.forChestShop.payment.methods;
|
||||||
|
|
||||||
|
import com.nijikokun.register.forChestShop.payment.Method;
|
||||||
|
|
||||||
import com.nijikokun.register.payment.forChestShop.Method;
|
|
||||||
import me.ashtheking.currency.Currency;
|
import me.ashtheking.currency.Currency;
|
||||||
import me.ashtheking.currency.CurrencyList;
|
import me.ashtheking.currency.CurrencyList;
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,9 +28,9 @@ public class MCUR implements Method {
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return "0.09";
|
return "0.09";
|
||||||
}
|
}
|
||||||
|
|
||||||
public int fractionalDigits() {
|
public int fractionalDigits() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String format(double amount) {
|
public String format(double amount) {
|
||||||
|
@ -51,6 +53,16 @@ public class MCUR implements Method {
|
||||||
return false;
|
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) {
|
public MethodAccount getAccount(String name) {
|
||||||
return new MCurrencyAccount(name);
|
return new MCurrencyAccount(name);
|
||||||
}
|
}
|
||||||
|
@ -61,15 +73,15 @@ public class MCUR implements Method {
|
||||||
|
|
||||||
public boolean isCompatible(Plugin plugin) {
|
public boolean isCompatible(Plugin plugin) {
|
||||||
return (plugin.getDescription().getName().equalsIgnoreCase("Currency")
|
return (plugin.getDescription().getName().equalsIgnoreCase("Currency")
|
||||||
|| plugin.getDescription().getName().equalsIgnoreCase("MultiCurrency"))
|
|| plugin.getDescription().getName().equalsIgnoreCase("MultiCurrency"))
|
||||||
&& plugin instanceof Currency;
|
&& plugin instanceof Currency;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlugin(Plugin plugin) {
|
public void setPlugin(Plugin plugin) {
|
||||||
currencyList = (Currency) plugin;
|
currencyList = (Currency) plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MCurrencyAccount implements MethodAccount {
|
public class MCurrencyAccount implements MethodAccount{
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public MCurrencyAccount(String name) {
|
public MCurrencyAccount(String name) {
|
|
@ -1,8 +1,10 @@
|
||||||
package com.nijikokun.register.payment.forChestShop.methods;
|
package com.nijikokun.register.forChestShop.payment.methods;
|
||||||
|
|
||||||
|
import com.nijikokun.register.forChestShop.payment.Method;
|
||||||
import com.nijiko.coelho.iConomy.iConomy;
|
import com.nijiko.coelho.iConomy.iConomy;
|
||||||
import com.nijiko.coelho.iConomy.system.Account;
|
import com.nijiko.coelho.iConomy.system.Account;
|
||||||
import com.nijikokun.register.payment.forChestShop.Method;
|
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,9 +28,9 @@ public class iCo4 implements Method {
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return "4";
|
return "4";
|
||||||
}
|
}
|
||||||
|
|
||||||
public int fractionalDigits() {
|
public int fractionalDigits() {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String format(double amount) {
|
public String format(double amount) {
|
||||||
|
@ -51,6 +53,32 @@ public class iCo4 implements Method {
|
||||||
return false;
|
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) {
|
public MethodAccount getAccount(String name) {
|
||||||
return new iCoAccount(com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(name));
|
return new iCoAccount(com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(name));
|
||||||
}
|
}
|
||||||
|
@ -58,18 +86,18 @@ public class iCo4 implements Method {
|
||||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCompatible(Plugin plugin) {
|
public boolean isCompatible(Plugin plugin) {
|
||||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
|
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
|
||||||
&& plugin.getClass().getName().equals("com.nijiko.coelho.iConomy.iConomy")
|
&& plugin.getClass().getName().equals("com.nijiko.coelho.iConomy.iConomy")
|
||||||
&& plugin instanceof iConomy;
|
&& plugin instanceof iConomy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlugin(Plugin plugin) {
|
public void setPlugin(Plugin plugin) {
|
||||||
iConomy = (iConomy) plugin;
|
iConomy = (iConomy)plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class iCoAccount implements MethodAccount {
|
public class iCoAccount implements MethodAccount {
|
||||||
private Account account;
|
private Account account;
|
||||||
|
|
||||||
public iCoAccount(Account account) {
|
public iCoAccount(Account account) {
|
||||||
|
@ -85,31 +113,31 @@ public class iCo4 implements Method {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean set(double amount) {
|
public boolean set(double amount) {
|
||||||
if (this.account == null) return false;
|
if(this.account == null) return false;
|
||||||
this.account.setBalance(amount);
|
this.account.setBalance(amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean add(double amount) {
|
public boolean add(double amount) {
|
||||||
if (this.account == null) return false;
|
if(this.account == null) return false;
|
||||||
this.account.add(amount);
|
this.account.add(amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean subtract(double amount) {
|
public boolean subtract(double amount) {
|
||||||
if (this.account == null) return false;
|
if(this.account == null) return false;
|
||||||
this.account.subtract(amount);
|
this.account.subtract(amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean multiply(double amount) {
|
public boolean multiply(double amount) {
|
||||||
if (this.account == null) return false;
|
if(this.account == null) return false;
|
||||||
this.account.multiply(amount);
|
this.account.multiply(amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean divide(double amount) {
|
public boolean divide(double amount) {
|
||||||
if (this.account == null) return false;
|
if(this.account == null) return false;
|
||||||
this.account.divide(amount);
|
this.account.divide(amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -131,7 +159,7 @@ public class iCo4 implements Method {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean remove() {
|
public boolean remove() {
|
||||||
if (this.account == null) return false;
|
if(this.account == null) return false;
|
||||||
this.account.remove();
|
this.account.remove();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
|
@ -1,11 +1,13 @@
|
||||||
package com.nijikokun.register.payment.forChestShop.methods;
|
package com.nijikokun.register.forChestShop.payment.methods;
|
||||||
|
|
||||||
|
import com.nijikokun.register.forChestShop.payment.Method;
|
||||||
import com.iConomy.iConomy;
|
import com.iConomy.iConomy;
|
||||||
import com.iConomy.system.Account;
|
import com.iConomy.system.Account;
|
||||||
import com.iConomy.system.BankAccount;
|
import com.iConomy.system.BankAccount;
|
||||||
import com.iConomy.system.Holdings;
|
import com.iConomy.system.Holdings;
|
||||||
import com.iConomy.util.Constants;
|
import com.iConomy.util.Constants;
|
||||||
import com.nijikokun.register.payment.forChestShop.Method;
|
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,9 +31,9 @@ public class iCo5 implements Method {
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return "5";
|
return "5";
|
||||||
}
|
}
|
||||||
|
|
||||||
public int fractionalDigits() {
|
public int fractionalDigits() {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String format(double amount) {
|
public String format(double amount) {
|
||||||
|
@ -54,6 +56,25 @@ public class iCo5 implements Method {
|
||||||
return (hasBank(bank)) && com.iConomy.iConomy.getBank(bank).hasAccount(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) {
|
public MethodAccount getAccount(String name) {
|
||||||
return new iCoAccount(com.iConomy.iConomy.getAccount(name));
|
return new iCoAccount(com.iConomy.iConomy.getAccount(name));
|
||||||
}
|
}
|
||||||
|
@ -63,16 +84,16 @@ public class iCo5 implements Method {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCompatible(Plugin plugin) {
|
public boolean isCompatible(Plugin plugin) {
|
||||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
|
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
|
||||||
&& plugin.getClass().getName().equals("com.iConomy.iConomy")
|
&& plugin.getClass().getName().equals("com.iConomy.iConomy")
|
||||||
&& plugin instanceof iConomy;
|
&& plugin instanceof iConomy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlugin(Plugin plugin) {
|
public void setPlugin(Plugin plugin) {
|
||||||
iConomy = (iConomy) plugin;
|
iConomy = (iConomy)plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class iCoAccount implements MethodAccount {
|
public class iCoAccount implements MethodAccount {
|
||||||
private Account account;
|
private Account account;
|
||||||
private Holdings holdings;
|
private Holdings holdings;
|
||||||
|
|
||||||
|
@ -90,31 +111,31 @@ public class iCo5 implements Method {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean set(double amount) {
|
public boolean set(double amount) {
|
||||||
if (this.holdings == null) return false;
|
if(this.holdings == null) return false;
|
||||||
this.holdings.set(amount);
|
this.holdings.set(amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean add(double amount) {
|
public boolean add(double amount) {
|
||||||
if (this.holdings == null) return false;
|
if(this.holdings == null) return false;
|
||||||
this.holdings.add(amount);
|
this.holdings.add(amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean subtract(double amount) {
|
public boolean subtract(double amount) {
|
||||||
if (this.holdings == null) return false;
|
if(this.holdings == null) return false;
|
||||||
this.holdings.subtract(amount);
|
this.holdings.subtract(amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean multiply(double amount) {
|
public boolean multiply(double amount) {
|
||||||
if (this.holdings == null) return false;
|
if(this.holdings == null) return false;
|
||||||
this.holdings.multiply(amount);
|
this.holdings.multiply(amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean divide(double amount) {
|
public boolean divide(double amount) {
|
||||||
if (this.holdings == null) return false;
|
if(this.holdings == null) return false;
|
||||||
this.holdings.divide(amount);
|
this.holdings.divide(amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -136,13 +157,13 @@ public class iCo5 implements Method {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean remove() {
|
public boolean remove() {
|
||||||
if (this.account == null) return false;
|
if(this.account == null) return false;
|
||||||
this.account.remove();
|
this.account.remove();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class iCoBankAccount implements MethodBankAccount {
|
public class iCoBankAccount implements MethodBankAccount {
|
||||||
private BankAccount account;
|
private BankAccount account;
|
||||||
private Holdings holdings;
|
private Holdings holdings;
|
||||||
|
|
||||||
|
@ -168,31 +189,31 @@ public class iCo5 implements Method {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean set(double amount) {
|
public boolean set(double amount) {
|
||||||
if (this.holdings == null) return false;
|
if(this.holdings == null) return false;
|
||||||
this.holdings.set(amount);
|
this.holdings.set(amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean add(double amount) {
|
public boolean add(double amount) {
|
||||||
if (this.holdings == null) return false;
|
if(this.holdings == null) return false;
|
||||||
this.holdings.add(amount);
|
this.holdings.add(amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean subtract(double amount) {
|
public boolean subtract(double amount) {
|
||||||
if (this.holdings == null) return false;
|
if(this.holdings == null) return false;
|
||||||
this.holdings.subtract(amount);
|
this.holdings.subtract(amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean multiply(double amount) {
|
public boolean multiply(double amount) {
|
||||||
if (this.holdings == null) return false;
|
if(this.holdings == null) return false;
|
||||||
this.holdings.multiply(amount);
|
this.holdings.multiply(amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean divide(double amount) {
|
public boolean divide(double amount) {
|
||||||
if (this.holdings == null) return false;
|
if(this.holdings == null) return false;
|
||||||
this.holdings.divide(amount);
|
this.holdings.divide(amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -214,7 +235,7 @@ public class iCo5 implements Method {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean remove() {
|
public boolean remove() {
|
||||||
if (this.account == null) return false;
|
if(this.account == null) return false;
|
||||||
this.account.remove();
|
this.account.remove();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
|
@ -1,10 +1,12 @@
|
||||||
package com.nijikokun.register.payment.forChestShop.methods;
|
package com.nijikokun.register.forChestShop.payment.methods;
|
||||||
|
|
||||||
|
import com.nijikokun.register.forChestShop.payment.Method;
|
||||||
import com.iCo6.iConomy;
|
import com.iCo6.iConomy;
|
||||||
import com.iCo6.system.Account;
|
import com.iCo6.system.Account;
|
||||||
import com.iCo6.system.Accounts;
|
import com.iCo6.system.Accounts;
|
||||||
import com.iCo6.system.Holdings;
|
import com.iCo6.system.Holdings;
|
||||||
import com.nijikokun.register.payment.forChestShop.Method;
|
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,9 +30,9 @@ public class iCo6 implements Method {
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return "6";
|
return "6";
|
||||||
}
|
}
|
||||||
|
|
||||||
public int fractionalDigits() {
|
public int fractionalDigits() {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String format(double amount) {
|
public String format(double amount) {
|
||||||
|
@ -53,6 +55,20 @@ public class iCo6 implements Method {
|
||||||
return false;
|
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) {
|
public MethodAccount getAccount(String name) {
|
||||||
return new iCoAccount((new Accounts()).get(name));
|
return new iCoAccount((new Accounts()).get(name));
|
||||||
}
|
}
|
||||||
|
@ -62,16 +78,16 @@ public class iCo6 implements Method {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCompatible(Plugin plugin) {
|
public boolean isCompatible(Plugin plugin) {
|
||||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
|
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
|
||||||
&& plugin.getClass().getName().equals("com.iCo6.iConomy")
|
&& plugin.getClass().getName().equals("com.iCo6.iConomy")
|
||||||
&& plugin instanceof iConomy;
|
&& plugin instanceof iConomy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlugin(Plugin plugin) {
|
public void setPlugin(Plugin plugin) {
|
||||||
iConomy = (iConomy) plugin;
|
iConomy = (iConomy)plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class iCoAccount implements MethodAccount {
|
public class iCoAccount implements MethodAccount {
|
||||||
private Account account;
|
private Account account;
|
||||||
private Holdings holdings;
|
private Holdings holdings;
|
||||||
|
|
||||||
|
@ -89,31 +105,31 @@ public class iCo6 implements Method {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean set(double amount) {
|
public boolean set(double amount) {
|
||||||
if (this.holdings == null) return false;
|
if(this.holdings == null) return false;
|
||||||
this.holdings.setBalance(amount);
|
this.holdings.setBalance(amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean add(double amount) {
|
public boolean add(double amount) {
|
||||||
if (this.holdings == null) return false;
|
if(this.holdings == null) return false;
|
||||||
this.holdings.add(amount);
|
this.holdings.add(amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean subtract(double amount) {
|
public boolean subtract(double amount) {
|
||||||
if (this.holdings == null) return false;
|
if(this.holdings == null) return false;
|
||||||
this.holdings.subtract(amount);
|
this.holdings.subtract(amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean multiply(double amount) {
|
public boolean multiply(double amount) {
|
||||||
if (this.holdings == null) return false;
|
if(this.holdings == null) return false;
|
||||||
this.holdings.multiply(amount);
|
this.holdings.multiply(amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean divide(double amount) {
|
public boolean divide(double amount) {
|
||||||
if (this.holdings == null) return false;
|
if(this.holdings == null) return false;
|
||||||
this.holdings.divide(amount);
|
this.holdings.divide(amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -135,7 +151,7 @@ public class iCo6 implements Method {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean remove() {
|
public boolean remove() {
|
||||||
if (this.account == null) return false;
|
if(this.account == null) return false;
|
||||||
this.account.remove();
|
this.account.remove();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
|
@ -2,7 +2,7 @@ name: ChestShop
|
||||||
|
|
||||||
main: com.Acrobot.ChestShop.ChestShop
|
main: com.Acrobot.ChestShop.ChestShop
|
||||||
|
|
||||||
version: 3.21
|
version: 3.22
|
||||||
|
|
||||||
|
|
||||||
author: Acrobot
|
author: Acrobot
|
||||||
|
|
Loading…
Reference in New Issue