Package com.patelheet.capitalengine.api
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 Summary
Modifier and TypeMethodDescriptionaccounts()Account lookup and creation.voidRaises an alert for owners.The running API version, for example"1.0.0".Player (or other account) → Treasury.currency()The currency.Destroys coins:from→ Mint.findByReference(org.bukkit.plugin.Plugin caller, String reference) Finds this plugin's transaction by its reference, for crash recovery.An account's transactions, newest first.booleanisCompatible(String minVersion) Whether the running API is at leastminVersion(semantic versioning).Creates coins: Mint →to.The registeredMonetaryPolicyservice with the highest priority, if any.policy(org.bukkit.plugin.Plugin caller) The caller's remaining limits today.Pays from the server: Treasury first, newly created coins for any shortfall, within the caller's limits.stats()Instant economy-wide snapshot.transaction(org.bukkit.plugin.Plugin caller, String type, String memo) Starts a multi-leg transaction.transfer(org.bukkit.plugin.Plugin caller, Account from, Account to, long amount, String type, String memo) Moves coins between two accounts.treasury()The server's wallet.
-
Method Details
-
apiVersion
String apiVersion()The running API version, for example"1.0.0". -
isCompatible
Whether the running API is at leastminVersion(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.memois 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
Starts a multi-leg transaction. Use this whenever you need areference. -
findByReference
CompletableFuture<Optional<TxRecord>> findByReference(org.bukkit.plugin.Plugin caller, String reference) Finds this plugin's transaction by its reference, for crash recovery. -
history
An account's transactions, newest first. PassLong.MAX_VALUEasbeforeTxIdfor the first page. -
stats
Stats stats()Instant economy-wide snapshot. -
policy
The caller's remaining limits today. -
monetaryPolicy
Optional<MonetaryPolicy> monetaryPolicy()The registeredMonetaryPolicyservice with the highest priority, if any. -
alert
Raises an alert for owners. FiresCapitalAlertEventsafely from any thread.
-