Package org.bukkit.event.entity

Examples of org.bukkit.event.entity.EntityDamageByEntityEvent


        }
        boolean tamedWolf = ent instanceof Wolf ? ((Wolf)ent).isTamed() : false;
        ClaimedResidence area = Residence.getResidenceManager().getByLoc(ent.getLocation());
        /* Living Entities */
        if (event instanceof EntityDamageByEntityEvent) {
            EntityDamageByEntityEvent attackevent = (EntityDamageByEntityEvent) event;
            Entity damager = attackevent.getDamager();
            ClaimedResidence srcarea = null;
            if (damager != null) {
                srcarea = Residence.getResidenceManager().getByLoc(damager.getLocation());
            }
            boolean srcpvp = true;
            if (srcarea != null) {
                srcpvp = srcarea.getPermissions().has("pvp", true);
            }
            ent = attackevent.getEntity();
            if ((ent instanceof Player || tamedWolf) && (damager instanceof Player || (damager instanceof Arrow && (((Arrow)damager).getShooter() instanceof Player)))) {
                Player attacker = null;
                if (damager instanceof Player) {
                    attacker = (Player) damager;
                } else if (damager instanceof Arrow) {
View Full Code Here


  }
 
  public static Entity getLiableDamager(EntityDamageEvent event)
  {
    if ( ! (event instanceof EntityDamageByEntityEvent)) return null;
    EntityDamageByEntityEvent edbeEvent = (EntityDamageByEntityEvent)event;
    Entity ret = edbeEvent.getDamager();
    if (ret instanceof Projectile)
    {
      ret = ((Projectile)ret).getShooter();
    }
    return ret;
View Full Code Here

  @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
  public void canCombatDamageHappen(EntityDamageEvent event)
  {
    // TODO: Can't we just listen to the class type the sub is of?
    if (!(event instanceof EntityDamageByEntityEvent)) return;
    EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent)event;
   
    if (this.canCombatDamageHappen(sub, true)) return;
    event.setCancelled(true);
  }
View Full Code Here

  // mainly for flaming arrows; don't want allies or people in safe zones to be ignited even after damage event is cancelled
  @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
  public void canCombatDamageHappen(EntityCombustByEntityEvent event)
  {
    EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), EntityDamageEvent.DamageCause.FIRE, 0D);
    if (this.canCombatDamageHappen(sub, false)) return;
    event.setCancelled(true);
  }
View Full Code Here

    Entity thrower = event.getPotion().getShooter();

    // ... scan through affected entities to make sure they're all valid targets.
    for (LivingEntity affectedEntity : event.getAffectedEntities())
    {
      EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(thrower, affectedEntity, EntityDamageEvent.DamageCause.CUSTOM, 0D);
      if (this.canCombatDamageHappen(sub, true)) continue;
     
      // affected entity list doesn't accept modification (iter.remove() is a no-go), but this works
      event.setIntensity(affectedEntity, 0.0);
    }
View Full Code Here

        // todo: use damage modifier system
        EntityDamageEvent event;
        if (source == null) {
            event = new EntityDamageEvent(this, cause, amount);
        } else {
            event = new EntityDamageByEntityEvent(source, this, cause, amount);
        }
        EventFactory.callEvent(event);
        if (event.isCancelled()) {
            return;
        }
View Full Code Here

                }
            }
        }

        if (event instanceof EntityDamageByEntityEvent) {
            EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event;
            if (sub.getDamager() instanceof Player) {
                Player player = (Player) sub.getDamager();
                Entity entity = sub.getEntity();
                ItemStack item = player.getItemInHand();

                if (item.getType().equals(Material.getMaterial(plugin.settingsManager.moverItem)) && plugin.permissionsManager.hasPermission(player, plugin.permissionsManager.mover) && !plugin.settingsManager.disableMover) {
                    event.setCancelled(true);
View Full Code Here

public class QuesterEntityListen implements Listener {
    @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
    public void onEntityDeath(EntityDeathEvent ev) {
        if (!(ev.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent))
            return;
        EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) ev.getEntity().getLastDamageCause();
        if (event.getDamager() instanceof Projectile) {
            Projectile shot = ((Projectile) event.getDamager());
            if (shot.getShooter() instanceof Player) {
                event = new EntityDamageByEntityEvent(shot.getShooter(), event.getEntity(), event.getCause(),
                        event.getDamage());
            }
        }
        if (event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity) {
            QuestManager.incrementQuest((Player) event.getDamager(), ev);
        }
    }
View Full Code Here

    @Override
    public void onDamage(EntityDamageEvent event) {
        if (!(event instanceof EntityDamageByEntityEvent))
            return;
        EntityDamageByEntityEvent ev = (EntityDamageByEntityEvent) event;
        if (!(ev.getDamager() instanceof LivingEntity))
            return;
        HumanNPC npc = NPCManager.get(event.getEntity());
        if (isOwner(ev.getDamager(), npc) || isCoOwned(ev.getDamager(), npc)) {
            event.setCancelled(true);
            return;
        }
        if (guardState != GuardState.NULL)
            guardState.getUpdater().onDamage(npc, (LivingEntity) ev.getDamager());
        else if (this.isAggressive) {
            target((LivingEntity) ev.getDamager(), npc);
        }
        event.setCancelled(false);
    }
View Full Code Here

        HumanNPC npc = NPCManager.get(event.getEntity());
        if (npc != null) {
            npc.callDamageEvent(event);
        }
        if (event instanceof EntityDamageByEntityEvent) {
            EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
            if (npc != null) {
                if (e.getDamager() instanceof Player) {
                    Player player = (Player) e.getDamager();
                    npc.callLeftClick(player, npc);
                }
            } else if (e.getDamager() instanceof Player) {
                CreatureTask.onDamage(e.getEntity(), event);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.bukkit.event.entity.EntityDamageByEntityEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.