Class BankUtils
java.lang.Object
nl.minetopiasdb.api.banking.BankUtils
General utility class for banking
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClear the bankaccount cache but leave it empty.intcreate(BankAccountType type) Create a bankaccount of the given type.voiddelete(int id) Delete the bankaccount with the provided ID.format(double number) Properly format a double to a money string.getAccounts(UUID uuid) Get a list of bankaccounts where this user is authorised.getAccounts(UUID uuid, BankAccountType... accountTypes) Get a list of bankaccounts where this user is authorised of a specificBankAccountType.getAccounts(BankAccountType... accountTypes) Get a list of bankaccounts with specific type(s)getBankAccount(int id) Get a bankaccount object from the cache.static BankUtilsGet an instance of BankUtilsintgetSlots(int accounts) Get the amount of slots used in the selector with provided amount of accounts.voidUpdate the bankaccount cache.voidsilentlyCreateBankaccount(int id, BankAccountType type) Silently create a bankaccount without communicating it through the messagechannels.voidsilentlyDeleteBankaccount(int id) Silently delete a bankaccount without communicating it through the messagechannels.voidPush all the changes to the database.
-
Constructor Details
-
BankUtils
public BankUtils()
-
-
Method Details
-
getInstance
-
getBankAccount
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
Get a list of bankaccounts with specific type(s)- Parameters:
accountTypes- bank account types- Returns:
- list of all bankaccounts with provided type
-
getAccounts
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
Get a list of bankaccounts where this user is authorised of a specificBankAccountType.- Parameters:
uuid- uuid of given playeraccountTypes- 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
Properly format a double to a money string.- Parameters:
number- number that needs to be formatted.- Returns:
- formatted money string
-
create
Create a bankaccount of the given type.BankAccountType.PERSONALwill not work!- Parameters:
type- bankaccounttype that needs to be created.- Returns:
- ID of the created bankaccount.
- Throws:
IllegalArgumentException- when type isBankAccountType.PERSONAL
-
delete
public void delete(int id) Delete the bankaccount with the provided ID.- Parameters:
id- bankaccount that needs to be deleted.
-
silentlyCreateBankaccount
Silently create a bankaccount without communicating it through the messagechannels. This method is for internal use only.- Parameters:
id- bank account typetype- 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
-