Java Code Examples for org.bukkit.event.entity.EntityDamageEvent.DamageCause#CONTACT

The following examples show how to use org.bukkit.event.entity.EntityDamageEvent.DamageCause#CONTACT . 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: LWCPlayerListener.java    From Modern-LWC with MIT License 6 votes vote down vote up
@EventHandler
public void onEntityDamage(EntityDamageEvent e) {
    if (e instanceof EntityDamageByEntityEvent
            && !(e.getCause() == DamageCause.BLOCK_EXPLOSION || e.getCause() == DamageCause.ENTITY_EXPLOSION))
        return;
    Entity entity = e.getEntity();
    if (plugin.getLWC().isProtectable(e.getEntity().getType())) {
        int A = 50000 + entity.getUniqueId().hashCode();
        LWC lwc = LWC.getInstance();
        Protection protection = lwc.getPhysicalDatabase().loadProtection(entity.getWorld().getName(), A, A, A);
        if (protection != null) {
            if (e.getCause() != DamageCause.CONTACT)
                e.setCancelled(true);
        }
    }
}
 
Example 2
Source File: DisableDamageMatchModule.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
private static DamageCause getBlockDamageCause(Block block) {
  switch (block.getType()) {
    case LAVA:
    case STATIONARY_LAVA:
      return DamageCause.LAVA;

    case FIRE:
      return DamageCause.FIRE;

    default:
      return DamageCause.CONTACT;
  }
}
 
Example 3
Source File: DisableDamageMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
private static DamageCause getBlockDamageCause(Block block) {
    switch(block.getType()) {
        case LAVA:
        case STATIONARY_LAVA:
            return DamageCause.LAVA;

        case FIRE:
            return DamageCause.FIRE;

        default:
            return DamageCause.CONTACT;
    }
}