-
Notifications
You must be signed in to change notification settings - Fork 0
Developer API
This page introduces the Coffers developer API and explains how plugin authors can integrate directly with Coffers.
Coffers includes a separate developer jar:
Coffers-API.jar
This jar is intended for plugin developers who want direct access to Coffers types and economy behavior.
It is not intended to be installed as the main server economy plugin by itself.
Direct Coffers integration gives plugin developers a richer foundation than relying only on Vault-style balance access.
Benefits include:
- direct currency definitions
- transaction results
- ledger history access
- transaction actor metadata
- richer failure reporting
- a cleaner economy-oriented API surface
Vault compatibility is still useful for legacy support, but the Coffers API is the better long-term integration target for Coffers-aware plugins.
The main API entry point is:
CoffersEconomy
This interface provides methods for:
- discovering currencies
- checking balances
- creating accounts
- depositing funds
- withdrawing funds
- transferring funds
- setting balances
- reading recent transactions
- formatting balances for display
The current API includes the following main types:
CoffersEconomyCurrencyDefinitionCurrencyFormatAccountSnapshotTransactionResultTransactionFailureTransactionKindTransactionActorTransactionActorTypeLedgerEntry
The CoffersEconomy interface is the main service contract.
Key capabilities include:
defaultCurrencyId()currencies()currency(String currencyId)hasAccount(UUID accountId)createAccount(UUID accountId)account(UUID accountId, String currencyId)getBalance(UUID accountId, String currencyId)deposit(...)withdraw(...)transfer(...)setBalance(...)recentTransactions(UUID accountId, int limit)format(String currencyId, BigDecimal amount)
The interface also includes convenience defaults for:
- default currency name access
- default currency symbol access
- default fractional digit access
- simplified balance, deposit, withdraw, transfer, and set-balance operations
CurrencyDefinition describes a configured currency.
It includes:
- currency ID
- singular name
- plural name
- symbol
- fractional digits
- starting balance
- formatting rules
This allows plugins to understand not just a balance number, but how a currency is actually defined and displayed.
CurrencyFormat controls how balances are displayed.
It includes options for:
- symbol placement
- spacing
- grouping separators
- trailing zero behavior
This helps other plugins keep their Coffers-related displays consistent with the server's configured economy presentation.
AccountSnapshot provides a lightweight account state view.
It includes:
- account UUID
- currency ID
- current balance
This is useful when a plugin wants a simple account read without requesting a full transaction flow.
TransactionResult is returned by balance-changing operations.
It includes:
- whether the action succeeded
- currency ID
- amount involved
- resulting balance
- failure type
- message
- related ledger entry when available
This is much richer than a simple true or false response.
TransactionFailure describes why a transaction failed.
Current values include:
NONEINVALID_AMOUNTINSUFFICIENT_FUNDS
This allows plugin developers to react more intelligently to failed transactions.
TransactionKind describes the type of ledger action.
Current values include:
DEPOSITWITHDRAWALTRANSFER_INTRANSFER_OUTSET
This is especially useful for plugins that want to inspect or present transaction history.
TransactionActor records who or what caused a transaction.
It includes:
- actor type
- actor UUID when available
- actor name
- source string
Factory helpers currently include:
- system
- console
- player
- plugin
- migration
- vault
This gives Coffers integrations better audit detail than a balance-only API.
TransactionActorType identifies the source category behind a transaction.
This allows plugin authors to distinguish, for example:
- player-driven changes
- console-driven changes
- migration actions
- Vault-triggered operations
LedgerEntry represents an individual recorded transaction entry.
It includes:
- entry ID
- reference ID
- account ID
- counterparty account ID
- currency ID
- transaction kind
- amount
- resulting balance
- actor metadata
- reason
- timestamp
This allows richer logging, auditing, and future plugin workflows than a simple current-balance-only model.
A Coffers-aware plugin will usually:
- obtain the
CoffersEconomyservice - discover the currency it wants to use
- read balances or account state
- perform a deposit, withdrawal, transfer, or set operation
- inspect the returned
TransactionResult
This is a more expressive flow than simply calling Vault and getting a yes or no answer.
Use the Coffers API when:
- you want direct Coffers-aware integration
- you need richer result objects
- you need audit or ledger data
- you care about multi-currency behavior
- you want future Coffers-native integration support
Use Vault compatibility when:
- you are supporting legacy plugin ecosystems
- you are integrating with general economy plugins rather than Coffers specifically
- you only need broad compatibility with existing Vault-based systems
Keep in mind:
- Vault compatibility is centered on the default Coffers currency
- Coffers-native integrations are the better path for richer features
-
Coffers-API.jaris for developers, not normal server owners - the API is currently intended to be version-matched with the Coffers release you are targeting
For plugin authors building directly for Coffers:
- prefer direct Coffers API integration
- use
TransactionResultinstead of assuming success - use
CurrencyDefinitionandCurrencyFormatinstead of hardcoding display rules - use
LedgerEntryand actor metadata if your plugin needs history or audit awareness
The Coffers API is designed to provide a stronger plugin integration foundation than the older balance-only patterns common in Vault-first designs.
It gives developers:
- richer data
- clearer transaction outcomes
- better metadata
- stronger alignment with Coffers-native features