Java Code Examples for org.bukkit.event.entity.EntityBreakDoorEvent#setCancelled()

The following examples show how to use org.bukkit.event.entity.EntityBreakDoorEvent#setCancelled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LWCEntityListener.java    From Modern-LWC with MIT License 6 votes vote down vote up
@EventHandler
public void entityBreakDoor(EntityBreakDoorEvent event) {
    Block block = event.getBlock();

    // See if there is a protection there
    Protection protection = plugin.getLWC().findProtection(block.getLocation());

    if (protection != null) {
        // protections.allowEntityBreakDoor
        boolean allowEntityBreakDoor = Boolean
                .parseBoolean(plugin.getLWC().resolveProtectionConfiguration(block, "allowEntityBreakDoor"));

        if (!allowEntityBreakDoor) {
            event.setCancelled(true);
        }
    }
}
 
Example 2
Source File: BlockListener.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGH)
public void onEntityBreakDoor(EntityBreakDoorEvent event) {
	bcoord.setFromLocation(event.getBlock().getLocation());
	StructureBlock sb = CivGlobal.getStructureBlock(bcoord);
	if (sb != null) {
		event.setCancelled(true);
	}

	CampBlock cb = CivGlobal.getCampBlock(bcoord);
	if (cb != null) {
		event.setCancelled(true);
	}
}