Overview | EssentialsC | EconomyApi
net.godlycow.org.essc.api

Interface EconomyApi

public interface EconomyApi

API interface for interacting with EssentialsC's economy system. The economy is backed by SQLite and maintains an in-memory cache of recently accessed balances. All methods that touch the database return CompletableFuture — do not block the main thread waiting on them.

Retrieve an instance via EssentialsCAPI.getEconomyApi().

EconomyApi eco = APIProvider.getAPI().getEconomyApi();

eco.getBalance(player.getUniqueId()).thenAccept(balance -> {
    player.sendMessage("Balance: " + eco.format(balance));
});

eco.withdraw(player.getUniqueId(), BigDecimal.valueOf(100))
   .thenAccept(success -> {
       if (!success) player.sendMessage("Insufficient funds.");
   });

Accounts

CompletableFuture<Boolean> hasAccount(UUID uuid)
Returns whether an economy account exists for the given player.
CompletableFuture<Boolean> createAccount(UUID uuid, String name)
Creates an account for the given player if one does not already exist.

Balances

CompletableFuture<BigDecimal> getBalance(UUID uuid)
Returns the current balance of the given player.
CompletableFuture<Boolean> has(UUID uuid, BigDecimal amount)
Returns whether the player has at least the specified amount.
CompletableFuture<Boolean> withdraw(UUID uuid, BigDecimal amount)
Withdraws the given amount from the player's account.
CompletableFuture<Boolean> deposit(UUID uuid, BigDecimal amount)
Deposits the given amount into the player's account.
CompletableFuture<Boolean> setBalance(UUID uuid, BigDecimal amount)
Sets the player's balance to exactly the given amount.
CompletableFuture<Map<UUID,BigDecimal>> getTopBalances(int limit)
Returns the top balances across all players, ordered descending.

Formatting

String format(BigDecimal amount)
Formats an amount as a full currency string including the currency name.
String formatPlain(BigDecimal amount)
Formats an amount as a plain number string with no currency name.
String currencyNameSingular()
Returns the singular form of the configured currency name.
String currencyNamePlural()
Returns the plural form of the configured currency name.

Limits

BigDecimal getMinTransaction()
Returns the minimum amount allowed in a single transaction.
BigDecimal getMaxBalance()
Returns the maximum balance a player may hold, or null if uncapped.
boolean hasMaxBalance()
Returns whether a maximum balance cap is configured.
BigDecimal getStartingBalance()
Returns the starting balance given to newly created accounts.

Vault

boolean isVaultHooked()
Returns whether EssentialsC is registered as the active Vault economy provider.
Accounts — Detail
public CompletableFuture<Boolean> hasAccount(UUID uuid)

Returns whether an economy account exists for the given player.

Do not block the main thread waiting on this future.

Parameters:
uuidthe UUID of the player to check; must not be null
Returns:
CompletableFuture<Boolean>true if an account exists
public CompletableFuture<Boolean> createAccount(UUID uuid, String name)

Creates an economy account for the given player if one does not already exist.

The account is initialised with the configured starting balance. If an account already exists this is a no-op and the future resolves false.

Do not block the main thread waiting on this future.

Parameters:
uuidthe UUID of the player; must not be null
namethe player's current name, used for display purposes; must not be null
Returns:
CompletableFuture<Boolean>true if the account was newly created, false if it already existed
Balances — Detail
public CompletableFuture<BigDecimal> getBalance(UUID uuid)

Returns the current balance of the given player. Results are served from an in-memory cache when available. Returns BigDecimal.ZERO if no account exists for the UUID.

Do not block the main thread waiting on this future.

Parameters:
uuidthe UUID of the player; must not be null
Returns:
CompletableFuture<BigDecimal>the player's balance; never null
public CompletableFuture<Boolean> has(UUID uuid, BigDecimal amount)

Returns whether the given player has at least the specified amount.

Do not block the main thread waiting on this future.

Parameters:
uuidthe UUID of the player; must not be null
amountthe amount to check against; must not be null
Returns:
CompletableFuture<Boolean>true if the player's balance is greater than or equal to amount
public CompletableFuture<Boolean> withdraw(UUID uuid, BigDecimal amount)

Withdraws the given amount from the player's account. The future resolves false if the amount is below the minimum transaction threshold, the player does not have sufficient funds, or no account exists for the UUID.

Do not block the main thread waiting on this future.

Parameters:
uuidthe UUID of the player; must not be null
amountthe amount to withdraw; must be positive
Returns:
CompletableFuture<Boolean>true on success
public CompletableFuture<Boolean> deposit(UUID uuid, BigDecimal amount)

Deposits the given amount into the player's account. The future resolves false if the amount is below the minimum transaction threshold, or the deposit would exceed the configured maximum balance. If no account exists for the UUID, one is created automatically.

Do not block the main thread waiting on this future.

Parameters:
uuidthe UUID of the player; must not be null
amountthe amount to deposit; must be positive
Returns:
CompletableFuture<Boolean>true on success
public CompletableFuture<Boolean> setBalance(UUID uuid, BigDecimal amount)

Sets the player's balance to exactly the given amount. The future resolves false if the amount is negative, exceeds the configured maximum balance, or no account exists for the UUID.

Do not block the main thread waiting on this future.

Parameters:
uuidthe UUID of the player; must not be null
amountthe exact balance to set; must be zero or positive
Returns:
CompletableFuture<Boolean>true on success
public CompletableFuture<Map<UUID, BigDecimal>> getTopBalances(int limit)

Returns the top balances across all players, ordered descending. The returned map preserves insertion order (highest balance first). Keys are player UUIDs, values are their balances.

Do not block the main thread waiting on this future.

Parameters:
limitthe maximum number of entries to return; must be positive
Returns:
CompletableFuture<Map<UUID,BigDecimal>>a linked map of UUID to balance, highest first; never null, may be empty
Formatting — Detail
public String format(BigDecimal amount)

Formats the given amount as a full currency string including the currency name (e.g. "1,234.56 Dollars" or "1.00 Dollar"). Singular vs. plural is chosen automatically based on the amount.

Parameters:
amountthe amount to format; must not be null
Returns:
Stringthe formatted currency string; never null
public String formatPlain(BigDecimal amount)

Formats the given amount as a plain number string with no currency name appended (e.g. "1,234.56").

Parameters:
amountthe amount to format; must not be null
Returns:
Stringthe formatted number string; never null
public String currencyNameSingular()

Returns the singular form of the configured currency name (e.g. "Dollar").

Returns:
Stringthe singular currency name; never null
public String currencyNamePlural()

Returns the plural form of the configured currency name (e.g. "Dollars").

Returns:
Stringthe plural currency name; never null
Limits — Detail
public BigDecimal getMinTransaction()

Returns the minimum amount allowed in a single transaction. Withdraw and deposit calls with an amount below this threshold resolve false without touching the database.

Returns:
BigDecimalthe minimum transaction amount; never null, always positive
public BigDecimal getMaxBalance()

Returns the maximum balance a player may hold, or null if there is no cap.

Returns:
BigDecimalthe maximum balance, or null if uncapped
public boolean hasMaxBalance()

Returns whether a maximum balance cap is configured. Equivalent to getMaxBalance() != null.

Returns:
booleantrue if a maximum balance limit is active
public BigDecimal getStartingBalance()

Returns the starting balance given to newly created accounts.

Returns:
BigDecimalthe starting balance; never null, always non-negative
Vault — Detail
public boolean isVaultHooked()

Returns whether EssentialsC has successfully registered itself as a Vault economy provider.

When true, other plugins using the Vault API will route economy calls through EssentialsC's economy. When false, Vault is either not installed or the hook failed to register.

Returns:
booleantrue if the Vault economy hook is active