use of com.sk89q.worldguard.bukkit.event.entity.DestroyEntityEvent in project WorldGuard by EngineHub.
the class EventAbstractionListener method onHangingBreak.
@EventHandler(ignoreCancelled = true)
public void onHangingBreak(HangingBreakEvent event) {
if (event instanceof HangingBreakByEntityEvent) {
Entity remover = ((HangingBreakByEntityEvent) event).getRemover();
Events.fireToCancel(event, new DestroyEntityEvent(event, create(remover), event.getEntity()));
if (event.isCancelled() && remover instanceof Player) {
playDenyEffect((Player) remover, event.getEntity().getLocation());
}
} else if (event.getCause() == HangingBreakEvent.RemoveCause.EXPLOSION) {
DestroyEntityEvent destroyEntityEvent = new DestroyEntityEvent(event, Cause.unknown(), event.getEntity());
destroyEntityEvent.getRelevantFlags().add(Flags.OTHER_EXPLOSION);
if (event.getEntity() instanceof ItemFrame) {
destroyEntityEvent.getRelevantFlags().add(Flags.ENTITY_ITEM_FRAME_DESTROY);
} else if (event.getEntity() instanceof Painting) {
destroyEntityEvent.getRelevantFlags().add(Flags.ENTITY_PAINTING_DESTROY);
}
Events.fireToCancel(event, destroyEntityEvent);
}
}
use of com.sk89q.worldguard.bukkit.event.entity.DestroyEntityEvent in project WorldGuard by EngineHub.
the class EventAbstractionListener method onPlayerPickupItem.
@EventHandler(ignoreCancelled = true)
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
Item item = event.getItem();
pickupDebounce.debounce(event.getPlayer(), item, event, new DestroyEntityEvent(event, create(event.getPlayer()), event.getItem()));
}
Aggregations