Class BankUtils

java.lang.Object
nl.minetopiasdb.api.banking.BankUtils

public class BankUtils extends Object
General utility class for banking
  • Constructor Details

    • BankUtils

      public BankUtils()
  • Method Details

    • getInstance

      public static BankUtils getInstance()
      Get an instance of BankUtils
      Returns:
      instance of BankUtils
    • getBankAccount

      public Bankaccount getBankAccount(int id)
      Get a bankaccount object from the cache. Can be run synchronously without any issues.
      Parameters:
      id - id of the bankaccount
      Returns:
      bankaccount object for given ID
    • getAccounts

      public List<Bankaccount> getAccounts(BankAccountType... accountTypes)
      Get a list of bankaccounts with specific type(s)
      Parameters:
      accountTypes - bank account types
      Returns:
      list of all bankaccounts with provided type
    • getAccounts

      public List<Bankaccount> getAccounts(UUID uuid)
      Get a list of bankaccounts where this user is authorised.
      Parameters:
      uuid - uuid of given player
      Returns:
      List of Bankaccounts where given player is authorised.
    • getAccounts

      public List<Bankaccount> getAccounts(UUID uuid, BankAccountType... accountTypes)
      Get a list of bankaccounts where this user is authorised of a specific BankAccountType.
      Parameters:
      uuid - uuid of given player
      accountTypes - BankAccountType(s) to be looked for
      Returns:
      List of Bankaccounts of the specified type where given player is authorised.
    • pullCache

      public void pullCache()
      Update the bankaccount cache.
    • toDatabase

      public void toDatabase()
      Push all the changes to the database.
    • clearCache

      public void clearCache()
      Clear the bankaccount cache but leave it empty. Don't use this without a good reason, or all the players will freak out because they think their bankaccounts are gone.
    • format

      public String format(double number)
      Properly format a double to a money string.
      Parameters:
      number - number that needs to be formatted.
      Returns:
      formatted money string
    • create

      public int create(BankAccountType type) throws IllegalArgumentException
      Create a bankaccount of the given type. BankAccountType.PERSONAL will not work!
      Parameters:
      type - bankaccounttype that needs to be created.
      Returns:
      ID of the created bankaccount.
      Throws:
      IllegalArgumentException - when type is BankAccountType.PERSONAL
    • delete

      public void delete(int id)
      Delete the bankaccount with the provided ID.
      Parameters:
      id - bankaccount that needs to be deleted.
    • silentlyCreateBankaccount

      public void silentlyCreateBankaccount(int id, BankAccountType type)
      Silently create a bankaccount without communicating it through the messagechannels. This method is for internal use only.
      Parameters:
      id - bank account type
      type - bankaccount type
    • silentlyDeleteBankaccount

      public void silentlyDeleteBankaccount(int id)
      Silently delete a bankaccount without communicating it through the messagechannels. This method is for internal use only.
      Parameters:
      id - bank account type
    • getSlots

      public int getSlots(int accounts)
      Get the amount of slots used in the selector with provided amount of accounts.
      Parameters:
      accounts - amount of accounts that need to fit.
      Returns:
      inventory size