Compatible with area protection plugin
About 219 wordsLess than 1 minute
To hook the function of no protection within area created by area protection plugin, you can follow the guides here.
Add a class
The name of the class should starts with H + abbreviation (or first three letters) of the corresponding plugin name.
E.g. Making a class for Residence, the name of the class should be HRes
ClassName.java
public class ClassName extends Hooks {
// Listeners that you are going to register
// Put them here so NoBuildPlus will register them at the start-up
@Override
public List<Listener> getListeners() {
return new ArrayList();
}
// NoBuildPlus will cancel it's checking if the below functions are returning true.
@Override
public boolean cancel(player player) {
// Add your code here.
return false;
}
@Override
public boolean cancel(Entity entity) {
// Add your code here.
return false;
}
@Override
public boolean cancel(Block block) {
// Add your code here.
return false;
}
@Override
public boolean cancel(Location loc) {
// Add your code here.
return false;
}
}Register the class
In the main class of NoBuildPlus, remember to register the class so NoBuildPlus knows it.
AreaProtectionLoader.java
public class AreaProtectionLoader {
private static final Map<String, Supplier<Hooks>> AREA_PROTECTION_HOOKS =
new HashMap<String, Supplier<Hooks>>() {{
put("Residence", HRes::new);
put("Dominion", HDom::new);
put("BlockRegen", HBlockRegen::new);
// Add your plugin here
}};
}