Interface CapitalApi


public interface CapitalApi
Entry point of the CapitalEngine API. Obtain it from Bukkit's ServicesManager:
CapitalApi api = Bukkit.getServicesManager().load(CapitalApi.class);

Amounts are long counts of the smallest unit and must be greater than 0. Every mutation is atomic, attributed to the calling plugin and checked against the owner's limits. Balance changes are visible to every reader as soon as the call returns; the future completes once the transaction is in the database, on a core thread (switch to the main/region thread before touching Bukkit objects, and never block on it). Failures are values (TxResult), not exceptions.

  • Method Details

    • apiVersion

      String apiVersion()
      The running API version, for example "1.0.0".
    • isCompatible

      boolean isCompatible(String minVersion)
      Whether the running API is at least minVersion (semantic versioning).
    • accounts

      Accounts accounts()
      Account lookup and creation.
    • treasury

      Account treasury()
      The server's wallet.
    • currency

      Currency currency()
      The currency.
    • transfer

      CompletableFuture<TxResult> transfer(org.bukkit.plugin.Plugin caller, Account from, Account to, long amount, String type, String memo)
      Moves coins between two accounts. memo is up to 128 characters and shown to players.
    • serverPay

      CompletableFuture<TxResult> serverPay(org.bukkit.plugin.Plugin caller, Account to, long amount, String type, String memo)
      Pays from the server: Treasury first, newly created coins for any shortfall, within the caller's limits.
    • collect

      CompletableFuture<TxResult> collect(org.bukkit.plugin.Plugin caller, Account from, long amount, String type, String memo)
      Player (or other account) → Treasury.
    • issue

      CompletableFuture<TxResult> issue(org.bukkit.plugin.Plugin caller, Account to, long amount, String type, String memo)
      Creates coins: Mint → to.
    • destroy

      CompletableFuture<TxResult> destroy(org.bukkit.plugin.Plugin caller, Account from, long amount, String type, String memo)
      Destroys coins: from → Mint.
    • transaction

      TransactionBuilder transaction(org.bukkit.plugin.Plugin caller, String type, String memo)
      Starts a multi-leg transaction. Use this whenever you need a reference.
    • findByReference

      CompletableFuture<Optional<TxRecord>> findByReference(org.bukkit.plugin.Plugin caller, String reference)
      Finds this plugin's transaction by its reference, for crash recovery.
    • history

      CompletableFuture<List<TxRecord>> history(Account account, int limit, long beforeTxId)
      An account's transactions, newest first. Pass Long.MAX_VALUE as beforeTxId for the first page.
    • stats

      Stats stats()
      Instant economy-wide snapshot.
    • policy

      PolicyStatus policy(org.bukkit.plugin.Plugin caller)
      The caller's remaining limits today.
    • monetaryPolicy

      Optional<MonetaryPolicy> monetaryPolicy()
      The registered MonetaryPolicy service with the highest priority, if any.
    • alert

      void alert(org.bukkit.plugin.Plugin source, Severity severity, String code, String message)
      Raises an alert for owners. Fires CapitalAlertEvent safely from any thread.