MCEngineCurrencyCommon - API Usage Guide
getApi()
Function
public static MCEngineCurrencyCommon getApi()
Usage
MCEngineCurrencyCommon common = MCEngineCurrencyCommon.getApi();
Provides access to the singleton API instance.
initPlayerData(UUID uuid)
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)
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)
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)
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)
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(...)
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()
Function
public Connection getDBConnection()
Usage
Connection conn = common.getDBConnection();
Useful for manual queries or diagnostics on the active database.
disConnect()
Function
public void disConnect()
Usage
common.disConnect();
Should be called during plugin disable or shutdown.