Basisbegrippen

De Sponge Economy API heeft een paar basis componenten waarmee ontwikkelaars vertrouwd moeten zijn:

  • EconomyService

  • Currency

  • Accounts

  • Transactions

De Economie Service

The EconomyService is the basis of the Economy API. It is used to interact via the Economy API, stores an economy’s currencies and provides methods for account management.

Waarschuwing

Sponge does not provide a default implementation for the EconomyService. It’s completely up to plugins to implement the Economy API. This means that you have to rely on another plugin which implements the service or you’ll have to implement it yourself, if you want to make use of it.

Currency

The Currency object represents a form of Currency. Currency stores a display name (plural and singular), a symbol, the amount of fractional digits, and whether the currency is the default currency for the economy. If the economy plugin chooses, it can support multiple currencies.

Accounts

Accounts are used to store economy information about a specific player or other object (i.e. bank, business, entity). There are two account types in the Sponge Economy API:

Virtuele Accounts

Virtual accounts are tied to an identifier, which is stored as a string. Virtual accounts can be tied to almost anything, but are commonly used for things such as banks, or non-players. To get the id of a virtual account, use getIdentifier().

Unieke Accounts

Unique accounts are tied to a UUID, usually a player. To get the UUID of an unique account, use getUUID().

Transactions

Transactions represent an account’s change in balance. There are currently three types of transactions:

  • Deposit: Occurs when an account has funds added to it

  • Withdraw: Occurs when an account has funds removed from it

  • Transfer: Occurs when an account exchanges funds with another account

When a transfer occurs, the EconomyTransactionEvent is fired. Using this event, you can get the TransactionResult. The TransactionResult stores data about the transaction that occurred, including:

  • Account betrokken

  • Currency involved

  • Amount of currency involved

  • Transactie type

  • Resultaat van de transactie

U kunt alle mogelijke transactie resultaten bekijken op de pagina van de ‘ResultType’ JavaDocs :javadoc: .