MCEngineCurrencyCommon - API Usage Guide

getApi()

/** Gets the global API singleton instance */

Function

public static MCEngineCurrencyCommon getApi()

Usage

MCEngineCurrencyCommon common = MCEngineCurrencyCommon.getApi();

Provides access to the singleton API instance.

initPlayerData(UUID uuid)

/** Initializes player data with default currency */

Function

public void initPlayerData(UUID uuid)

Usage

common.initPlayerData(playerId);

Sets all player coin balances to 0.0 if not already initialized.

checkIfPlayerExists(UUID uuid)

/** Checks whether player data exists in the database */

Function

public boolean checkIfPlayerExists(UUID uuid)

Usage

boolean exists = common.checkIfPlayerExists(playerId);

Returns true if player currency data is stored in the DB.

addCoin(UUID uuid, String coinType, double amt)

/** Adds coins to a player's balance */

Function

public void addCoin(UUID uuid, String coinType, double amt)

Usage

common.addCoin(playerId, "gold", 50.0);

Increases the player’s balance for the given coin type.

minusCoin(UUID uuid, String coinType, double amt)

/** Subtracts coins from a player's balance */

Function

public void minusCoin(UUID uuid, String coinType, double amt)

Usage

common.minusCoin(playerId, "silver", 25.0);

Decreases the player’s balance for the specified coin.

getCoin(UUID uuid, String coinType)

/** Retrieves the current coin balance for a player */

Function

public double getCoin(UUID uuid, String coinType)

Usage

double coins = common.getCoin(playerId, "copper");

Returns the balance of the requested coin type for a player.

createTransaction(...)

/** Records a currency transaction between two players */

Function

public void createTransaction(UUID sender, UUID receiver, String currencyType, String transactionType, double amount, String notes)

Usage

common.createTransaction(senderId, receiverId, "gold", "pay", 10.0, "Payment for item");

Logs a transaction with type, currency, amount, and optional notes.

getDBConnection()

/** Returns the active SQL connection instance */

Function

public Connection getDBConnection()

Usage

Connection conn = common.getDBConnection();

Useful for manual queries or diagnostics on the active database.

disConnect()

/** Closes the active database connection */

Function

public void disConnect()

Usage

common.disConnect();

Should be called during plugin disable or shutdown.