main/API

API

There's a simple API provided by RoadProtector:

/*
 * Remove protection around defined block in area specified by radius
 * Protector will be replaced with "unprotector" defined in config
 */
public int unProtect(Block b, int r){

/*
 * Remove protection around defined block in area specified by radius
 * Protector will be replaced with defined "unprotector"
 */
public int unProtect(Block b, int r, int unprotector){


/*
 * Remove all protectors that could affect to defined block 
 * (area specified by protection field size, defined in config)
 * Protector will be replaced with "unprotector" defined in config
 */
public int unProtect(Block b)
	

/*
 * Check is defined location protected by the RoadProtector
 * returns "true" if location is protected 
 */
public boolean isProtected (Location loc) 
	
/*
 * Check is defined block protected by the RoadProtector
 * returns "true" if block is protected 
 */
public boolean isProtected (Block b) 
	
/*
 * Check is player is above the "speed-blocks"
 * returns "true" he walk on the road.
 * This methods did not check protection on player location 
 */
public boolean isPlayerOnRoad(Player p)

You can use this methods inside your plugin, but first you must connect to RoadProtector. Here is an example of function that could be used to connect to RoadProtector from any other plugin.

RoadProtector rp;

public boolean connectRoadProtector(){
	Plugin roadProtector= getServer().getPluginManager().getPlugin("RoadProtector");
	if ((roadProtector != null)&&(roadProtector instanceof RoadProtector)) {
		rp = (RoadProtector)roadProtector;
		return true;
	}
	return false;
}

Comments

Posts Quoted:
Reply
Clear All Quotes