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 Context s. |
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 Context s. |
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 Context s. |
default Map<Currency,TransactionResult> |
resetBalances(Cause cause)
Resets the balances for all
Currency s 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
Currency s used on this account
to their default values (getDefaultBalance(Currency) ),
using the specified Context s. |
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, getIdentifier
Text 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 Context
s 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 Context
s.
If this method returns false
, then
getDefaultBalance(Currency)
will be used when
retrieving a balance for the specified Currency
with
the specified Context
s.
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 Context
s.
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
Context
s 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 Context
s.
Amounts may differ depending on the Context
s specified and
the implementation. The set of Context
s 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 Context
s 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 Context
s specified and
the implementation. The set of Context
s 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)
Currency
s used on this account
to their default values (getDefaultBalance(Currency)
),
using the specified Context
s.cause
- The Cause
for the transactioncontexts
- the Context
s 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)
Currency
s 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 Context
s.default TransactionResult resetBalance(Currency currency, Cause cause)
Currency
to its default
value (getDefaultBalance(Currency)
),
using the current active Context
s.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 Context
s.
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 Currency
cause
- The Cause
for the transactioncontexts
- The Context
s 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 Context
s.
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 Currency
cause
- The Cause
for the transactionTransferResult
representative of the effects of the
operation