package com.nijikokun.register.payment.forChestShop; import org.bukkit.plugin.Plugin; /** * Interface to be implemented by a payment method. * * @author Nijikokun (@nijikokun) * @copyright Copyright (C) 2011 * @license AOL license */ public interface Method { /** * Encodes the Plugin into an Object disguised as the Plugin. * If you want the original Plugin Class you must cast it to the correct * Plugin, to do so you have to verify the name and or version then cast. *

*

     *  if(method.getName().equalsIgnoreCase("iConomy"))
     *   iConomy plugin = ((iConomy)method.getPlugin());
* * @return Object * @see #getName() * @see #getVersion() */ Object getPlugin(); /** * Returns the actual name of this method. * * @return String Plugin name. */ String getName(); /** * Returns the actual version of this method. * * @return String Plugin version. */ String getVersion(); /** * Returns the amount of decimal places that get stored * NOTE: it will return -1 if there is no rounding * * @return int for each decimal place */ int fractionalDigits(); /** * Formats amounts into this payment methods style of currency display. * * @param amount Double * @return String - Formatted Currency Display. */ String format(double amount); /** * Allows the verification of bank API existence in this payment method. * * @return boolean */ boolean hasBanks(); /** * Determines the existence of a bank via name. * * @param bank Bank name * @return boolean * @see #hasBanks */ boolean hasBank(String bank); /** * Determines the existence of an account via name. * * @param name Account name * @return boolean */ boolean hasAccount(String name); /** * Check to see if an account name is tied to a bank. * * @param bank Bank name * @param name Account name * @return boolean */ boolean hasBankAccount(String bank, String name); /** * Forces an account creation * * @param name Account name * @return boolean */ boolean createAccount(String name); /** * Forces an account creation * * @param name Account name * @param balance Initial account balance * @return boolean */ boolean createAccount(String name, double balance); /** * Returns a MethodAccount class for an account name. * * @param name Account name * @return MethodAccount or Null */ MethodAccount getAccount(String name); /** * Returns a MethodBankAccount class for an account name. * * @param bank Bank name * @param name Account name * @return MethodBankAccount or Null */ MethodBankAccount getBankAccount(String bank, String name); /** * Checks to verify the compatibility between this Method and a plugin. * Internal usage only, for the most part. * * @param plugin Plugin * @return boolean */ boolean isCompatible(Plugin plugin); /** * Set Plugin data. * * @param plugin Plugin */ void setPlugin(Plugin plugin); /** * Contains Calculator and Balance functions for Accounts. */ interface MethodAccount { double balance(); boolean set(double amount); boolean add(double amount); boolean subtract(double amount); boolean multiply(double amount); boolean divide(double amount); boolean hasEnough(double amount); boolean hasOver(double amount); boolean hasUnder(double amount); boolean isNegative(); boolean remove(); } /** * Contains Calculator and Balance functions for Bank Accounts. */ interface MethodBankAccount extends MethodAccount { String getBankName(); int getBankId(); } }