← TNE overview · Java API guides
DEVELOPER DOCUMENTATION · API 1.2.6 · JAVA 21 API · SDK EXAMPLE: JDK 25
Version scope: TNE/API 1.2.6. The portable API uses Java 21 bytecode. Use the newer Java runtime required by your Minecraft server (Java 25 for 26.x). The downloadable example project itself targets JDK 25. Install TNE with Riddles Core 0.6.23 or newer within 0.6.x. These guides describe the native Paper/Folia integration, not a proxy or HTTP API.
Use this page while coding. New to the API? Start with setup, then payments.
All methods below belong to EconomyClient. Default-currency overloads omit
the currency argument.
| Task | Call | Successful value |
|---|---|---|
| Create or get a named account | accounts().create(accountKey, displayName) |
Account |
| List this integration's named accounts | accounts().list(limit, offset) |
List<Account> |
| Look up a named account by its stable key | accounts().find(accountKey) |
Optional<Account> |
| Look up an account reference | accounts().find(accountRef) |
Optional<Account> |
| Rename a named account | accounts().rename(accountKey, displayName) |
Account |
| Read a chosen account | balance(accountRef, currency) |
AccountBalance |
| Read all virtual balances of an account | balances(accountRef) |
List<AccountBalance> |
| Pay from a chosen account | pay(sourceRef, playerUuid, currency, amount, key) |
Transaction |
| Charge into a chosen account | charge(playerUuid, destinationRef, currency, amount, key) |
Transaction |
| Move money between chosen accounts | transfer(sourceRef, destinationRef, currency, amount, key) |
Transaction |
| Read default balance | balance(playerUuid) |
Balance |
| Read selected balance | balance(playerUuid, currency) |
Balance |
| Pay another player | transfer(fromUuid, toUuid, currency, amount, key) |
Transaction |
| Credit a player | deposit(playerUuid, currency, amount, key) |
Transaction |
| Debit a player | withdraw(playerUuid, currency, amount, key) |
Transaction |
| Post an atomic set of payments | post(request) |
TransactionReceipt |
| Recover a full receipt by saved key | receipt(key) |
Optional<TransactionReceipt> |
| Read this integration's full receipt by UUID | receipt(transactionUuid) |
Optional<TransactionReceipt> |
| Read account history across transaction origins | history(accountRef, limit, offset) |
List<TransactionReceipt> |
| Reverse one of this integration's transactions | reverse(transactionUuid, reason, key) |
TransactionReceipt |
| Read the original single-payment summary | transaction(key) |
Optional<Transaction> |
amount is a positive BigDecimal. Currency precision is enforced; the API
does not silently round an invalid amount. Read CurrencyInfo.scale() to learn
how many decimal places a currency supports.
A Balance is a snapshot, not a reservation. Decide whether a payment succeeded
from the transfer or withdrawal result, rather than checking a balance first.
Transaction.amount() is the amount moved, not the player's resulting balance.
Native deposit and withdraw now move funds through TNE Checking, not Vault Checking. Both require clientForPlugin(this) and owner approval. Prefer checking().pay() for a payout with an explicit reason and full receipt. Dedicated-account operations keep their existing funded behavior.
Use the migration and authorization guide. integrations.vault.settlement-account-id does not configure native TNE Checking. No money automatically moves from old Vault balances.
| API | Result / rule |
|---|---|
api.clientForPlugin(this) |
Platform-bound EconomyClient; pass your enabled registered plugin from its own classloader. |
client.checking().account(currency) |
Deterministic AccountRef; reference lookup grants no spending authority. |
client.checking().pay(destination, currency, amount, reason, key) |
CompletionStage<Result<TransactionReceipt>>; requires owner approval and funding. |
SystemAccountIds.VAULT_CHECKING |
Stable default Vault account UUID; separate from native checking. |
SystemAccountIds.CONVERSION_RECEIPTS / CONVERSION_PAYOUTS |
Stable default exchange-account UUIDs. |
SystemAccountIds.canonical(uuid) |
Maps reserved historical IDs to defaults; custom IDs remain unchanged. |
SystemAccountIds is in com.cmriddles.thenewereconomy.api.account. Constants identify accounts, not permission or a funded currency balance. Custom configured roles can use different accounts. Resolve native checking through its service instead of hard-coding a UUID. Preserve old integration namespaces when recovering earlier operations.
A time currency uses whole seconds, not decimal money. Read CurrencyInfo.timeCurrency() and scale(); time currencies always have scale zero. Existing monetary currencies keep their units. Create a new time currency through setup rather than reinterpreting a live money currency.
import com.cmriddles.thenewereconomy.api.currency.TimeAmount;
import java.time.Duration;
import java.math.BigDecimal;
BigDecimal fiveMinutes = TimeAmount.seconds(Duration.ofMinutes(5)); // 300
Duration duration = TimeAmount.duration(fiveMinutes);
String display = TimeAmount.format(fiveMinutes); // 0d 0h 5m 0s
Use the same balance, transfer, checking payout, receipt and operation-key APIs with the configured time currency ID. Amounts in commands, funding and API calls are seconds: 60 = one minute, 3600 = one hour, 86400 = one day. Fractional seconds are rejected; normal positive-amount rules still apply to payments. duration() also requires a value within Java's exact long-second range. Helpers do not fund an account or submit a payment.
TNE owns the online countdown. Do not implement a second deduction loop. The Minecraft backend settles elapsed online time approximately once per second through balanced ledger transactions. Offline time does not count down. Savings, checking and plugin accounts do not count down. Each time currency counts down independently in the configured balance group, stopping at zero.
All participating backends sharing the currency need the updated plugin and consistent unit/database/balance-group configuration. Session fencing rejects stale-session settlement, and retries are idempotent. A forced termination can lose unsettled time; TNE does not guess offline elapsed time after recovery.
Countdown transactions emit TRANSACTION_COMMITTED with operation=time_countdown. TIME_BALANCE_EXHAUSTED is emitted when a countdown reaches zero. Other payments that spend the final balance produce ordinary transaction events. Persist your event cursor and handle replay idempotently; follow the event guide.
TNE does not kill players, change health, teleport, respawn or implement game rules. A game plugin can observe balances/events and decide the gameplay behavior. Recheck current state when necessary because an event describes a committed historical action, not necessarily the current balance.
var defaultCurrency = api.defaultCurrency();
String id = defaultCurrency.id(); // e.g. "coin": use in API calls
String display = defaultCurrency.pluralName(); // e.g. "Coins": use in your UI
int decimals = defaultCurrency.scale();
for (var currency : api.currencies()) {
// Configured virtual currencies usable through this API.
}
Currency IDs are case-insensitive and normalize to lowercase. Display names are
separate, with initial capitals. Do not use a display name, symbol, or formatted
balance as an identifier. Virtual-money operations do not deliver item currencies or XP. Use
notes() for signed physical money notes; see the commerce guide.
The client uses api.defaultScope(), TNE's configured server scope. scope()
shows that value. There is no scope override in this API; this is not a
remote-server or federated settlement API.
Money and balance methods return CompletionStage<Result<T>>:
error != null). Unexpected failures and
shutdown can happen. An exception is not proof that a write did not commit.result.isSuccess().result.value() only on success. Read result.failure() only on failure.Useful failure codes:
| Code | Meaning / next step |
|---|---|
VALIDATION_ERROR |
Check UUIDs, positive amount, precision, or key. |
CURRENCY_UNAVAILABLE |
Check the currency ID and configured currency type. |
INSUFFICIENT_FUNDS |
The required debit cannot be funded. |
ACCOUNT_RESTRICTED |
An account policy prevents the operation. |
PERMISSION_DENIED |
TNE policy rejected the operation. |
CONFLICT |
Conflicting/repeated operation; reconcile using your saved records. |
DEPENDENCY_UNAVAILABLE |
Storage/runtime is starting, stopping, or unavailable. |
INTERNAL_ERROR |
Record the failure's correlation ID for investigation. |
The failure also provides message() and correlationId(). Log these for
diagnosis; keep player-facing messages short. Do not parse English error messages
to decide whether a transaction succeeded. Invalid operation inputs return a
validation result; client(integrationName) itself rejects blank, oversized, or
control-character-containing names synchronously.
isAvailable() is a quick readiness check, not a guarantee that the next request
will succeed. Currency metadata is cached and can be read without waiting for
storage. The provider is unregistered when TNE stops. Look up the service again
after a lifecycle change; treat an old client as unavailable.
Do not call .join() or blocking .get() on Paper's main thread or any Folia
global, region, or entity thread. The API schedules its own storage work; you can
call it from a command handler without creating your own database thread.
Completion callbacks can run on a worker thread. Use the relevant Paper/Folia
scheduler for inventory changes, messages, entities, and world access. The example
uses player.getScheduler().run(...), which also handles the player retiring.
Use api.clientForPlugin(this) for platform-bound attribution and approved checking access. api.client(getName()) remains self-declared attribution for existing dedicated-account integrations; it cannot spend shared checking. Use a stable plugin name; do not put player input or
an order ID in the integration name. The per-operation idempotency key identifies
the individual action.
Writes go through TNE's existing transaction engine, balance checks, immutable double-entry ledger, audit records, and configured storage. This API does not provide a balance setter or direct SQL access. It does not require your plugin to construct ledger entries, balancing UUIDs, storage services, or commands.
The API classes to depend on are under com.cmriddles.thenewereconomy.api.
Platform and application implementation classes are internal integration details;
do not cast the provider or depend on Paper* classes.
You can also download TNE-API-1.2.6.jar or the complete
TNE-Developer-SDK-1.2.6.zip from
the 1.2.6 release.
The SDK includes sources, Javadoc, and a complete example plugin.
If you prefer a local API dependency, install the downloaded JAR into your local
Maven repository, then use the same provided dependency shown above:
mvn install:install-file -Dfile=TNE-API-1.2.6.jar -DgroupId=com.cmriddles -DartifactId=the-newer-economy-api -Dversion=1.2.6 -Dpackaging=jar -DgeneratePom=true
For Gradle's local-file alternative, copy it to libs and replace the coordinate
dependency with compileOnly(files("libs/TNE-API-1.2.6.jar")). Your CI must also
receive that file or perform the same local installation step.
| Path | What belongs here |
|---|---|
src/main/java/ |
Public contracts, shared value types, and developer test utilities. |
src/test/java/ |
Tests of those contracts and utilities. They are not packaged in the API JAR. |
examples/ |
A separate runnable plugin. It is not packaged in the API JAR. |
docs/ |
Setup, task guides, and this reference. |
pom.xml, mvnw, .mvn/ |
Standalone Maven build and wrapper. |
.github/workflows/ |
Automated API and example verification. |
Start reading code at TneApi, then EconomyClient, then the service you need.
A small interface or enum is a complete contract, not a placeholder.
Some shared types predate the current client API: federation/, the typed IDs in
asset/, payment/, transaction/, and AccountId. security/ contains release
signature verification used by TNE's updater. These predate the current release and remain
for compatibility; their presence does not expose a native federation service.
You do not need them for the account and payment integrations in these guides.
testing/EconomySandbox and CurrencyProviderContract are optional tools for
writing your own tests. See testing.
Setup & first balance · Accounts & payments · Reservations & workflows · Account controls & refunds · Commerce & menus · Events, extensions & testing · Example plugin
Reviewed November 10, 2026 against the published TNE 1.2.6 SDK, public API sources and current runtime implementation. The standalone API repository remains at 1.0.64; use this release’s SDK for current contracts. Earlier material was adapted from the MIT-licensed API repository.