RedProtect API - FabioZumbi12/RedProtect GitHub Wiki
RedProtect offer an API to easily manage the regions, check for flags and player permissions.
Use the Github maven api in your pom.xml:
Repository:
<repositories>
<repository>
<id>redprotect-repo</id>
<url>https://raw.githubusercontent.com/FabioZumbi12/RedProtect/mvn-repo/</url>
</repository>
</repositories>
Dependency:
<dependencies>
<dependency>
//Core is needed
<groupId>br.net.fabiozumbi12.RedProtect</groupId>
<artifactId>RedProtect-Core</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>br.net.fabiozumbi12.RedProtect</groupId>
<artifactId>RedProtect-[Check below for dependency names]</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>br.net.fabiozumbi12.RedProtect</groupId>
<artifactId>RedProtect-[Check below for dependency names]</artifactId>
<version>LATEST</version>
<classifier>javadoc</classifier>
</dependency>
</dependencies>
Check the dependency names and APIs: Click here
You can check if the Redprotect is present and loaded using the code on your main class:
public static boolean redProtect;
public MyPluginClass extends JavaPlugin {
public void onEnable() {
redProtect = checkRP();
}
private boolean checkRP(){
Plugin pRP = Bukkit.getPluginManager().getPlugin("RedProtect");
if (pRP != null && pRP.isEnabled()){
return true;
}
return false;
}
}
With this we check if the RedProtect is installed and enabled. Now, you can use the method RedProtect.get().getAPI() to get the region, flags or add flags, and all other API methods from api.
public static Region getPlayerRegion(Player p){
if (MyPluginClass.redProtect){
return RedProtect.get().getAPI().getRegion(p.getLocation());
}
return null;
}
If there's no region on player location, the method will return null.
Region r = getPlayerRegion(p);
if (r != null){
r.setFlag("chest",true); //allow others to access chests on region;
}
Region r = getPlayerRegion(p);
if (r != null && r.canBuild(p)){
//do something to allowed players
}
Region r = getPlayerRegion(p);
//If in Online Mode, will return the UUIDs as string!
List<PlayerRegion> leaders = r.getLeaders();
if (!leaders.isEmpty()){
String uuid= leaders.get(0).getUUID();
String player = leaders.get(0).getPlayerName();
}
You can see more info on API class with cometed methods: https://github.com/FabioZumbi12/RedProtect/blob/master/RedProtect-Spigot/src/main/java/br/net/fabiozumbi12/RedProtect/Bukkit/API/RedProtectAPI.java