🪛 Developer API

If you want to add CoinsEngine as a dependency to your project, you have to install it from .jar to your local maven repository, as well as nightcore:

mvn install:install-file -Dfile=nightcore.jar -DgroupId=su.nightexpress.nightcore -DartifactId=nightcore -Dversion={VERSION} -Dpackaging=jar -DgeneratePom=true
mvn install:install-file -Dfile=CoinsEngine.jar -DgroupId=su.nightexpress.coinsengine -DartifactId=CoinsEngine -Dversion={VERSION} -Dpackaging=jar -DgeneratePom=true

And then add it to your pom.xml:

<dependency>
    <groupId>su.nightexpress.nightcore</groupId>
    <artifactId>nightcore</artifactId>
    <version>{VERSION}</version>
</dependency>

<dependency>
    <groupId>su.nightexpress.coinsengine</groupId>
    <artifactId>CoinsEngine</artifactId>
    <version>{VERSION}</version>
</dependency>

Don't forget to change {VERSION} to actual version of CoinsEngine and nightcore in both codes above.

API Events

  • ChangeBalanceEvent - Called after the player's currency balance chagned.

API Usage

// Obtain currency object by currency ID.
Currency currency = CoinsEngineAPI.getCurrency("coins");
if (currency == null) return;

// Obtain balance.
double balance = CoinsEngineAPI.getBalance(player, currency);

// Set player's currency balance.
CoinsEngineAPI.setBalance(Player player, Currency currency, double amount);
CoinsEngineAPI.setBalance(UUID playerId, Currency currency, double amount);
CoinsEngineAPI.setBalance(UUID playerId, String currency, double amount);

// Add to player's currency balance.
CoinsEngineAPI.addBalance(Player player, Currency currency, double amount);
CoinsEngineAPI.addBalance(UUID playerId, Currency currency, double amount);
CoinsEngineAPI.addBalance(UUID playerId, String currency, double amount);

// Remove from player's currency balance.
CoinsEngineAPI.removeBalance(Player player, Currency currency, double amount);
CoinsEngineAPI.removeBalance(UUID playerId, Currency currency, double amount);
CoinsEngineAPI.removeBalance(UUID playerId, String currency, double amount);

// Obtain user data.
CoinsUser user = CoinsEngineAPI.getUserData(Player player); // Can't be null.
CoinsUser user = CoinsEngineAPI.getUserData(String playerName); // Nullable
CoinsUser user = CoinsEngineAPI.getUserData(UUID uuid); // Nullable

// User methods.
user.setBalance(currency, amount);
user.addBalance(currency, amount);.
user.removeBalance(currency, amount);

// Register custom currency.
CoinsEngineAPI.getCurrencyManager().registerCurrency(myCurrency);

Last updated