Interface Account
- All Superinterfaces:
Contextual
- All Known Subinterfaces:
UniqueAccount
,VirtualAccount
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.
-
Method Summary
Modifier and TypeMethodDescriptiondefault BigDecimal
Returns aBigDecimal
representative of the balance stored within thisAccount
for theCurrency
given, with the current active cause.Returns aBigDecimal
representative of the balance stored within thisAccount
for theCurrency
given and the set ofContext
s.Returns aBigDecimal
representative of the balance stored within thisAccount
for theCurrency
given and the set ofContext
s.default Map
<Currency, BigDecimal> balances()
defaultBalance
(Currency currency) Gets the default balance of this account for the specifiedCurrency
.default TransactionResult
deposit
(Currency currency, BigDecimal amount) deposit
(Currency currency, BigDecimal amount, Set<Context> contexts) deposit
(Currency currency, BigDecimal amount, Cause cause) Gets the display name for this account.default boolean
hasBalance
(Currency currency) Returns whether this account has a set balance for the specifiedCurrency
, with the current active cause.boolean
hasBalance
(Currency currency, Set<Context> contexts) boolean
hasBalance
(Currency currency, Cause cause) default TransactionResult
resetBalance
(Currency currency) Resets the balance for the specifiedCurrency
to its default value (defaultBalance(Currency)
), using the current activeContext
s.resetBalance
(Currency currency, Set<Context> contexts) Resets the balance for the specifiedCurrency
to its default value (defaultBalance(Currency)
), using the specifiedContext
s.resetBalance
(Currency currency, Cause cause) Resets the balance for the specifiedCurrency
to its default value (defaultBalance(Currency)
), using context from the specifiedCause
.default Map
<Currency, TransactionResult> Resets the balances for allCurrency
s used on this account to their default values (defaultBalance(Currency)
), using the current activeContext
.resetBalances
(Set<Context> contexts) Resets the balances for allCurrency
s used on this account to their default values (defaultBalance(Currency)
), using the specifiedContext
s.resetBalances
(Cause cause) Resets the balances for allCurrency
s used on this account to their default values (defaultBalance(Currency)
), using the specifiedCause
s.default TransactionResult
setBalance
(Currency currency, BigDecimal amount) setBalance
(Currency currency, BigDecimal amount, Set<Context> contexts) setBalance
(Currency currency, BigDecimal amount, Cause cause) default TransferResult
transfer
(Account to, Currency currency, BigDecimal amount) transfer
(Account to, Currency currency, BigDecimal amount, Cause cause) default TransactionResult
withdraw
(Currency currency, BigDecimal amount) withdraw
(Currency currency, BigDecimal amount, Set<Context> contexts) withdraw
(Currency currency, BigDecimal amount, Cause cause) Methods inherited from interface org.spongepowered.api.service.context.Contextual
contextCause, friendlyIdentifier, identifier
-
Method Details
-
displayName
Component displayName()Gets the display name for this account.This should be used by plugins to get a human-readable name for an account, regardless of the specific type (
UniqueAccount
orVirtualAccount
).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- Returns:
- The display name for this account
-
defaultBalance
Gets the default balance of this account for the specifiedCurrency
.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 theContext
s used when retrieving a balance.- Parameters:
currency
- the currency to get the default balance for.- Returns:
- The default balance for the specified
Currency
.
-
hasBalance
Returns whether this account has a set balance for the specifiedCurrency
, with the specifiedContext
s.If this method returns
false
, thendefaultBalance(Currency)
will be used when retrieving a balance for the specifiedCurrency
with the specifiedContext
s. -
hasBalance
Returns whether this account has a set balance for the specifiedCurrency
, with context from the specifiedCause
s.If this method returns
false
, thendefaultBalance(Currency)
will be used when retrieving a balance for the specifiedCurrency
with the specifiedContext
s. -
hasBalance
Returns whether this account has a set balance for the specifiedCurrency
, with the current active cause.If this method returns
.false
, thendefaultBalance(Currency)
will be used when retrieving a balance for the specifidCurrency
with the current active cause -
balance
Returns aBigDecimal
representative of the balance stored within thisAccount
for theCurrency
given and the set ofContext
s.The default result when the account does not have a balance of the given
Currency
will bedefaultBalance(Currency)
.The balance may be unavailable depending on the set of
Context
s used. -
balance
Returns aBigDecimal
representative of the balance stored within thisAccount
for theCurrency
given and the set ofContext
s.The default result when the account does not have a balance of the given
Currency
will bedefaultBalance(Currency)
.The balance may be unavailable depending on the set of
Context
s used. -
balance
Returns aBigDecimal
representative of the balance stored within thisAccount
for theCurrency
given, with the current active cause.The default result when the account does not have a balance of the given
Currency
will bedefaultBalance(Currency)
. -
balances
Returns aMap
of all currently set balances the account holds within the set ofContext
s.Amounts may differ depending on the
Context
s specified and the implementation. The set ofContext
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 underlyingAccount
. SeesetBalance(Currency, BigDecimal, Cause)
to set values.- Parameters:
contexts
- the set ofContext
s to use with the specified amounts- Returns:
- A
Map
ofCurrency
toBigDecimal
amounts that this account holds
-
balances
Returns aMap
of all currently set balances the account holds within the set ofContext
s.Amounts may differ depending on the
Cause
specified and the implementation. The set ofContext
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 underlyingAccount
. SeesetBalance(Currency, BigDecimal, Cause)
to set values.- Parameters:
cause
- the set ofContext
s to use with the specified amounts- Returns:
- A
Map
ofCurrency
toBigDecimal
amounts that this account holds
-
balances
Returns aMap
of all currently set balances the account holds within the current activeContext
.Amounts may differ depending on the
Context
s specified and the implementation. The set ofContext
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 underlyingAccount
and may result in runtime exceptions depending on implementation. SeesetBalance(Currency, BigDecimal, Cause)
to set values.- Returns:
- A
Map
ofCurrency
toBigDecimal
amounts that this account holds
-
setBalance
-
setBalance
-
setBalance
-
resetBalances
Resets the balances for allCurrency
s used on this account to their default values (defaultBalance(Currency)
), using the specifiedContext
s.- Parameters:
contexts
- theContext
s to use when resetting the balances.- Returns:
- A map of
Currency
toTransactionResult
. Each entry represents the result of resetting a particular currency.
-
resetBalances
Resets the balances for allCurrency
s used on this account to their default values (defaultBalance(Currency)
), using the specifiedCause
s.- Parameters:
cause
- the cause to computer context to use when resetting the balances.- Returns:
- A map of
Currency
toTransactionResult
. Each entry represents the result of resetting a particular currency.
-
resetBalances
Resets the balances for allCurrency
s used on this account to their default values (defaultBalance(Currency)
), using the current activeContext
.- Returns:
- A map of
Currency
toTransactionResult
. Each entry represents the result of resetting a particular currency
-
resetBalance
Resets the balance for the specifiedCurrency
to its default value (defaultBalance(Currency)
), using the specifiedContext
s. -
resetBalance
Resets the balance for the specifiedCurrency
to its default value (defaultBalance(Currency)
), using context from the specifiedCause
.- Parameters:
currency
- TheCurrency
to reset the balance forcause
- The cause to use to compute context when resetting the balance- Returns:
- The result of the transaction
-
resetBalance
Resets the balance for the specifiedCurrency
to its default value (defaultBalance(Currency)
), using the current activeContext
s.- Parameters:
currency
- TheCurrency
to reset the balance for- Returns:
- The result of the transaction
-
deposit
-
deposit
-
deposit
-
withdraw
-
withdraw
-
withdraw
-
transfer
Transfers the specified amount of the specifiedCurrency
from this account the destination account, using the specifiedContext
s.This operation is a merged
withdraw(Currency, BigDecimal, Cause)
from this account with adeposit(Currency, BigDecimal, Cause)
into the specified account.- Parameters:
to
- the Account to transfer the amounts to.currency
- TheCurrency
to transfer the specified amount foramount
- The amount to transfer for the specifiedCurrency
contexts
- TheContext
s to use with the specifiedCurrency
and account- Returns:
- A
TransferResult
representative of the effects of the operation
-
transfer
Transfers the specified amount of the specifiedCurrency
from this account the destination account, using the specifiedCause
.This operation is a merged
withdraw(Currency, BigDecimal, Cause)
from this account with adeposit(Currency, BigDecimal, Cause)
into the specified account.- Parameters:
to
- the Account to transfer the amounts to.currency
- TheCurrency
to transfer the specified amount foramount
- The amount to transfer for the specifiedCurrency
cause
- The cause to use with the specifiedCurrency
and account- Returns:
- A
TransferResult
representative of the effects of the operation
-
transfer
Transfers the specified amount of the specifiedCurrency
from this account the destination account, using the current activeContext
s.This operation is a merged
withdraw(Currency, BigDecimal, Cause)
from this account with adeposit(Currency, BigDecimal, Cause)
into the specified account.- Parameters:
to
- the Account to transfer the amounts to.currency
- TheCurrency
to transfer the specified amount foramount
- The amount to transfer for the specifiedCurrency
- Returns:
- A
TransferResult
representative of the effects of the operation
-