Package org.bukkit.event.entity

Examples of org.bukkit.event.entity.EntityDamageByEntityEvent


        // Shouldn't ever happen
    }
   
    private void onMonsterDeath(EntityDeathEvent event) {
        EntityDamageEvent e1 = event.getEntity().getLastDamageCause();
        EntityDamageByEntityEvent e2 = (e1 instanceof EntityDamageByEntityEvent) ? (EntityDamageByEntityEvent) e1 : null;
        Entity damager = (e2 != null) ? e2.getDamager() : null;
        LivingEntity damagee = event.getEntity();

        // Make sure to grab the owner of a projectile/pet
        if (damager instanceof Projectile) {
            damager = ((Projectile) damager).getShooter();
View Full Code Here


        Entity damagee = event.getEntity();
        if (!arena.isRunning() && !arena.getRegion().contains(damagee.getLocation())) {
            return;
        }

        EntityDamageByEntityEvent edbe = (event instanceof EntityDamageByEntityEvent) ? (EntityDamageByEntityEvent) event : null;
        Entity damager = null;

        if (edbe != null) {
            damager = edbe.getDamager();

            if (damager instanceof Projectile) {
                damager = ((Projectile) damager).getShooter();
            }
View Full Code Here

            // "CANCELLED" to stop the entity from being damaged.
            // Element(Decimal) to set the amount of damage the entity receives.
            //
            // -->

            EntityDamageByEntityEvent subEvent = (EntityDamageByEntityEvent) event;

            // Have a different set of player and NPC contexts for events
            // like "player damages player" from the one we have for
            // "player damaged by player"

            dPlayer subPlayer = null;
            dNPC subNPC = null;
            dEntity projectile = null;
            dEntity damager = new dEntity(subEvent.getDamager());

            if (damager.isProjectile()) {
                projectile = damager;
                context.put("projectile", projectile);
View Full Code Here

            }
        }
//      System.out.println(event.getCause());
      // Attacking entities.
        if (event instanceof EntityDamageByEntityEvent) {
            final EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
            final Entity damager = e.getDamager();
            final int tick = TickTask.getTick();
          if (damagedPlayer != null && !damagedIsDead){
              // TODO: check once more when to set this (!) in terms of order.
            FightData.getData(damagedPlayer).damageTakenByEntityTick = tick;
                if (hasThorns(damagedPlayer)){
                // TODO: Cleanup here.
                  // Remember the id of the attacker to allow counter damage.
                  damagedData.thornsId = damager.getEntityId();
              }
                else{
                  damagedData.thornsId = Integer.MIN_VALUE;
                }
          }
          final DamageCause damageCause = event.getCause();
          final Player player = damager instanceof Player ? (Player) damager : null;
          Player attacker = player;
          // TODO: deobfuscate.
          if (damager instanceof TNTPrimed) {
            final Entity source = ((TNTPrimed) damager).getSource();
            if (source instanceof Player) {
              attacker = (Player) source;
            }
          }
          if (attacker != null && (damageCause == DamageCause.BLOCK_EXPLOSION || damageCause == DamageCause.ENTITY_EXPLOSION)) {
            // NOTE: Pigs don't have data.
        final FightData data = FightData.getData(attacker);
              data.lastExplosionEntityId = damaged.getEntityId();
          data.lastExplosionDamageTick = tick;
          return;
        }
            if (player != null){
                final double damage = BridgeHealth.getDamage(e);
                final FightData data = FightData.getData(player);
                if (damageCause == DamageCause.ENTITY_ATTACK){
            // TODO: Might/should skip the damage comparison, though checking on lowest priority.
                  if (damaged.getEntityId() == data.lastExplosionEntityId && tick == data.lastExplosionDamageTick) {
                    data.lastExplosionDamageTick = -1;
                    data.lastExplosionEntityId = Integer.MAX_VALUE;
                  } else if (handleNormalDamage(player, damaged, damage, tick, data)){
                    e.setCancelled(true);
                  }
                }
            }
        }
    }
View Full Code Here

            EntityDamageEvent lastDamageCause = victim.getLastDamageCause();

            if (lastDamageCause instanceof EntityDamageByEntityEvent)
            {
                EntityDamageByEntityEvent entityEvent = (EntityDamageByEntityEvent) lastDamageCause;

                if (entityEvent.getDamager() instanceof Player)
                {
                    attacker = (Player) entityEvent.getDamager();
                } else if (entityEvent.getDamager() instanceof Arrow)
                {
                    Arrow arrow = (Arrow) entityEvent.getDamager();

                    if (arrow.getShooter() instanceof Player)
                    {
                        attacker = (Player) arrow.getShooter();
                    }
View Full Code Here

        Player victim = null;


        if (event instanceof EntityDamageByEntityEvent)
        {
            EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event;

            if (sub.getEntity() instanceof Player && sub.getDamager() instanceof Player)
            {
                attacker = (Player) sub.getDamager();
                victim = (Player) sub.getEntity();
            }

            if (plugin.getSettingsManager().isTamableMobsSharing())
            {
                if (sub.getEntity() instanceof Wolf && sub.getDamager() instanceof Player)
                {
                    attacker = (Player) sub.getDamager();
                    Wolf wolf = (Wolf) sub.getEntity();
                    ClanPlayer cp = plugin.getClanManager().getClanPlayer(attacker);
                    if (wolf.isTamed())
                    {
                        if (cp.getClan().isMember((Player) wolf.getOwner()))
                        {
                            // Sets the wolf to friendly if the attacker is one out of his clan
                            wolf.setAngry(false);
                        }
                    }
                }
            }

            if (sub.getEntity() instanceof Player && sub.getDamager() instanceof Arrow)
            {
                Arrow arrow = (Arrow) sub.getDamager();

                if (arrow.getShooter() instanceof Player)
                {
                    attacker = (Player) arrow.getShooter();
                    victim = (Player) sub.getEntity();
                }
            }
        }

        if (victim != null)
View Full Code Here

        // make sure plugin is enabled
        if(!plugin.isEnabled())
            return;
       
        if (event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent){
            EntityDamageByEntityEvent e = (EntityDamageByEntityEvent)event.getEntity().getLastDamageCause();
            org.bukkit.entity.Player pDamager = null;
            if(e.getDamager() instanceof org.bukkit.entity.Player) {
                pDamager = (org.bukkit.entity.Player) e.getDamager();
            } else if(e.getDamager() instanceof Projectile && ((Projectile)e.getDamager()).getShooter() instanceof org.bukkit.entity.Player) {
                pDamager = (org.bukkit.entity.Player)((Projectile)e.getDamager()).getShooter();
            } else if(e.getDamager() instanceof Tameable) {
                Tameable t = (Tameable) e.getDamager();
                if (t.isTamed() && t.getOwner() instanceof org.bukkit.entity.Player) {
                    pDamager = (org.bukkit.entity.Player) t.getOwner();
                }
            }
            if(pDamager != null) {
View Full Code Here

  {
    if(event.getCause() == DamageCause.ENTITY_ATTACK)
    {
      if (event instanceof EntityDamageByEntityEvent)
      {
        EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent)event;
        if(isPlayer(sub.getEntity()) && isPlayer(sub.getDamager()))
        {
          EpicZonePlayer ezp = General.getPlayer(sub.getEntity().getEntityId());
          Zone zone = ezp.getCurrentZone();
          if(zone != null)
          {
            if(!zone.hasPVP())
            {
              event.setCancelled(true);
            }
          }
        }
      }
      else if (event instanceof EntityDamageByProjectileEvent)
      {
        EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent)event;
        if(isPlayer(sub.getEntity()) && isPlayer(sub.getDamager()))
        {
          EpicZonePlayer ezp = General.getPlayer(sub.getEntity().getEntityId());
          Zone zone = ezp.getCurrentZone();
          if(zone != null)
          {
            if(!zone.hasPVP())
            {
View Full Code Here

  {
    if(event.getCause() == DamageCause.ENTITY_ATTACK)
    {
      if (event instanceof EntityDamageByEntityEvent)
      {
        EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent)event;
        if(isPlayer(sub.getEntity()) && isPlayer(sub.getDamager()))
        {
          EpicZonePlayer ezp = General.getPlayer(sub.getEntity().getEntityId());
          EpicZone zone = ezp.getCurrentZone();
          if(zone != null)
          {
            if(!zone.hasPVP())
            {
              event.setCancelled(true);
            }
          }
        }
      }
      else if (event instanceof EntityDamageByProjectileEvent)
      {
        EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent)event;
        if(isPlayer(sub.getEntity()) && isPlayer(sub.getDamager()))
        {
          EpicZonePlayer ezp = General.getPlayer(sub.getEntity().getEntityId());
          EpicZone zone = ezp.getCurrentZone();
          if(zone != null)
          {
            if(!zone.hasPVP())
            {
View Full Code Here

            if (this.plugin.getManager().isVanished(player) && VanishPerms.blockIncomingDamage(player)) {
                event.setCancelled(true);
            }
        }
        if (event instanceof EntityDamageByEntityEvent) {
            final EntityDamageByEntityEvent ev = (EntityDamageByEntityEvent) event;
            final Entity damager = ev.getDamager();
            Player player = null;
            if (damager instanceof Player) {
                player = (Player) damager;
            } else if (damager instanceof Projectile) {
                final Projectile projectile = (Projectile) damager;
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.