me.mjolnir.mineconomy.internal
Class MCCom

java.lang.Object
  extended by me.mjolnir.mineconomy.internal.MCCom

public class MCCom
extends java.lang.Object

Handles exterior classes reading/writing account values.

Author:
MjolnirCommando

Constructor Summary
MCCom()
           
 
Method Summary
static boolean accountExists(java.lang.String bank, java.lang.String account)
          Returns true if the specified account exists in the specified bank.
static void add(java.lang.String account, double amount)
          Adds the specified amount to specified account.
static void add(java.lang.String bank, java.lang.String account, double amount)
          Adds the specified amount to the specified account's balance in the specified bank.
static boolean bankExists(java.lang.String bank)
          Returns true if the specified bank exists.
static boolean canAfford(java.lang.String account, double amount)
          Returns true if specified player has specified amount in their account.
static boolean canAfford(java.lang.String bank, java.lang.String account, double amount)
          Returns true if the specified account in the specified bank has the specified amount in their account.
static boolean canExternalAfford(java.lang.String account, double amount)
          Returns true if the specified account has at least the specified amount.
static void create(java.lang.String account)
          Creates a new account with the specified name.
static void create(java.lang.String bank, java.lang.String account)
          Creates an account with the specified name in the specified bank.
static void createBank(java.lang.String bank)
          Creates a bank with the specified name.
static boolean currencyExists(java.lang.String currency)
          Returns true if the specified currency exists.
static void delete(java.lang.String account)
          Deletes an existing account with the specified name.
static void delete(java.lang.String bank, java.lang.String account)
          Deletes the account with the specified name in the specified bank.
static void deleteBank(java.lang.String bank)
          Deletes the bank with the specified name.
static void divide(java.lang.String account, double divisor)
          Divides the specified account by the specified divisor.
static void divide(java.lang.String bank, java.lang.String account, double divisor)
          Divides the specified account's balance with the specified divisor in the specified bank.
static void empty(java.lang.String account)
          Sets the specified account's balance to 0.
static void empty(java.lang.String bank, java.lang.String account)
          Sets the specified account's balance, in the specified bank, to 0.
static boolean exists(java.lang.String account)
          Returns true if specified player has an account.
static java.lang.String getAccount(java.lang.String account)
          Returns account from case-insensitive alias
static java.lang.String getAccountCurrency(java.lang.String account)
          Gets the currency of the specified account.
static AccountingBase getAccounting()
          Returns instance of accounting class to use.
static java.util.ArrayList<java.lang.String> getAccounts()
          Gets an ArrayList with all MineConomy accounts.
static double getBalance(java.lang.String account)
          Returns the balance of the specified player.
static double getBalance(java.lang.String bank, java.lang.String account)
          Returns the balance of the specified account in the specified bank.
static java.util.ArrayList<java.lang.String> getBanks()
          Returns a list of all existing banks.
static java.lang.String getCurrency(java.lang.String account)
          Returns the currency used by an account.
static java.lang.String getCurrencyById(java.lang.String id)
          Gets the currency with the specified ID.
static java.lang.String getCurrencyId(java.lang.String currency)
          Gets the ID of the specified currency.
static double getCurrencyValue(java.lang.String currency)
          Returns the specified currency's value.
static java.lang.String getDefaultCurrency()
          Returns the default currency.
static double getExternalBalance(java.lang.String account)
          Returns the balance of the specified account.
static java.lang.String getName()
          Returns the name of MineConomy.
static double getPhysicalCurrencyValue(java.lang.String currency)
          Returns the specified physical currency's value.
static org.bukkit.plugin.java.JavaPlugin getPlugin()
          Returns the MineConomy plugin.
static java.lang.String getVersion()
          Returns the current version of MineConomy.
static boolean idExists(java.lang.String id)
          Returns true if the specified ID exists.
static void initialize()
          Initializes MCCom base classes.
static void multiply(java.lang.String account, double multiplier)
          Multiplies the specified account by the specified multiplier.
static void multiply(java.lang.String bank, java.lang.String account, double multiplier)
          Multiplies the specified account's balance with the specified multiplier in the specified bank.
static boolean physicalCurrencyExists(java.lang.String currency)
          Returns true if the specified physical currency exists.
static void rename(java.lang.String account, java.lang.String newAccount)
          Renames an existing account with the specified name.
static void rename(java.lang.String oldBank, java.lang.String oldAccount, java.lang.String newBank, java.lang.String newAccount)
          Renames the specified account in the respective bank to the new account name in its respective bank.
static void renameBank(java.lang.String oldBank, java.lang.String newBank)
          Renames the specified bank with the new specified name.
static void setAccountCurrency(java.lang.String account, java.lang.String currency)
          Sets the specified currency of the specified account.
static void setBalance(java.lang.String account, double balance)
          Sets the balance of the specified player.
static void setBalance(java.lang.String bank, java.lang.String account, double balance)
          Returns the balance of the specified account in the specified bank.
static void setExternalBalance(java.lang.String account, double balance)
          Sets the specified account's balance to the specified amount.
static void subtract(java.lang.String account, double amount)
          Subtracts the specified amount from specified account.
static void subtract(java.lang.String bank, java.lang.String account, double amount)
          Subtracts the specified amount from the specified account's balance in the specified bank.
static void transfer(java.lang.String accountFrom, java.lang.String accountTo, double amount)
          The specified amount is added to the specified FROM account and subtracted from the specified TO account.
static void transfer(java.lang.String bankFrom, java.lang.String accountFrom, java.lang.String bankTo, java.lang.String accountTo, double amount)
          The specified amount is added to the specified FROM account and subtracted from the specified TO account in their respective banks.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MCCom

public MCCom()
Method Detail

getAccount

public static java.lang.String getAccount(java.lang.String account)
Returns account from case-insensitive alias

Parameters:
account -
Returns:
Account name

getBalance

public static double getBalance(java.lang.String account)
Returns the balance of the specified player.

Parameters:
account -
Returns:
double
Throws:
NoAccountException

setBalance

public static void setBalance(java.lang.String account,
                              double balance)
Sets the balance of the specified player.

Parameters:
account -
balance -
Throws:
NoAccountException
MaxDebtException

exists

public static boolean exists(java.lang.String account)
Returns true if specified player has an account.

Parameters:
account -
Returns:
boolean

canAfford

public static boolean canAfford(java.lang.String account,
                                double amount)
Returns true if specified player has specified amount in their account.

Parameters:
account -
amount -
Returns:
boolean
Throws:
NoAccountException

add

public static void add(java.lang.String account,
                       double amount)
Adds the specified amount to specified account.

Parameters:
account -
amount -
Throws:
NoAccountException

subtract

public static void subtract(java.lang.String account,
                            double amount)
Subtracts the specified amount from specified account.

Parameters:
account -
amount -
Throws:
NoAccountException
InsufficientFundsException

multiply

public static void multiply(java.lang.String account,
                            double multiplier)
Multiplies the specified account by the specified multiplier.

Parameters:
account -
multiplier -
Throws:
NoAccountException
NaturalNumberException

divide

public static void divide(java.lang.String account,
                          double divisor)
Divides the specified account by the specified divisor.

Parameters:
account -
divisor -
Throws:
NoAccountException
NaturalNumberException
InsufficientFundsException

empty

public static void empty(java.lang.String account)
Sets the specified account's balance to 0.

Parameters:
account -
Throws:
NoAccountException

create

public static void create(java.lang.String account)
Creates a new account with the specified name.

Parameters:
account -
Throws:
AccountNameConflictException

delete

public static void delete(java.lang.String account)
Deletes an existing account with the specified name.

Parameters:
account -
Throws:
NoAccountException

rename

public static void rename(java.lang.String account,
                          java.lang.String newAccount)
Renames an existing account with the specified name.

Parameters:
account -
newAccount -
Throws:
NoAccountException
AccountNameConflictException

transfer

public static void transfer(java.lang.String accountFrom,
                            java.lang.String accountTo,
                            double amount)
The specified amount is added to the specified FROM account and subtracted from the specified TO account.

Parameters:
accountFrom -
accountTo -
amount -
Throws:
NoAccountException
InsufficientFundsException

getAccounts

public static java.util.ArrayList<java.lang.String> getAccounts()
Gets an ArrayList with all MineConomy accounts.

Returns:
An ArrayList of MineConomy Accounts

getAccountCurrency

public static java.lang.String getAccountCurrency(java.lang.String account)
Gets the currency of the specified account.

Parameters:
account -
Returns:
currency
Throws:
NoAccountException

setAccountCurrency

public static void setAccountCurrency(java.lang.String account,
                                      java.lang.String currency)
Sets the specified currency of the specified account.

Parameters:
account -
currency -
Throws:
NoAccountException
NoCurrencyException

getDefaultCurrency

public static java.lang.String getDefaultCurrency()
Returns the default currency.

Parameters:
account -
Returns:
The default currency.

currencyExists

public static boolean currencyExists(java.lang.String currency)
Returns true if the specified currency exists.

Parameters:
currency -
Returns:
True if the specified currency exists.

getCurrencyId

public static java.lang.String getCurrencyId(java.lang.String currency)
Gets the ID of the specified currency.

Parameters:
currency -
Returns:
The ID of the specified currency.

getCurrencyById

public static java.lang.String getCurrencyById(java.lang.String id)
Gets the currency with the specified ID.

Parameters:
id -
Returns:
The currency with the specified ID.

idExists

public static boolean idExists(java.lang.String id)
Returns true if the specified ID exists.

Parameters:
id -
Returns:
True if the specified ID exists.

physicalCurrencyExists

public static boolean physicalCurrencyExists(java.lang.String currency)
Returns true if the specified physical currency exists.

Parameters:
currency -
Returns:
True is specified physical currency exists.

getCurrency

public static java.lang.String getCurrency(java.lang.String account)
Returns the currency used by an account.

Parameters:
account -
Returns:
Currency name
Throws:
NoAccountException

getCurrencyValue

public static double getCurrencyValue(java.lang.String currency)
Returns the specified currency's value.

Parameters:
currency -
Returns:
Currency value
Throws:
NoCurrencyException

getPhysicalCurrencyValue

public static double getPhysicalCurrencyValue(java.lang.String currency)
Returns the specified physical currency's value.

Parameters:
currency -
Returns:
Currency value
Throws:
NoCurrencyException

getBalance

public static double getBalance(java.lang.String bank,
                                java.lang.String account)
Returns the balance of the specified account in the specified bank.

Parameters:
bank -
account -
Returns:
balance
Throws:
NoAccountException
NoBankException

setBalance

public static void setBalance(java.lang.String bank,
                              java.lang.String account,
                              double balance)
Returns the balance of the specified account in the specified bank.

Parameters:
bank -
account -
balance -
Throws:
NoAccountException
NoBankException
MaxDebtException

accountExists

public static boolean accountExists(java.lang.String bank,
                                    java.lang.String account)
Returns true if the specified account exists in the specified bank.

Parameters:
bank -
account -
Returns:
True if the specified account exists in the specified bank.

bankExists

public static boolean bankExists(java.lang.String bank)
Returns true if the specified bank exists.

Parameters:
bank -
Returns:
boolean

canAfford

public static boolean canAfford(java.lang.String bank,
                                java.lang.String account,
                                double amount)
Returns true if the specified account in the specified bank has the specified amount in their account.

Parameters:
bank -
account -
amount -
Returns:
boolean
Throws:
NoAccountException
NoBankException

create

public static void create(java.lang.String bank,
                          java.lang.String account)
Creates an account with the specified name in the specified bank.

Parameters:
bank -
account -
Throws:
AccountNameConflictException

createBank

public static void createBank(java.lang.String bank)
Creates a bank with the specified name.

Parameters:
bank -
Throws:
BankNameConflictException

delete

public static void delete(java.lang.String bank,
                          java.lang.String account)
Deletes the account with the specified name in the specified bank.

Parameters:
bank -
account -
Throws:
NoAccountException

deleteBank

public static void deleteBank(java.lang.String bank)
Deletes the bank with the specified name.

Parameters:
bank -
Throws:
NoBankException

empty

public static void empty(java.lang.String bank,
                         java.lang.String account)
Sets the specified account's balance, in the specified bank, to 0.

Parameters:
bank -
account -
Throws:
NoBankException
NoAccountException

rename

public static void rename(java.lang.String oldBank,
                          java.lang.String oldAccount,
                          java.lang.String newBank,
                          java.lang.String newAccount)
Renames the specified account in the respective bank to the new account name in its respective bank.

Parameters:
oldBank -
oldAccount -
newBank -
newAccount -
Throws:
NoBankException
NoAccountException
AccountNameConflictException

renameBank

public static void renameBank(java.lang.String oldBank,
                              java.lang.String newBank)
Renames the specified bank with the new specified name.

Parameters:
oldBank -
newBank -
Throws:
NoBankException
BankNameConflictException

transfer

public static void transfer(java.lang.String bankFrom,
                            java.lang.String accountFrom,
                            java.lang.String bankTo,
                            java.lang.String accountTo,
                            double amount)
The specified amount is added to the specified FROM account and subtracted from the specified TO account in their respective banks.

Parameters:
bankFrom -
accountFrom -
bankTo -
accountTo -
amount -
Throws:
NoBankException
NoAccountException
InsufficientFundsException

add

public static void add(java.lang.String bank,
                       java.lang.String account,
                       double amount)
Adds the specified amount to the specified account's balance in the specified bank.

Parameters:
bank -
account -
amount -
Throws:
NoBankException
NoAccountException

subtract

public static void subtract(java.lang.String bank,
                            java.lang.String account,
                            double amount)
Subtracts the specified amount from the specified account's balance in the specified bank.

Parameters:
bank -
account -
amount -
Throws:
NoBankException
NoAccountException
InsufficientFundsException

multiply

public static void multiply(java.lang.String bank,
                            java.lang.String account,
                            double multiplier)
Multiplies the specified account's balance with the specified multiplier in the specified bank.

Parameters:
bank -
account -
multiplier -
Throws:
NoBankException
NoAccountException

divide

public static void divide(java.lang.String bank,
                          java.lang.String account,
                          double divisor)
Divides the specified account's balance with the specified divisor in the specified bank.

Parameters:
bank -
account -
divisor -
Throws:
NoBankException
NoAccountException
InsufficientFundsException

getBanks

public static java.util.ArrayList<java.lang.String> getBanks()
Returns a list of all existing banks.

Returns:
All banks

canExternalAfford

public static boolean canExternalAfford(java.lang.String account,
                                        double amount)
Returns true if the specified account has at least the specified amount. (Currencies are converted.)

Parameters:
account -
amount -
Returns:
True if the specified account has at least the specified amount.

getExternalBalance

public static double getExternalBalance(java.lang.String account)
Returns the balance of the specified account. (Currencies are converted.)

Parameters:
account -
Returns:
Balance

setExternalBalance

public static void setExternalBalance(java.lang.String account,
                                      double balance)
Sets the specified account's balance to the specified amount. (Currencies are converted.)

Parameters:
account -
balance -

getAccounting

public static AccountingBase getAccounting()
Returns instance of accounting class to use.

Returns:
Accounting class

initialize

public static void initialize()
Initializes MCCom base classes. (Required for SQL)


getName

public static java.lang.String getName()
Returns the name of MineConomy.

Returns:
name

getVersion

public static java.lang.String getVersion()
Returns the current version of MineConomy.

Returns:
version

getPlugin

public static org.bukkit.plugin.java.JavaPlugin getPlugin()
Returns the MineConomy plugin.

Returns:
MineConomy