基于Essentials插件的插件二次开发(第一期)
-
本帖最后由 noname 于 2014-7-24 17:00 编辑
在实际的服务器插件开发中,有时候需要用到Essentials插件的一些接口。如果不想去看Essentials的源码的话,可以参考下这个网站。
http://wiki.mc-ess.net/wiki/Essentials_Economy/API
这一期只是简单的交流一下关于Essentials_Economy的一些接口,和基于这些接口的二次开发。
首先你的库必须包含有com.earth2me.essentials.api,就是Essentials的基础插件。
下面是一些基础的方法:
Checking Informationboolean 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
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
其次在开发的过程中要注意Essentials插件和你开发的插件之间的加载顺序,即优先级问题。如果你调用了Essentials的方法,而你的插件优先于Essentials插件加载,这服务器就会报错。如果不知道如何进行优先级判断的可以去看Vault的Vault.java文件中的hookEconomy()方法。 -
-
-
不错