Mineuniverse
Log in Register
Plugins

CurrencyHandler

CurrencyHandler is a Economy API that features support for more than just money.
by SydMontague
Download Claim this project
2,731 downloads
0 likes
Updated Jun 30, 2026
0 hypes
Admin Tools Developer Tools Economy

CurrencyHandler

CurrencyHandler is a Economy API that features support for more than just money.

Plugins can register their own currencies (e.g. own Levels), which can be used by every other plugin, without knowing the registering plugin. This allows plugins to be expandable without any code change on their side.

Metrics

This plugin utilises Hidendra's plugin metrics system. You can opt-out under <yourPluginFolder>/PluginMetrics/config.yml

The following informations will be collected:

  • A unique identifier
  • The server's version of Java
  • Whether the server is in offline or online mode
  • The plugin's version
  • The server's implementation and game version
  • The OS version/name and architecture
  • The core count for the CPU
  • The number of players online
  • The Metrics version
  • Your online-mode
  • Your server location
  • The keys of your registered currencies

Handlers

Every handler need a own input format. The handler author needs to specify this format in their documentation.

This plugin itself provides 5 default handlers.

Default Handlers

Money (requires Vault)
key: money
input format: any number

Food
key: food
input format: integer

Health
key: health
input format: integer

Enchantment Level
key: enchantlevel
input format: integer

Item
key: item
input format: list with entryformat "<itemid>:<itemdata> <amount>" or "<itemid> <amount>"


Usage as Admin

Usually you don't have to do more than putting the .jar into you plugins folder. However, you can deactivate the default handler via the config.yml.

All other things are handled by other plugins and their config files.


Usage as Developer

(You should take a look at the source code, this section is not very well written yet.)

Use currencies

To check if a Handler is stored use the static CurrencyHandler.hasHandler(String key). To get a Handler object use the static method CurrencyHandler.getHandler(String key).

For the usage of Handler objects scroll down to the HandlerInterface section.

Register currencies

To register a new currency you need to call the static method CurrencyHandler.registerHandler(String key, Handler handler), where the handler is a instance of a class, which implements the Handler interface specified below. Try to make your key as unique as possible (or simply configurable) to avoid conflicts with other plugins.

Handler Interface
public interface Handler
{
    /**
     * Check if a player owns enough of the handled currency
     * 
     * @param holder the "owner" of the currency
     * @param amount the amount of the handled currency
     * @return true if the amount of the handled currency is greater or equal
     *         the amount, false if not or when one of the input parameters does not match the requirements of the Handler
     */
    public abstract boolean hasCurrency(Object holder, Object amount);
    
    /**
     * Withdraw an amount of the handled currency from a player
     * If one of the input parameter does not match the requirements, nothing will happen.
     * 
     * @param holder the "owner" of the currency
     * @param amount the amount of the handled currency
     */
    public abstract void withdrawCurrency(Object holder, Object amount);
    
    /**
     * Give an amount of the handled currency to a player
     * If one of the input parameter does not match the requirements, nothing will happen.
     * 
     * @param holder the "owner" of the currency
     * @param amount the amount of the handled currency
     */
    public abstract void giveCurrency(Object holder, Object amount);
    
    /**
     * Set the amount of the handled currency to a player
     * If one of the input parameter does not match the requirements, nothing will happen.
     * 
     * @param holder the "owner" of the currency
     * @param amount the amount of the handled currency
     * @throws UnsupportedOperationException when a handler does not support this
     */
    public abstract void setCurrency(Object holder, Object amount) throws UnsupportedOperationException;
    
    /**
     * Get a string, which describes the given object
     * If one of the input parameter does not match the requirements, nothing will happen.
     * 
     * @param value the object that needs to be formated
     * @return the String, after the handler's format
     */
    public abstract String getFormatedString(Object value);
    
    /**
     * Get the name of the currency.
     * 
     * @return the name of the currency as String
     */
    public abstract String getCurrencyName();
    
    /**
     * Check if the given Object is usable by this handler.
     * It's advised to check this method before interacting with the handler.
     * 
     * @param obj the object that needs to be checked
     * @return true if the object can be used as amount by this handler, false if not
     */
    public abstract boolean checkInputObject(Object obj);
    
    /**
     * Check if the given Object is usable as holder by this handler.
     * It's advised to check this method before interacting with the handler.
     * 
     * @param obj the object that needs to be checked
     * @return true if the object can be used as holder by this handler, false if not
     */
    public abstract boolean checkInputHolder(Object obj);
}

Source Code

GitHub

CurrencyHandler 1.0.0
MC CB 1.7.2-R0.3
Beta 2014-04-16 Get
CurrencyHandler RC2
MC CB 1.6.2-R1.0
Beta 2013-09-20 Get
CurrencyHandler RC1
MC CB 1.5.2-R0.1
Beta 2013-05-10 Get

More from SydMontague

AntiUGFarm
6,215
UnhealthyDeath
5,461
Recycler
4,856
SkillLevels
3,087
ImageMaps
160,151
ServerMinimap
155,626

You Might Also Like

HyperConomy
The all in one economy and shop plugin.
94,502
Experience Bank II
Experience Bank II
9,883
MySQL Economy Bridge
Sync your economy accounts over many servers using MySQL.
9,832
BuyXP
Links the experience system with your economy plugin.
9,832
McmmoPay
McmmoPay
9,689
MinePermit
Require Players to pay to mine
9,617