Essentials Economy/API
From Essentials
Essentials Economy is a full fledged economy system, comparable to iConomy.
The built in economy API will redirect to any other detected economy system including any register or vault plugin. This means you can use EssEco api as a economy api instead of vault/register if your plugin is dependent on Essentials.
API
All the following API calls are safe calls. If the account doesn't yet exist but is valid, it will be created.
The api code can be found in the github
package com.earth2me.essentials.api;
You may instead use the Register or Vault plugin to hook Essentials Eco, as Essentials is registered in both these methods.
Checking Information
Public accessible methods for checking a players balance.
- boolean playerExists(String name) : Confirms an account exists
- double getMoney(String name) : Get current balance
- boolean hasEnough(String name, double amount) : Checks if the balance would be enough to withdraw the amount
- boolean hasMore(String name, double amount) : Confirms the account has more than the amount
- boolean hasLess(String name, double amount) : Confirms the account has less than the amount
- boolean isNegative(String name) : Checks if the account balance is negative
Altering Information
Public accessible methods for altering a players balance.
- void setMoney(String name, double bal) : Set current balance
- void add(String name, double money) : Add to balance
- void divide(String name, double money) : Divide balance
- void multiply(String name, double money) : Multiply balance
- void subtract(String name, double money) : Subtract from balance
- void resetBalance(String name) : Reset balance to 0
Tools
Public accessible methods for dealing with currency/economy
- String format(double amount) : Formats the cash amount as a displayable string.
NPC
These methods deal with NPC accounts only.
- boolean isNPC(String name) : Test if a player is a npc
- boolean createNPC(String name) : Creates dummy files for a npc, if there is no player yet with that name.
- void removeNPC(String name) : Deletes a user, if it is marked as npc.