public interface Account extends Contextual
currencies.
Accounts come in two varieties: user accounts
and VirtualAccount virtual accounts.
Unique accounts are bound to a UUID, usually of a particular
User's GameProfile.
Virtual accounts are identified by a String identifier, which may have any
value. They are not tied to any Entity, player or otherwise. Virtual
accounts may be used for purposes such as bank accounts, non-player
Entity accounts, or other things.
| Modifier and Type | Method and Description |
|---|---|
default TransactionResult |
deposit(Currency currency,
BigDecimal amount,
Cause cause)
|
TransactionResult |
deposit(Currency currency,
BigDecimal amount,
Cause cause,
Set<Context> contexts)
|
default BigDecimal |
getBalance(Currency currency)
Returns a
BigDecimal representative of the balance stored
within this Account for the Currency given, with
the current active contexts. |
BigDecimal |
getBalance(Currency currency,
Set<Context> contexts)
Returns a
BigDecimal representative of the balance stored within this
Account for the Currency given and the set of Contexts. |
default Map<Currency,BigDecimal> |
getBalances()
|
Map<Currency,BigDecimal> |
getBalances(Set<Context> contexts)
|
BigDecimal |
getDefaultBalance(Currency currency)
Gets the default balance of this account for the specified
Currency. |
Text |
getDisplayName()
Gets the display name for this account.
|
default boolean |
hasBalance(Currency currency)
Returns whether this account has a set balance for the specified
Currency, with the current active contexts. |
boolean |
hasBalance(Currency currency,
Set<Context> contexts)
|
default TransactionResult |
resetBalance(Currency currency,
Cause cause)
Resets the balance for the specified
Currency to its default
value (getDefaultBalance(Currency)),
using the current active Contexts. |
TransactionResult |
resetBalance(Currency currency,
Cause cause,
Set<Context> contexts)
Resets the balance for the specified
Currency to its default
value (getDefaultBalance(Currency)), using
the specified Contexts. |
default Map<Currency,TransactionResult> |
resetBalances(Cause cause)
Resets the balances for all
Currencys used on this account to
their default values (getDefaultBalance(Currency)), using
the current active Context. |
Map<Currency,TransactionResult> |
resetBalances(Cause cause,
Set<Context> contexts)
Resets the balances for all
Currencys used on this account
to their default values (getDefaultBalance(Currency)),
using the specified Contexts. |
default TransactionResult |
setBalance(Currency currency,
BigDecimal amount,
Cause cause)
|
TransactionResult |
setBalance(Currency currency,
BigDecimal amount,
Cause cause,
Set<Context> contexts)
|
default TransferResult |
transfer(Account to,
Currency currency,
BigDecimal amount,
Cause cause)
|
TransferResult |
transfer(Account to,
Currency currency,
BigDecimal amount,
Cause cause,
Set<Context> contexts)
|
default TransactionResult |
withdraw(Currency currency,
BigDecimal amount,
Cause cause)
|
TransactionResult |
withdraw(Currency currency,
BigDecimal amount,
Cause cause,
Set<Context> contexts)
|
getActiveContexts, getFriendlyIdentifier, getIdentifierText getDisplayName()
This should be used by plugins to get a human-readable name for an
account, regardless of the specific type (UniqueAccount or
VirtualAccount).
Its contents are dependent on the provider of EconomyService.
For example, an economy plugin could allow players to configure the
display name of their account
BigDecimal getDefaultBalance(Currency currency)
Currency.
The default balance is used when the balance is retrieved for the
first time for a given Currency on this account, or if no
balance is available for the Contexts used when retrieving
a balance.
currency - the currency to get the default balance for.Currency.boolean hasBalance(Currency currency, Set<Context> contexts)
Currency, with the specified Contexts.
If this method returns false, then
getDefaultBalance(Currency) will be used when
retrieving a balance for the specified Currency with
the specified Contexts.
default boolean hasBalance(Currency currency)
Currency, with the current active contexts.
If this method returns false, then
getDefaultBalance(Currency) will be used when retrieving
a balance for the specifid Currency with
the current active contexts
BigDecimal getBalance(Currency currency, Set<Context> contexts)
BigDecimal representative of the balance stored within this
Account for the Currency given and the set of Contexts.
The default result when the account does not have a balance of the
given Currency will be getDefaultBalance(Currency).
The balance may be unavailable depending on the set of
Contexts used.
default BigDecimal getBalance(Currency currency)
BigDecimal representative of the balance stored
within this Account for the Currency given, with
the current active contexts.
The default result when the account does not have a balance of the
given Currency will be getDefaultBalance(Currency).
Map<Currency,BigDecimal> getBalances(Set<Context> contexts)
Map of all currently set balances the account holds
within the set of Contexts.
Amounts may differ depending on the Contexts specified and
the implementation. The set of Contexts may be empty.
Currency amounts which are 0 may or may not be included in
the returned mapping.
Changes to the returned Map will not be reflected in
the underlying Account. See
setBalance(Currency, BigDecimal, Cause, Set) to set values.
contexts - the set of Contexts to use with the
specified amountsMap of Currency to BigDecimal amounts
that this account holdsdefault Map<Currency,BigDecimal> getBalances()
Map of all currently set balances the account holds
within the current active Context.
Amounts may differ depending on the Contexts specified and
the implementation. The set of Contexts may be empty.
Currency amounts which are 0 may or may not be included in
the returned mapping.
Changes to the returned Map will not be reflected in
the underlying Account and may result in runtime exceptions
depending on implementation. See
setBalance(Currency, BigDecimal, Cause, Set) to set values.
Map of Currency to BigDecimal amounts
that this account holdsTransactionResult setBalance(Currency currency, BigDecimal amount, Cause cause, Set<Context> contexts)
default TransactionResult setBalance(Currency currency, BigDecimal amount, Cause cause)
Map<Currency,TransactionResult> resetBalances(Cause cause, Set<Context> contexts)
Currencys used on this account
to their default values (getDefaultBalance(Currency)),
using the specified Contexts.cause - The Cause for the transactioncontexts - the Contexts to use when resetting the balances.Currency to TransactionResult. Each
entry represents the result of resetting a particular currency.default Map<Currency,TransactionResult> resetBalances(Cause cause)
Currencys used on this account to
their default values (getDefaultBalance(Currency)), using
the current active Context.cause - The Cause for the transactionCurrency to TransactionResult. Each
entry represents the result of resetting a particular currencyTransactionResult resetBalance(Currency currency, Cause cause, Set<Context> contexts)
Currency to its default
value (getDefaultBalance(Currency)), using
the specified Contexts.default TransactionResult resetBalance(Currency currency, Cause cause)
Currency to its default
value (getDefaultBalance(Currency)),
using the current active Contexts.TransactionResult deposit(Currency currency, BigDecimal amount, Cause cause, Set<Context> contexts)
default TransactionResult deposit(Currency currency, BigDecimal amount, Cause cause)
TransactionResult withdraw(Currency currency, BigDecimal amount, Cause cause, Set<Context> contexts)
default TransactionResult withdraw(Currency currency, BigDecimal amount, Cause cause)
TransferResult transfer(Account to, Currency currency, BigDecimal amount, Cause cause, Set<Context> contexts)
Currency
from this account the destination account,
using the specified Contexts.
This operation is a merged withdraw(Currency, BigDecimal, Cause, Set)
from this account with a deposit(Currency, BigDecimal, Cause, Set)
into the specified account.
to - the Account to transfer the amounts to.currency - The Currency to transfer the specified amount foramount - The amount to transfer for the specified Currencycause - The Cause for the transactioncontexts - The Contexts to use with the
specified Currency and accountTransferResult representative of the effects of
the operationdefault TransferResult transfer(Account to, Currency currency, BigDecimal amount, Cause cause)
Currency
from this account the destination account,
using the current active Contexts.
This operation is a merged withdraw(Currency, BigDecimal, Cause, Set)
from this account with a deposit(Currency, BigDecimal, Cause, Set)
into the specified account.
to - the Account to transfer the amounts to.currency - The Currency to transfer the specified amount foramount - The amount to transfer for the specified Currencycause - The Cause for the transactionTransferResult representative of the effects of the
operation