Hook into Parties

SecurityVillagers offers a developer API to get information about protected entities and handle plugin events.

Importing SecurityVillagers

To add the API to your project you can use use Maven, Gradle or manual adding in classpath.




repositories {
maven {
name = 'alessiodp-repo'
url = 'https://repo.alessiodp.com/releases/'
dependencies {
compileOnly group: 'com.alessiodp.securityvillagers', name: 'securityvillagers-api', version: '2.14.8'


Your plugin must loaded after Parties so you have to define this behavior in plugin.yml of your plugin by inserting Parties as depend (or soft-depend):

depend: [SecurityVillagers]
softdepend: [SecurityVillagers]

Before hook into it, be sure its enabled!

if (getServer().getPluginManager().getPlugin("SecurityVillagers") != null) {
if (getServer().getPluginManager().getPlugin("SecurityVillagers").isEnabled()) {
// SecurityVillagers is enabled

Then you can take the instance of SecurityVillagers:

SecurityVillagersAPI api = SecurityVillagers.getApi();

API Methods

SecurityVillagers offers a class called SecurityVillagersAPI, you can declare it to call API methods. This is how you can use it:

SecurityVillagersAPI api = SecurityVillagers.getApi();
// Get a list of protected entities
List<UUID> entities = api.getProtectedEntities();
// Get the entity selected by a player
Entity entity = api.getSelectedEntity(simplePlayer);

Event handlers

SecurityVillagers offers some events open to handle, you can hook into them like every Bukkit listener.

public void onPlayerChat(SecurityVillagersDamageEvent event) {
if (event.getAttackResult() == AttackResult.SUCCESS) {
// Even if the attack is gonna be a success, prevent it by changing it into MELEE deny result
// The user will receive a message like "you cannot hit X"
public void onPlayerChat(SecurityVillagersProtectionChangeEvent event) {
// Prevent protection change


You can find the JavaDoc here.