org.bukkit.event.entity.EntityDamageByBlockEvent Java Examples

The following examples show how to use org.bukkit.event.entity.EntityDamageByBlockEvent. 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: EntityEventHandler.java    From GriefDefender with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamage(EntityDamageByBlockEvent event) {
    if (event.getCause() == DamageCause.SUFFOCATION || event.getCause() == DamageCause.DROWNING) {
        return;
    }
    GDTimings.ENTITY_DAMAGE_EVENT.startTiming();
    if (protectEntity(event, event.getDamager() == null ? event.getCause() : event.getDamager(), event.getEntity())) {
        event.setCancelled(true);
    }
    GDTimings.ENTITY_DAMAGE_EVENT.stopTiming();
}
 
Example #2
Source File: TrackerMatchModule.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
public DamageInfo resolveDamage(EntityDamageEvent damageEvent) {
  if (damageEvent instanceof EntityDamageByEntityEvent) {
    return resolveDamage((EntityDamageByEntityEvent) damageEvent);
  } else if (damageEvent instanceof EntityDamageByBlockEvent) {
    return resolveDamage((EntityDamageByBlockEvent) damageEvent);
  } else {
    return resolveDamage(damageEvent.getCause(), damageEvent.getEntity());
  }
}
 
Example #3
Source File: EventResolver.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
default DamageInfo resolveDamage(EntityDamageEvent damageEvent) {
    if(damageEvent instanceof EntityDamageByEntityEvent) {
        return resolveDamage((EntityDamageByEntityEvent) damageEvent);
    } else if(damageEvent instanceof EntityDamageByBlockEvent) {
        return resolveDamage((EntityDamageByBlockEvent) damageEvent);
    } else {
        return resolveDamage(damageEvent.getCause(), damageEvent.getEntity());
    }
}
 
Example #4
Source File: TrackerMatchModule.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
public DamageInfo resolveDamage(EntityDamageByBlockEvent damageEvent) {
  return resolveDamage(damageEvent.getCause(), damageEvent.getEntity(), damageEvent.getDamager());
}
 
Example #5
Source File: EventResolver.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
default DamageInfo resolveDamage(EntityDamageByBlockEvent damageEvent) {
    return resolveDamage(damageEvent.getCause(), damageEvent.getEntity(), damageEvent.getDamager());
}