Skip to main content
com.jpprison.economy.JPPrisonAPI provides static, null-safe methods for reading and modifying player economy balances from any plugin. All methods support both UUID and OfflinePlayer lookups. Class: com.jpprison.economy.JPPrisonAPI

Method Reference

Get Balance

Returns the player’s current balance for the specified economy.
Returns: double — the player’s balance, or 0.0 if the player has no data.

Check Affordability

Returns true if the player has at least the specified amount in the given economy.
Returns: boolean — false if the player has insufficient balance or no data.

Give Currency

Adds the specified amount to the player’s balance.
This call fires a BalanceChangeEvent with cause API_GIVE. You can listen for and cancel it in your own plugin.

Deduct Currency

Removes the specified amount from the player’s balance. Returns false if the player cannot afford it.
Returns: boolean — false if the player had insufficient balance (no deduction occurs).

Attempt a Purchase

An atomic operation that checks the player’s balance, deducts the cost, and returns the result — all in one call. Use this for shop and crate plugins to avoid race conditions.
Returns: boolean — true if the purchase succeeded and the balance was deducted.

Format a Value

Formats a numeric amount using the economy’s configured symbol, color, and decimal format for display in chat or GUIs.
Returns: String — the formatted, color-coded balance string.

EconomyCost

EconomyCost parses a human-readable cost string where the economy ID comes last. This is ideal for config-driven pricing where the economy type is read from YAML.
Config-driven example:

WorldGuard Flag

JPPrison registers a jpprison-enchants WorldGuard flag to gate enchant payouts inside specific regions. You can access this flag from your own plugin to perform the same check.

Null Safety

All JPPrisonAPI methods return safe defaults if the player has no stored data or if the economy ID does not exist:
  • getBalance → 0.0
  • has → false
  • take → false
  • give → no-op (silent)
You never need to null-check the return values of these methods.