API
Application Programming Interface
PvPToggle includes several functions for enabling developers to hook into it's features and toggle players, worlds or global PvP status. These functions, and some explanation are listed below.
The first step is to hook into PvPToggle. To do this, in your code, you must put the following line of code in your imports section:
import com.sleelin.pvptoggle.PvPToggle;
This will provide you with the interface to toggle and check PvP status. The next step is to check if PvPToggle is loaded on the target system (if it is not loaded, errors will occur). You can do this with the following code, which you can use anywhere:
Plugin PvPTogglePlugin = this.getServer().getPluginManager().getPlugin("PvPToggle"); if (PvPTogglePlugin != null){ PvPToggle pvptoggle = ((PvPToggle) PvPTogglePlugin).getHandler(); }
Interface Functions
From here, there are a range of functions at your disposal which can be used to toggle PvP status. These are:
boolean pvptoggle.checkPlayerStatus(Player player, String world)
- Checks whether or not PvP is enabled for a specified player in the specified world, and returns their status as a Boolean. Takes arguments player, of type Player, and world, of type String.
boolean pvptoggle.checkWorldStatus(String world)
- Checks whether or not PvP is enabled world-wide for a specified world, and returns the result as a boolean. Takes argument world, of type String.
boolean pvptoggle.checkGlobalStatus()
- Checks whether server-wide PvP is enabled, and returns the result as a boolean.
void pvptoggle.setPlayerStatus(Player player, String world, boolean newval)
- Sets PvP to "newval" for a specified player in the specified world. Takes arguments player, of type Player, world, of type String, and newval, of type boolean.
How can this be fixed?
@bPrepared
Huh, looks like Bukkit might have changed the way the plugin handler retrieves plugin instances. This will be fixed in v2.0 coming soon!
Please could you update your API? I'm trying to use your plugin with mine and its incredibly difficult with an out of date API