Grundkonzept
Die Sponge Economy API hat ein paar grundlegende Komponenten, mit denen Entwickler vertraut sein sollten:
EconomyService
Währung
Konten
Transaktionen
Der EconomyService
Der EconomyService ist die Basis der Economy API. Dieser wird verwendet um mit der Economy API zu interagieren, speichert zudem die dazugehörigen Währungen und bietet Methoden zum Account-Management an.
Warnung
Sponge stellt keine Standardimplementierung für den``EconomyService`` bereit. Es liegt an den Plugins selbst, die ‚Economy API‘ zu implementieren. Das heißt, dass du ein anderes Plugin brauchst, das diesen Service implementiert, oder dass du die ‚Economy API‘ selbst implementieren musst, wenn du von ihr Gebrauch machen möchtest.
Währung
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.
Konten
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:
Virtuelle Konten
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()
.
Einzigartige Konten
Unique accounts are tied to a UUID, usually a player. To get the UUID of an unique account, use getUUID()
.
Transaktionen
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 involved
Currency involved
Amount of currency involved
Art der Transaktion
Ergebnis der Transaktion
You can view all possible transaction results on the ResultType JavaDocs page.