- 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:
Acrobot 2011-09-29 20:29:39 +02:00
parent 4440101a3a
commit 9a6b9d0c38
19 changed files with 456 additions and 272 deletions

View File

@ -1,6 +1,6 @@
package com.Acrobot.ChestShop.Config;
import com.nijikokun.register.payment.forChestShop.Methods;
import com.nijikokun.register.forChestShop.payment.Methods;
/**
* @author Acrobot

View File

@ -25,7 +25,8 @@ public enum Property {
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_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;

View File

@ -1,7 +1,9 @@
package com.Acrobot.ChestShop;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Property;
import com.Acrobot.ChestShop.Utils.uLongName;
import com.nijikokun.register.payment.forChestShop.Method;
import com.nijikokun.register.forChestShop.payment.Method;
/**
* @author Acrobot
@ -15,6 +17,11 @@ public class Economy {
}
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);
}

View File

@ -5,12 +5,14 @@ import com.Acrobot.ChestShop.Utils.uBlock;
import com.Acrobot.ChestShop.Utils.uLongName;
import com.Acrobot.ChestShop.Utils.uSign;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.material.PistonBaseMaterial;
/**
* @author Acrobot
@ -57,6 +59,17 @@ public class blockBreak extends BlockListener {
}
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;
}
}

View File

@ -71,11 +71,8 @@ public class playerInteract extends PlayerListener {
Action buy = (Config.getBoolean(Property.REVERSE_BUTTONS) ? Action.LEFT_CLICK_BLOCK : Action.RIGHT_CLICK_BLOCK);
if (action == buy) {
ShopManagement.buy(sign, player);
} else {
ShopManagement.sell(sign, player);
}
if (action == buy) ShopManagement.buy(sign, player);
else ShopManagement.sell(sign, player);
}
private static boolean enoughTimeHasPassed(Player player) {

View File

@ -1,7 +1,7 @@
package com.Acrobot.ChestShop.Listeners;
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.ServerListener;

View File

@ -13,7 +13,7 @@ import com.Acrobot.ChestShop.Utils.uSign;
import com.daemitus.deadbolt.Deadbolt;
import com.griefcraft.lwc.LWCPlugin;
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 org.bukkit.event.server.PluginEnableEvent;
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.");
}
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());
}
}

View File

@ -22,8 +22,13 @@ public class uTowny {
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) {
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) {

View File

@ -22,7 +22,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
public abstract class Database {
private final JavaPlugin javaPlugin;
private JavaPlugin javaPlugin;
private ClassLoader classLoader;
private Level loggerLevel;
private boolean usingSQLite;
@ -31,7 +31,7 @@ public abstract class Database {
/**
* Create an instance of Database
*
*
* @param javaPlugin Plugin instancing this database
*/
public Database(JavaPlugin javaPlugin) {
@ -45,8 +45,9 @@ public abstract class Database {
method.setAccessible(true);
//Store the ClassLoader
this.classLoader = (ClassLoader) method.invoke(javaPlugin);
} catch (Exception ex) {
this.classLoader = (ClassLoader)method.invoke(javaPlugin);
}
catch(Exception 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
*
* @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 username Username required to access the database
* @param password Password belonging to the username, may be empty
* @param isolation Isolation type. For example: SERIALIZABLE, also see TransactionIsolation
* @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 username Username required to access the database
* @param password Password belonging to the username, may be empty
* @param isolation Isolation type. For example: SERIALIZABLE, also see TransactionIsolation
*/
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
try {
try {
//Disable all logging
disableDatabaseLogging(false);
@ -73,16 +74,18 @@ public abstract class Database {
loadDatabase();
//Create all tables
installDatabase(true);
} catch (Exception ex) {
installDatabase(false);
}
catch(Exception ex) {
throw new RuntimeException("An exception has occured while initializing the database", ex);
} finally {
}
finally {
//Enable all logging
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
DataSourceConfig ds = new DataSourceConfig();
ds.setDriver(driver);
@ -101,7 +104,10 @@ public abstract class Database {
List<Class<?>> classes = getDatabaseClasses();
//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
sc.setClasses(classes);
@ -116,6 +122,8 @@ public abstract class Database {
sc.getDatabasePlatform().getDbDdlSyntax().setIdentity("");
}
prepareDatabaseAdditionalConfig(ds, sc);
//Finally the data source
sc.setDataSourceConfig(ds);
@ -146,33 +154,34 @@ public abstract class Database {
//Setup Ebean based on the configuration
ebeanServer = EbeanServerFactory.create(serverConfig);
} catch (Exception ex) {
}
catch(Exception ex) {
throw new RuntimeException("Failed to create a new instance of the EbeanServer", ex);
} finally {
}
finally {
//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
try {
if (cacheField != null) cacheField.setBoolean(null, cacheValue);
} catch (Exception e) {
if(cacheField != null) {
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.");
}
}
}
private void installDatabase(boolean rebuild) {
//Check if the database has to be rebuild
if (!rebuild) return;
//Create a DDL generator
SpiEbeanServer serv = (SpiEbeanServer) ebeanServer;
DdlGenerator gen = serv.getDdlGenerator();
//Check if the database already (partially) exists
//Check if the database already (partially) exists
boolean databaseExists = false;
for (Class<?> aClass : getDatabaseClasses()) {
List<Class<?>> classes = getDatabaseClasses();
for (Class<?> aClass : classes) {
try {
//Do a simple query which only throws an exception if the table does not exist
ebeanServer.find(aClass).findRowCount();
@ -180,33 +189,53 @@ public abstract class Database {
//Query passed without throwing an exception, a database therefore already exists
databaseExists = true;
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 {
beforeDropDatabase();
} catch (Exception ex) {
}
catch(Exception ex) {
//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
gen.runScript(true, gen.generateDropDdl());
//If SQLite is being used, the database has to reloaded to release all resources
if (usingSQLite) loadDatabase();
if(usingSQLite) {
loadDatabase();
}
//Generate a CreateDDL-script
//If SQLite is being used, the CreateDLL-script has to be validated and potentially fixed to be valid
gen.runScript(false, (usingSQLite ? validateCreateDDLSqlite(gen.generateCreateDdl()) : gen.generateCreateDdl()));
if(usingSQLite) {
//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
try {
afterCreateDatabase();
} catch (Exception ex) {
}
catch(Exception ex) {
throw new RuntimeException("An unexpected exception occured", ex);
}
}
@ -241,11 +270,12 @@ public abstract class Database {
scriptLines.add(currentLine.trim());
//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
currentTable = currentLine.split(" ", 4)[2];
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
int index = scriptLines.size() - 1;
foundTables.put(currentTable, index);
@ -260,16 +290,17 @@ public abstract class Database {
//Reset the table-tracker
currentTable = null;
} else if (currentLine.startsWith("alter table")) {
}
else if(currentLine.startsWith("alter table")) {
//Found a potentially unsupported action
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
String[] addConstraintLine = alterTableLine[3].split(" ", 4);
//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
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
scriptLines.remove(scriptLines.size() - 1);
tableOffset++;
} else {
}
else {
//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]);
}
@ -293,14 +325,15 @@ public abstract class Database {
//Turn all the lines back into a single string
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
System.out.println(newScript);
//Return the fixed script
return newScript.toString();
} catch (Exception ex) {
}
catch (Exception ex) {
//Exception: Failed to fix the DDL or something just went plain wrong
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) {
//If logging is allowed, nothing has to be changed
if (logging) return;
if(logging) {
return;
}
//Retrieve the level of the root logger
loggerLevel = Logger.getLogger("").getLevel();
@ -319,7 +354,9 @@ public abstract class Database {
private void enableDatabaseLogging(boolean logging) {
//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
Logger.getLogger("").setLevel(loggerLevel);
@ -327,7 +364,7 @@ public abstract class Database {
/**
* Get a 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() {
@ -337,18 +374,24 @@ public abstract class Database {
/**
* Method called before the loaded database is being dropped
*/
protected void beforeDropDatabase() {
}
protected void beforeDropDatabase() {}
/**
* 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
*
*
* @return EbeanServer Instance of the EbeanServer
*/
public EbeanServer getDatabase() {

View File

@ -1,4 +1,4 @@
package com.nijikokun.register.payment.forChestShop;
package com.nijikokun.register.forChestShop.payment;
import org.bukkit.plugin.Plugin;
@ -14,11 +14,11 @@ public interface Method {
* Encodes the Plugin into an Object disguised as the Plugin.
* If you want the original Plugin Class you must cast it to the correct
* Plugin, to do so you have to verify the name and or version then cast.
* <p/>
*
* <pre>
* if(method.getName().equalsIgnoreCase("iConomy"))
* iConomy plugin = ((iConomy)method.getPlugin());</pre>
*
*
* @return <code>Object</code>
* @see #getName()
* @see #getVersion()
@ -38,11 +38,11 @@ public interface Method {
* @return <code>String</code> Plugin version.
*/
public String getVersion();
/**
* Returns the amount of decimal places that get stored
* NOTE: it will return -1 if there is no rounding
*
*
* @return <code>int</code> for each decimal place
*/
public int fractionalDigits();
@ -88,6 +88,23 @@ public interface Method {
*/
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>.
*
@ -127,25 +144,15 @@ public interface Method {
*/
public interface MethodAccount {
public double balance();
public boolean set(double amount);
public boolean add(double amount);
public boolean subtract(double amount);
public boolean multiply(double amount);
public boolean divide(double amount);
public boolean hasEnough(double amount);
public boolean hasOver(double amount);
public boolean hasUnder(double amount);
public boolean isNegative();
public boolean remove();
@Override
@ -157,29 +164,17 @@ public interface Method {
*/
public interface MethodBankAccount {
public double balance();
public String getBankName();
public int getBankId();
public boolean set(double amount);
public boolean add(double amount);
public boolean subtract(double amount);
public boolean multiply(double amount);
public boolean divide(double amount);
public boolean hasEnough(double amount);
public boolean hasOver(double amount);
public boolean hasUnder(double amount);
public boolean isNegative();
public boolean remove();
@Override

View File

@ -1,20 +1,20 @@
package com.nijikokun.register.payment.forChestShop;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
package com.nijikokun.register.forChestShop.payment;
import java.util.HashSet;
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
* based on a "first come, first served" basis.
* <p/>
*
* 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
* payment plugins in the initialization process.
* <p/>
*
* in <code>bukkit.yml</code>:
* <blockquote><pre>
* economy:
@ -29,7 +29,7 @@ public class Methods {
private static String version = null;
private static boolean self = false;
private static Method Method = null;
public static String preferred = "";
private static String preferred = "";
private static Set<Method> Methods = new HashSet<Method>();
private static Set<String> Dependencies = new HashSet<String>();
private static Set<Method> Attachables = new HashSet<Method>();
@ -42,13 +42,13 @@ public class Methods {
* Implement all methods along with their respective name & class.
*/
private static void _init() {
addMethod("iConomy", new com.nijikokun.register.payment.forChestShop.methods.iCo6());
addMethod("iConomy", new com.nijikokun.register.payment.forChestShop.methods.iCo5());
addMethod("iConomy", new com.nijikokun.register.payment.forChestShop.methods.iCo4());
addMethod("BOSEconomy", new com.nijikokun.register.payment.forChestShop.methods.BOSE6());
addMethod("BOSEconomy", new com.nijikokun.register.payment.forChestShop.methods.BOSE7());
addMethod("Essentials", new com.nijikokun.register.payment.forChestShop.methods.EE17());
addMethod("Currency", new com.nijikokun.register.payment.forChestShop.methods.MCUR());
addMethod("iConomy", new com.nijikokun.register.forChestShop.payment.methods.iCo6());
addMethod("iConomy", new com.nijikokun.register.forChestShop.payment.methods.iCo5());
addMethod("iConomy", new com.nijikokun.register.forChestShop.payment.methods.iCo4());
addMethod("BOSEconomy", new com.nijikokun.register.forChestShop.payment.methods.BOSE6());
addMethod("BOSEconomy", new com.nijikokun.register.forChestShop.payment.methods.BOSE7());
addMethod("Essentials", new com.nijikokun.register.forChestShop.payment.methods.EE17());
addMethod("Currency", new com.nijikokun.register.forChestShop.payment.methods.MCUR());
Dependencies.add("MultiCurrency");
}
@ -74,7 +74,6 @@ public class Methods {
/**
* Use to get version of Register plugin
*
* @return version
*/
public static String getVersion() {
@ -86,6 +85,7 @@ public class Methods {
* through the <code>_init</code> method.
*
* @return <code>Set<String></code> - Array of payment methods that are loaded.
* @see #setMethod(org.bukkit.plugin.Plugin)
*/
public static Set<String> getDependencies() {
return Dependencies;
@ -99,7 +99,7 @@ public class Methods {
* @return Method <em>or</em> Null
*/
public static Method createMethod(Plugin plugin) {
for (Method method : Methods)
for (Method method: Methods)
if (method.isCompatible(plugin)) {
method.setPlugin(plugin);
return method;
@ -117,6 +117,7 @@ public class Methods {
* Verifies if Register has set a payment method for usage yet.
*
* @return <code>boolean</code>
* @see #setMethod(org.bukkit.plugin.Plugin)
* @see #checkDisabled(org.bukkit.plugin.Plugin)
*/
public static boolean hasMethod() {
@ -127,6 +128,7 @@ public class Methods {
* Checks Plugin Class against a multitude of checks to verify it's usability
* as a payment method.
*
* @param <code>PluginManager</code> the plugin manager for the server
* @return <code>boolean</code> True on success, False on failure.
*/
public static boolean setMethod(PluginManager manager) {
@ -140,14 +142,14 @@ public class Methods {
int count = 0;
boolean match = false;
Plugin plugin;
Plugin plugin = null;
for (String name : Dependencies) {
for (String name : getDependencies()) {
if (hasMethod())
break;
plugin = manager.getPlugin(name);
if (plugin == null)
if (plugin == null || !plugin.isEnabled())
continue;
Method current = createMethod(plugin);
@ -170,8 +172,7 @@ public class Methods {
continue;
if (hasMethod()) {
match = true;
break;
match = true; break;
}
if (preferred.isEmpty())
@ -181,8 +182,8 @@ public class Methods {
if (preferred.equalsIgnoreCase(attached.getName()))
Method = attached;
else
Method = attached;
else
Method = attached;
}
count++;
@ -199,7 +200,7 @@ public class Methods {
* @return <code>boolean</code>
*/
public static boolean setPreferred(String check) {
if (Dependencies.contains(check)) {
if (getDependencies().contains(check)) {
preferred = check;
return true;
}
@ -224,7 +225,7 @@ public class Methods {
* @return <code>boolean</code>
*/
public static boolean checkDisabled(Plugin method) {
if (!hasMethod())
if(!hasMethod())
return true;
if (Method.isCompatible(method))

View File

@ -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 org.bukkit.plugin.Plugin;
@ -26,15 +27,15 @@ public class BOSE6 implements Method {
public String getVersion() {
return "0.6.2";
}
public int fractionalDigits() {
return 0;
return 0;
}
public String format(double amount) {
String currency = this.BOSEconomy.getMoneyNamePlural();
if (amount == 1)
if(amount == 1)
currency = this.BOSEconomy.getMoneyName();
return amount + " " + currency;
@ -54,34 +55,51 @@ public class BOSE6 implements Method {
public boolean hasBankAccount(String bank, String 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) {
if (!hasAccount(name))
if(!hasAccount(name))
return null;
return new BOSEAccount(name, this.BOSEconomy);
}
public MethodBankAccount getBankAccount(String bank, String name) {
if (!hasBankAccount(bank, 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");
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 static class BOSEAccount implements MethodAccount {
public class BOSEAccount implements MethodAccount {
private final String name;
private final BOSEconomy BOSEconomy;
@ -95,30 +113,30 @@ public class BOSE6 implements Method {
}
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);
}
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);
}
public boolean subtract(double amount) {
int IntAmount = (int) Math.ceil(amount);
int balance = (int) this.balance();
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setPlayerMoney(this.name, (balance - IntAmount), false);
}
public boolean multiply(double amount) {
int IntAmount = (int) Math.ceil(amount);
int balance = (int) this.balance();
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setPlayerMoney(this.name, (balance * IntAmount), false);
}
public boolean divide(double amount) {
int IntAmount = (int) Math.ceil(amount);
int balance = (int) this.balance();
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
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 BOSEconomy BOSEconomy;
@ -165,31 +183,31 @@ public class BOSE6 implements Method {
}
public boolean set(double amount) {
int IntAmount = (int) Math.ceil(amount);
int IntAmount = (int)Math.ceil(amount);
return this.BOSEconomy.setBankMoney(bank, IntAmount, true);
}
public boolean add(double amount) {
int IntAmount = (int) Math.ceil(amount);
int balance = (int) this.balance();
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance + IntAmount), false);
}
public boolean subtract(double amount) {
int IntAmount = (int) Math.ceil(amount);
int balance = (int) this.balance();
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance - IntAmount), false);
}
public boolean multiply(double amount) {
int IntAmount = (int) Math.ceil(amount);
int balance = (int) this.balance();
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance * IntAmount), false);
}
public boolean divide(double amount) {
int IntAmount = (int) Math.ceil(amount);
int balance = (int) this.balance();
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance / IntAmount), false);
}

View File

@ -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 org.bukkit.plugin.Plugin;
@ -26,15 +27,15 @@ public class BOSE7 implements Method {
public String getVersion() {
return "0.7.0";
}
public int fractionalDigits() {
return this.BOSEconomy.getFractionalDigits();
return this.BOSEconomy.getFractionalDigits();
}
public String format(double amount) {
String currency = this.BOSEconomy.getMoneyNamePlural();
if (amount == 1)
if(amount == 1)
currency = this.BOSEconomy.getMoneyName();
return amount + " " + currency;
@ -56,31 +57,48 @@ public class BOSE7 implements Method {
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name);
}
public boolean createAccount(String name) {
if(hasAccount(name))
return false;
this.BOSEconomy.registerPlayer(name);
return true;
}
public boolean createAccount(String name, Double balance) {
if(hasAccount(name))
return false;
this.BOSEconomy.registerPlayer(name);
this.BOSEconomy.setPlayerMoney(name, balance, false);
return true;
}
public MethodAccount getAccount(String name) {
if (!hasAccount(name))
if(!hasAccount(name))
return null;
return new BOSEAccount(name, this.BOSEconomy);
}
public MethodBankAccount getBankAccount(String bank, String name) {
if (!hasBankAccount(bank, 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");
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy")
&& plugin instanceof BOSEconomy
&& !plugin.getDescription().getVersion().equals("0.6.2");
}
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 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 BOSEconomy BOSEconomy;

View File

@ -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.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;
/**
@ -31,9 +30,9 @@ public class EE17 implements Method {
public String getVersion() {
return "2.2";
}
public int fractionalDigits() {
return -1;
return -1;
}
public String format(double amount) {
@ -56,8 +55,32 @@ public class EE17 implements Method {
return false;
}
public boolean createAccount(String name) {
if(hasAccount(name))
return false;
Economy.createNPC(name);
return true;
}
public boolean createAccount(String name, Double balance) {
if(hasAccount(name))
return false;
Economy.createNPC(name);
try {
Economy.setMoney(name, balance);
} catch (Exception ex) {
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
return false;
}
return true;
}
public MethodAccount getAccount(String name) {
if (!hasAccount(name))
if(!hasAccount(name))
return null;
return new EEcoAccount(name);
@ -66,19 +89,20 @@ public class EE17 implements Method {
public MethodBankAccount getBankAccount(String bank, String name) {
return null;
}
public boolean isCompatible(Plugin plugin) {
try { Class.forName("com.earth2me.essentials.api.Economy"); } catch (Exception e) { return false; }
try { Class.forName("com.earth2me.essentials.api.Economy"); }
catch(Exception e) { return false; }
return plugin.getDescription().getName().equalsIgnoreCase("essentials")
&& plugin instanceof Essentials;
&& plugin instanceof Essentials;
}
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;
public EEcoAccount(String name) {
@ -90,8 +114,8 @@ public class EE17 implements Method {
try {
balance = Economy.getMoney(this.name);
} catch (UserDoesNotExistException ex) {
System.out.println("[REGISTER] Failed to grab balance in Essentials Economy: " + ex.getMessage());
} catch (Exception ex) {
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
}
return balance;
@ -100,11 +124,8 @@ public class EE17 implements Method {
public boolean set(double amount) {
try {
Economy.setMoney(name, amount);
} catch (UserDoesNotExistException ex) {
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
return false;
} catch (NoLoanPermittedException ex) {
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
} catch (Exception ex) {
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
return false;
}
@ -114,11 +135,8 @@ public class EE17 implements Method {
public boolean add(double amount) {
try {
Economy.add(name, amount);
} catch (UserDoesNotExistException ex) {
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
return false;
} catch (NoLoanPermittedException ex) {
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
} catch (Exception ex) {
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
return false;
}
@ -128,11 +146,8 @@ public class EE17 implements Method {
public boolean subtract(double amount) {
try {
Economy.subtract(name, amount);
} catch (UserDoesNotExistException ex) {
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
return false;
} catch (NoLoanPermittedException ex) {
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
} catch (Exception ex) {
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
return false;
}
@ -142,11 +157,8 @@ public class EE17 implements Method {
public boolean multiply(double amount) {
try {
Economy.multiply(name, amount);
} catch (UserDoesNotExistException ex) {
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
return false;
} catch (NoLoanPermittedException ex) {
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
} catch (Exception ex) {
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
return false;
}
@ -156,11 +168,8 @@ public class EE17 implements Method {
public boolean divide(double amount) {
try {
Economy.divide(name, amount);
} catch (UserDoesNotExistException ex) {
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
return false;
} catch (NoLoanPermittedException ex) {
System.out.println("[REGISTER] No loan permitted in Essentials Economy: " + ex.getMessage());
} catch (Exception ex) {
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
return false;
}
@ -170,8 +179,8 @@ public class EE17 implements Method {
public boolean hasEnough(double amount) {
try {
return Economy.hasEnough(name, amount);
} catch (UserDoesNotExistException ex) {
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
} catch (Exception ex) {
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
}
return false;
@ -180,8 +189,8 @@ public class EE17 implements Method {
public boolean hasOver(double amount) {
try {
return Economy.hasMore(name, amount);
} catch (UserDoesNotExistException ex) {
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
} catch (Exception ex) {
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
}
return false;
@ -190,8 +199,8 @@ public class EE17 implements Method {
public boolean hasUnder(double amount) {
try {
return Economy.hasLess(name, amount);
} catch (UserDoesNotExistException ex) {
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
} catch (Exception ex) {
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
}
return false;
@ -200,8 +209,8 @@ public class EE17 implements Method {
public boolean isNegative() {
try {
return Economy.isNegative(name);
} catch (UserDoesNotExistException ex) {
System.out.println("[REGISTER] User does not exist in Essentials Economy: " + ex.getMessage());
} catch (Exception ex) {
System.out.println("[REGISTER] Error in Essentials Economy: " + ex.getMessage());
}
return false;

View File

@ -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.CurrencyList;
import org.bukkit.plugin.Plugin;
/**
@ -26,9 +28,9 @@ public class MCUR implements Method {
public String getVersion() {
return "0.09";
}
public int fractionalDigits() {
return -1;
return -1;
}
public String format(double amount) {
@ -51,6 +53,16 @@ public class MCUR implements Method {
return false;
}
public boolean createAccount(String name) {
CurrencyList.setValue((String) CurrencyList.maxCurrency(name)[0], name, 0);
return true;
}
public boolean createAccount(String name, Double balance) {
CurrencyList.setValue((String) CurrencyList.maxCurrency(name)[0], name, balance);
return true;
}
public MethodAccount getAccount(String name) {
return new MCurrencyAccount(name);
}
@ -61,15 +73,15 @@ public class MCUR implements Method {
public boolean isCompatible(Plugin plugin) {
return (plugin.getDescription().getName().equalsIgnoreCase("Currency")
|| plugin.getDescription().getName().equalsIgnoreCase("MultiCurrency"))
&& plugin instanceof Currency;
|| plugin.getDescription().getName().equalsIgnoreCase("MultiCurrency"))
&& plugin instanceof Currency;
}
public void setPlugin(Plugin plugin) {
currencyList = (Currency) plugin;
}
public static class MCurrencyAccount implements MethodAccount {
public class MCurrencyAccount implements MethodAccount{
private String name;
public MCurrencyAccount(String name) {

View File

@ -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.system.Account;
import com.nijikokun.register.payment.forChestShop.Method;
import org.bukkit.plugin.Plugin;
/**
@ -26,9 +28,9 @@ public class iCo4 implements Method {
public String getVersion() {
return "4";
}
public int fractionalDigits() {
return 2;
return 2;
}
public String format(double amount) {
@ -51,6 +53,32 @@ public class iCo4 implements Method {
return false;
}
public boolean createAccount(String name) {
if(hasAccount(name))
return false;
try {
com.nijiko.coelho.iConomy.iConomy.getBank().addAccount(name);
} catch(Exception E) {
return false;
}
return true;
}
public boolean createAccount(String name, Double balance) {
if(hasAccount(name))
return false;
try {
com.nijiko.coelho.iConomy.iConomy.getBank().addAccount(name, balance);
} catch(Exception E) {
return false;
}
return true;
}
public MethodAccount getAccount(String name) {
return new iCoAccount(com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(name));
}
@ -58,18 +86,18 @@ public class iCo4 implements Method {
public MethodBankAccount getBankAccount(String bank, String name) {
return null;
}
public boolean isCompatible(Plugin plugin) {
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
&& plugin.getClass().getName().equals("com.nijiko.coelho.iConomy.iConomy")
&& plugin instanceof iConomy;
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
&& plugin.getClass().getName().equals("com.nijiko.coelho.iConomy.iConomy")
&& plugin instanceof iConomy;
}
public void setPlugin(Plugin plugin) {
iConomy = (iConomy) plugin;
iConomy = (iConomy)plugin;
}
public static class iCoAccount implements MethodAccount {
public class iCoAccount implements MethodAccount {
private Account account;
public iCoAccount(Account account) {
@ -85,31 +113,31 @@ public class iCo4 implements Method {
}
public boolean set(double amount) {
if (this.account == null) return false;
if(this.account == null) return false;
this.account.setBalance(amount);
return true;
}
public boolean add(double amount) {
if (this.account == null) return false;
if(this.account == null) return false;
this.account.add(amount);
return true;
}
public boolean subtract(double amount) {
if (this.account == null) return false;
if(this.account == null) return false;
this.account.subtract(amount);
return true;
}
public boolean multiply(double amount) {
if (this.account == null) return false;
if(this.account == null) return false;
this.account.multiply(amount);
return true;
}
public boolean divide(double amount) {
if (this.account == null) return false;
if(this.account == null) return false;
this.account.divide(amount);
return true;
}
@ -131,7 +159,7 @@ public class iCo4 implements Method {
}
public boolean remove() {
if (this.account == null) return false;
if(this.account == null) return false;
this.account.remove();
return true;
}

View File

@ -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.system.Account;
import com.iConomy.system.BankAccount;
import com.iConomy.system.Holdings;
import com.iConomy.util.Constants;
import com.nijikokun.register.payment.forChestShop.Method;
import org.bukkit.plugin.Plugin;
/**
@ -29,9 +31,9 @@ public class iCo5 implements Method {
public String getVersion() {
return "5";
}
public int fractionalDigits() {
return 2;
return 2;
}
public String format(double amount) {
@ -54,6 +56,25 @@ public class iCo5 implements Method {
return (hasBank(bank)) && com.iConomy.iConomy.getBank(bank).hasAccount(name);
}
public boolean createAccount(String name) {
if(hasAccount(name))
return false;
return com.iConomy.iConomy.Accounts.create(name);
}
public boolean createAccount(String name, Double balance) {
if(hasAccount(name))
return false;
if(!com.iConomy.iConomy.Accounts.create(name))
return false;
getAccount(name).set(balance);
return true;
}
public MethodAccount getAccount(String name) {
return new iCoAccount(com.iConomy.iConomy.getAccount(name));
}
@ -63,16 +84,16 @@ public class iCo5 implements Method {
}
public boolean isCompatible(Plugin plugin) {
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
&& plugin.getClass().getName().equals("com.iConomy.iConomy")
&& plugin instanceof iConomy;
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
&& plugin.getClass().getName().equals("com.iConomy.iConomy")
&& plugin instanceof iConomy;
}
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 Holdings holdings;
@ -90,31 +111,31 @@ public class iCo5 implements Method {
}
public boolean set(double amount) {
if (this.holdings == null) return false;
if(this.holdings == null) return false;
this.holdings.set(amount);
return true;
}
public boolean add(double amount) {
if (this.holdings == null) return false;
if(this.holdings == null) return false;
this.holdings.add(amount);
return true;
}
public boolean subtract(double amount) {
if (this.holdings == null) return false;
if(this.holdings == null) return false;
this.holdings.subtract(amount);
return true;
}
public boolean multiply(double amount) {
if (this.holdings == null) return false;
if(this.holdings == null) return false;
this.holdings.multiply(amount);
return true;
}
public boolean divide(double amount) {
if (this.holdings == null) return false;
if(this.holdings == null) return false;
this.holdings.divide(amount);
return true;
}
@ -136,13 +157,13 @@ public class iCo5 implements Method {
}
public boolean remove() {
if (this.account == null) return false;
if(this.account == null) return false;
this.account.remove();
return true;
}
}
public static class iCoBankAccount implements MethodBankAccount {
public class iCoBankAccount implements MethodBankAccount {
private BankAccount account;
private Holdings holdings;
@ -168,31 +189,31 @@ public class iCo5 implements Method {
}
public boolean set(double amount) {
if (this.holdings == null) return false;
if(this.holdings == null) return false;
this.holdings.set(amount);
return true;
}
public boolean add(double amount) {
if (this.holdings == null) return false;
if(this.holdings == null) return false;
this.holdings.add(amount);
return true;
}
public boolean subtract(double amount) {
if (this.holdings == null) return false;
if(this.holdings == null) return false;
this.holdings.subtract(amount);
return true;
}
public boolean multiply(double amount) {
if (this.holdings == null) return false;
if(this.holdings == null) return false;
this.holdings.multiply(amount);
return true;
}
public boolean divide(double amount) {
if (this.holdings == null) return false;
if(this.holdings == null) return false;
this.holdings.divide(amount);
return true;
}
@ -214,7 +235,7 @@ public class iCo5 implements Method {
}
public boolean remove() {
if (this.account == null) return false;
if(this.account == null) return false;
this.account.remove();
return true;
}

View File

@ -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.system.Account;
import com.iCo6.system.Accounts;
import com.iCo6.system.Holdings;
import com.nijikokun.register.payment.forChestShop.Method;
import org.bukkit.plugin.Plugin;
/**
@ -28,9 +30,9 @@ public class iCo6 implements Method {
public String getVersion() {
return "6";
}
public int fractionalDigits() {
return 2;
return 2;
}
public String format(double amount) {
@ -53,6 +55,20 @@ public class iCo6 implements Method {
return false;
}
public boolean createAccount(String name) {
if(hasAccount(name))
return false;
return (new Accounts()).create(name);
}
public boolean createAccount(String name, Double balance) {
if(hasAccount(name))
return false;
return (new Accounts()).create(name, balance);
}
public MethodAccount getAccount(String name) {
return new iCoAccount((new Accounts()).get(name));
}
@ -62,16 +78,16 @@ public class iCo6 implements Method {
}
public boolean isCompatible(Plugin plugin) {
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
&& plugin.getClass().getName().equals("com.iCo6.iConomy")
&& plugin instanceof iConomy;
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
&& plugin.getClass().getName().equals("com.iCo6.iConomy")
&& plugin instanceof iConomy;
}
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 Holdings holdings;
@ -89,31 +105,31 @@ public class iCo6 implements Method {
}
public boolean set(double amount) {
if (this.holdings == null) return false;
if(this.holdings == null) return false;
this.holdings.setBalance(amount);
return true;
}
public boolean add(double amount) {
if (this.holdings == null) return false;
if(this.holdings == null) return false;
this.holdings.add(amount);
return true;
}
public boolean subtract(double amount) {
if (this.holdings == null) return false;
if(this.holdings == null) return false;
this.holdings.subtract(amount);
return true;
}
public boolean multiply(double amount) {
if (this.holdings == null) return false;
if(this.holdings == null) return false;
this.holdings.multiply(amount);
return true;
}
public boolean divide(double amount) {
if (this.holdings == null) return false;
if(this.holdings == null) return false;
this.holdings.divide(amount);
return true;
}
@ -135,7 +151,7 @@ public class iCo6 implements Method {
}
public boolean remove() {
if (this.account == null) return false;
if(this.account == null) return false;
this.account.remove();
return true;
}

View File

@ -2,7 +2,7 @@ name: ChestShop
main: com.Acrobot.ChestShop.ChestShop
version: 3.21
version: 3.22
author: Acrobot