Java 类org.bukkit.event.entity.EntityDamageByEntityEvent 实例源码

项目:McPlayUHC    文件:EntityDamageByEntityListener.java   
@EventHandler
public void EntityDamageByEntityListener(EntityDamageByEntityEvent e) {
    if (!GameManager.getGameSituation()) {
        e.setCancelled(true);
    }
    if (e.getDamager() instanceof Player) {
        if (e.getEntity() instanceof Player) {
            Player damager = (Player) e.getDamager();
            Player victim = (Player) e.getEntity();
            if (SettingsManager.shotinfo) {
                if (e.getCause() == DamageCause.PROJECTILE) {
                    if(victim.getLocation().distance(damager.getLocation()) < 20) {
                        Bukkit.broadcastMessage(SettingsManager.niceshot.replace("%s", victim.getName()).replace("%s", damager.getName()).replace("%d", String.valueOf(victim.getLocation().distance(damager.getLocation()))));
                    }
                }
            }
        }
    }
}
项目:Crescent    文件:KillauraC.java   
@Override
public void call(Event event) {
    if (event instanceof EntityDamageByEntityEvent) {
        final EntityDamageByEntityEvent edbe = (EntityDamageByEntityEvent) event;

        if (edbe.getEntity() instanceof LivingEntity) {
            final LivingEntity le = (LivingEntity) edbe.getEntity();

            final Location eye = profile.getPlayer().getEyeLocation();

            final double yawBetween = Helper.getYawBetween(eye, le.getLocation());
            final double playerYaw = profile.getPlayer().getEyeLocation().getYaw();

            final double angleBetween = Math.abs(180 - Math.abs(Math.abs(yawBetween - playerYaw) - 180));

            callback(angleBetween >= DISALLOWED_ANGLE && previousAngles.size() >= NEEDED_SAMPLES
                    && getAverageAngle() >= DISALLOWED_ANGLE);

            previousAngles.put(angleBetween, System.currentTimeMillis());
        }
    }
}
项目:Warzone    文件:ProjectileDamageResolver.java   
public @Nullable
DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
    if(damageEvent instanceof EntityDamageByEntityEvent) {
        EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent;

        if(event.getDamager() instanceof Projectile) {
            Projectile projectile = (Projectile) event.getDamager();
            Location launchLocation = this.projectileDistanceTracker.getLaunchLocation(projectile);
            Double projectileDistance = null;

            if(launchLocation != null) projectileDistance = event.getEntity().getLocation().distance(launchLocation);

            if(projectile.getShooter() instanceof LivingEntity) {
                return new ProjectileDamageInfo(projectile, (LivingEntity) projectile.getShooter(), projectileDistance);
            }
        }
    }
    return null;
}
项目:Warzone    文件:DispensedProjectileDamageResolver.java   
public @Nullable
DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
    if(damageEvent instanceof EntityDamageByEntityEvent) {
        EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent;

        if(event.getDamager() instanceof Projectile) {
            Projectile projectile = (Projectile) event.getDamager();
            Location launchLocation = this.projectileDistanceTracker.getLaunchLocation(projectile);
            Double projectileDistance = null;
            OfflinePlayer dispenserOwner = dispenserTracker.getOwner(projectile);


            if(launchLocation != null) projectileDistance = event.getEntity().getLocation().distance(launchLocation);

            if(projectile.getShooter() instanceof LivingEntity) {
                return new DispensedProjectileDamageInfo(projectile, (LivingEntity) projectile.getShooter(), projectileDistance, dispenserOwner);
            }
        }
    }
    return null;
}
项目:Warzone    文件:TNTDamageResolver.java   
public @Nullable
DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
    if(damageEvent instanceof EntityDamageByEntityEvent) {
        EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent;

        if(event.getDamager() instanceof TNTPrimed) {
            TNTPrimed tnt = (TNTPrimed) event.getDamager();
            Player owner = null;
            if(this.explosiveTracker.hasOwner(tnt)) {
                owner = this.explosiveTracker.getOwner(tnt);
            } else if(this.dispenserTracker.hasOwner(tnt)) {
                // getPlayer() is temporary to keep owner uniform until other services use OfflinePlayer
                owner = this.dispenserTracker.getOwner(tnt).getPlayer();
            }

            return new TNTDamageInfo(tnt, owner);
        }
    }

    return null;
}
项目:Kineticraft    文件:Toggles.java   
@EventHandler(ignoreCancelled = true)
public void onPvP(EntityDamageByEntityEvent evt) {
    if (Parties.isParty(evt.getDamager()))
        return;

    Player attacker = evt.getDamager() instanceof Player ? (Player) evt.getDamager() :
            (evt.getDamager() instanceof Projectile && ((Projectile) evt.getDamager()).getShooter() instanceof Player
            ? (Player) ((Projectile) evt.getDamager()).getShooter() : null); // Yuck, maybe we can make a method for this later.
    if (attacker == null || !(evt.getEntity() instanceof Player))
        return; // One or both of the combatants isn't a player.

    boolean outgoingFail = !getToggle(attacker, Toggle.PVP);
    boolean incomingFail = !getToggle(evt.getEntity(), Toggle.PVP);

    if (outgoingFail || incomingFail) {
        attacker.sendMessage(ChatColor.RED + (outgoingFail ? "You have PvP disabled. (/togglepvp)"
                : evt.getEntity().getName() + " has PvP disabled."));
        evt.setCancelled(true);
        evt.getEntity().setFireTicks(-1); // Disable fire damage.
    }
}
项目:Warzone    文件:MeleeDamageResolver.java   
public @Nullable
DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
    if(damageEvent instanceof EntityDamageByEntityEvent && damageEvent.getCause() == DamageCause.ENTITY_ATTACK) {
        EntityDamageByEntityEvent entityEvent = (EntityDamageByEntityEvent) damageEvent;

        if(entityEvent.getDamager() instanceof LivingEntity) {
            LivingEntity attacker = (LivingEntity) entityEvent.getDamager();

            Material weaponMaterial;
            ItemStack held = attacker.getEquipment().getItemInMainHand();
            if(held != null) {
                weaponMaterial = held.getType();
            } else {
                weaponMaterial = Material.AIR;
            }

            return new SimpleMeleeDamageInfo(attacker, weaponMaterial);
        }
    }

    return null;
}
项目:ZentrelaRPG    文件:NPCManager.java   
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    if (event.getDamager() instanceof Player) {
        if (event.getEntity() != null && npcs.containsKey(event.getEntity().getUniqueId())) {
            event.setCancelled(true);
            Player p = (Player) (event.getDamager());
            if (plugin.getPD(p) != null) {
                if (lastClick.containsKey(p.getUniqueId())) {
                    if (System.currentTimeMillis() - lastClick.get(p.getUniqueId()) < 333) {
                        return;
                    }
                }
                lastClick.put(p.getUniqueId(), System.currentTimeMillis());
                npcs.get(event.getEntity().getUniqueId()).interact(p, plugin.getPD(p));
            }
        }
    }
}
项目:Chambers    文件:TeamDamageListener.java   
@EventHandler
public void onDamageByEntity(EntityDamageByEntityEvent event) {
    if (event.getEntity() instanceof Player && event.getDamager() instanceof Player) {
        Player player = (Player) event.getEntity();
        Player damager = (Player) event.getDamager();
        Profile playerProfile = Chambers.getInstance().getProfileManager().getProfileByUuid(player.getUniqueId());
        Profile damagerProfile = Chambers.getInstance().getProfileManager().getProfileByUuid(damager.getUniqueId());
        if (playerProfile.getTeam() == null || damagerProfile.getTeam() == null || playerProfile.getProfileStatus() != ProfileStatus.PLAYING || damagerProfile.getProfileStatus() != ProfileStatus.PLAYING) {
            event.setCancelled(true);
            damager.sendMessage(ChatColor.RED + "You cannot do this in your current state.");
            return;
        }
        if (playerProfile.getTeam() == damagerProfile.getTeam()) {
            event.setCancelled(true);
            damager.sendMessage(ChatColor.YELLOW + "You cannot hurt " + damagerProfile.getTeam().getColor() + player.getName() + ChatColor.YELLOW + ".");
        }
    }
}
项目:WC    文件:Weapons.java   
@EventHandler
public void onDamageEntity(EntityDamageByEntityEvent e){
    Player p;

    if (e.getDamager() instanceof Player && e.getEntity() instanceof Zombie){
        p = (Player)e.getDamager();
        Weapon weapon;

        if (p.getInventory().getItemInMainHand() == null || !Weapon.isWeapon(p.getInventory().getItemInMainHand())) return;
        if (Weapon.getWeaponByItemStack(p.getInventory().getItemInMainHand()) == null) {
            e.setDamage(0);
            return;
        }
        weapon = Weapon.getWeaponByItemStack(p.getInventory().getItemInMainHand());

        if (weapon.getId() != 0) return;

        e.setDamage(((Zombie) e.getEntity()).getMaxHealth());
    }

    if (e.getDamager() instanceof Zombie && e.getEntity() instanceof Player) {
        p = (Player) e.getEntity();
        if (this.plugin.getBlooding().contains(new TWDPlayer(p.getUniqueId()))) return;
        this.plugin.getBlooding().add(new TWDPlayer(p.getUniqueId()));
    }
}
项目:SuperiorCraft    文件:LongRangeWeapon.java   
@EventHandler
public void onEntityDamage(EntityDamageByEntityEvent e) {
    if ((e.getDamager() instanceof Arrow) && (((Arrow) e.getDamager()).getShooter() instanceof Player) && e.getDamager().getCustomName() == name) {
        e.setDamage(e.getDamage() + damage);
        if (effect != null) {

            ((LivingEntity) e.getEntity()).addPotionEffect(effect);
        }
    }
    if ((e.getDamager() instanceof Fireball) && (((Fireball) e.getDamager()).getShooter() instanceof Player) && e.getDamager().getCustomName() == name) {
        e.setDamage(e.getDamage() + damage);
    }
    if ((e.getDamager() instanceof Snowball) && (((Snowball) e.getDamager()).getShooter() instanceof Player) && e.getDamager().getCustomName() == name) {
        e.setDamage(e.getDamage() + damage);
    }

}
项目:SuperiorCraft    文件:SuperiorCraft.java   
@EventHandler
public void onEntityByEntityDamage(EntityDamageByEntityEvent e) {
    /*if ((e.getDamager() instanceof Fireball) && (((Fireball) e.getDamager()).getShooter() instanceof Player)) {
        e.setDamage(20.0);
    }

    if ((e.getDamager() instanceof SmallFireball) && (((SmallFireball) e.getDamager()).getShooter() instanceof Player)) {
        e.setDamage(100.0);
    }*/
    /*if ((e.getDamager() instanceof Arrow) && (((Arrow) e.getDamager()).getShooter() instanceof Player) && e.getDamager().getCustomName() == "S1D") {
        e.setDamage(e.getDamage() + 4);
    }
    if ((e.getDamager() instanceof Arrow) && (((Arrow) e.getDamager()).getShooter() instanceof Player) && e.getDamager().getCustomName() == "S10D") {
        e.setDamage(e.getDamage() + 20);
    }
    if ((e.getDamager() instanceof Arrow) && (((Arrow) e.getDamager()).getShooter() instanceof Player) && e.getDamager().getCustomName() == "A1D") {
        e.setDamage(e.getDamage() + 2);
    }*/


}
项目:ProjectAres    文件:PlayerStaminaState.java   
void onEvent(EntityDamageEvent event) {
    if(event.getEntity() == player.getBukkit()) {
        // Player took damage
        mutateStamina(options.mutators.injury);

    } else if(event.getCause() == EntityDamageEvent.DamageCause.ENTITY_ATTACK &&
              event instanceof EntityDamageByEntityEvent &&
              ((EntityDamageByEntityEvent) event).getDamager() == player.getBukkit()) {

        // Player is damager and attack is melee
        swinging = false;

        for(StaminaSymptom symptom : getActiveSymptoms()) {
            symptom.onAttack(event);
        }

        mutateStamina(options.mutators.meleeHit);
    }
}
项目:ProjectAres    文件:BloodMatchModule.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityDamage(final EntityDamageEvent event) {
    if(event.getEntity() instanceof Player) {
        Player victim = (Player) event.getEntity();
        Location location = victim.getBoundingBox().center().toLocation(match.getWorld());
        if(event.getDamage() > 0 && location.getY() >= 0 && !victim.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
            EntityUtils.entities(match.getWorld(), Player.class)
                 .filter(player -> settings.getManager(player).getValue(Settings.BLOOD, Boolean.class, false))
                 .forEach(player -> {
                     if(event instanceof EntityDamageByEntityEvent) {
                         player.playEffect(location, Effect.STEP_SOUND, Material.REDSTONE_WIRE);
                     } else {
                         player.playEffect(location, Effect.STEP_SOUND, Material.LAVA);
                     }
                 });
        }
    }
}
项目:ProjectAres    文件:ProjectileMatchModule.java   
@EventHandler
public void onProjectileHurtEvent(EntityDamageByEntityEvent event) {
    if(!(event.getEntity() instanceof LivingEntity)) return;
    final LivingEntity damagedEntity = (LivingEntity) event.getEntity();

    final ProjectileDefinition projectileDefinition = Projectiles.getProjectileDefinition(event.getDamager());
    if(projectileDefinition == null) return;

    if(!projectileDefinition.potion().isEmpty()) {
        damagedEntity.addPotionEffects(projectileDefinition.potion());
    }

    if(projectileDefinition.damage() != null) {
        event.setDamage(projectileDefinition.damage());
    }
}
项目:HCFCore    文件:RogueClass.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    Entity entity = event.getEntity();
    Entity damager = event.getDamager();
    if (entity instanceof Player && damager instanceof Player) {
        Player attacker = (Player) damager;
        if (plugin.getPvpClassManager().getEquippedClass(attacker) == this) {
            ItemStack stack = attacker.getItemInHand();
            if (stack != null && stack.getType() == Material.GOLD_SWORD && stack.getEnchantments().isEmpty()) {
                Player player = (Player) entity;
                player.sendMessage(SettingsYML.ENEMY_COLOUR + attacker.getName() + ChatColor.YELLOW + " has backstabbed you.");
                player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1.0F, 1.0F);

                attacker.sendMessage(ChatColor.YELLOW + "You have backstabbed " + SettingsYML.ENEMY_COLOUR + player.getName() + ChatColor.YELLOW + '.');
                attacker.setItemInHand(new ItemStack(Material.AIR, 1));
                player.setHealth(12);
                attacker.playSound(player.getLocation(), Sound.ITEM_BREAK, 1.0F, 1.0F);

                event.setDamage(3.0);
            }
        }
    }
}
项目:MT_Core    文件:PlayerListener.java   
@EventHandler
public void onPlayerKillsPlayer(EntityDamageByEntityEvent e) {
    if (!(e.getDamager() instanceof Player) || !(e.getEntity() instanceof Player))
        return;

    Player killer = (Player) e.getDamager();
    Player target = (Player) e.getEntity();

    // Check if the target is dead
    if (target.getHealth() - e.getDamage() <= 0) {
        PlayerObject killerObject = main.getPlayerManager().getMortuusPlayer(killer.getUniqueId());

        // Sets the time in SECONDS.
        killerObject.setLastPlayerKillTime(System.currentTimeMillis() / 1000);
        killerObject.addPlayerKills(1);

        for (PKStates state : PKStates.values()) {
            if (killerObject.getPlayerKills() == state.getRequiredKills()) {
                killerObject.setPkState(state);
                main.getScoreboards().switchTeam(killer, state.name());
                break;
            }
        }
    }
}
项目:HCFCore    文件:InvincibilityTimer.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    Entity entity = event.getEntity();
    if (entity instanceof Player) {
        Player attacker = BukkitUtils.getFinalAttacker(event, true);
        if (attacker == null)
            return;

        long remaining;
        Player player = (Player) entity;
        if ((remaining = getRemaining(player)) > 0L) {
            event.setCancelled(true);
            attacker.sendMessage(ChatColor.RED + player.getName() + " has their " + getDisplayName() + ChatColor.RED + " timer for another " + ChatColor.BOLD
                    + DurationFormatter.getRemaining(remaining, true, false) + ChatColor.RED + '.');

            return;
        }

        if ((remaining = getRemaining(attacker)) > 0L) {
            event.setCancelled(true);
            attacker.sendMessage(ChatColor.RED + "You cannot attack players whilst your " + getDisplayName() + ChatColor.RED + " timer is active [" + ChatColor.BOLD
                    + DurationFormatter.getRemaining(remaining, true, false) + ChatColor.RED + " remaining]. Use '" + ChatColor.GOLD + PVP_COMMAND + ChatColor.RED + "' to allow pvp.");
        }
    }
}
项目:SurvivalPlus    文件:ObsidianMaceWeakness.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onAttack(EntityDamageByEntityEvent event)
{
    if(event.isCancelled()) return;
    if(event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity && event.getCause() == DamageCause.ENTITY_ATTACK)
    {
        Player player = (Player)event.getDamager();
        ItemStack mainItem = player.getInventory().getItemInMainHand();
        LivingEntity enemy = (LivingEntity)event.getEntity();

        if(mainItem.getType() == Material.GOLD_SPADE)
        {
            enemy.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 100, 0, false));
            enemy.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 100, 0, false));
            player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 48, 2, true));
            Location particleLoc = player.getLocation();
            particleLoc.setY(particleLoc.getY() + 2);
               ParticleEffect.HEART.display(0.5f, 0, 0.5f, 1, 2, particleLoc, 64);
        }
    }
}
项目:SurvivalPlus    文件:StarBattleaxeWither.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onAttack(EntityDamageByEntityEvent event)
{
    if(event.isCancelled()) return;
    if(event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity && event.getCause() == DamageCause.ENTITY_ATTACK)
    {
        Player player = (Player)event.getDamager();
        ItemStack mainItem = player.getInventory().getItemInMainHand();
        LivingEntity enemy = (LivingEntity)event.getEntity();

        Random rand = new Random();

        if(mainItem.getType() == Material.GOLD_AXE)
        {
            enemy.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 480, 2, false));
            enemy.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 480, 0, false));
            enemy.getLocation().getWorld().playSound(enemy.getLocation(), Sound.ENTITY_WITHER_SPAWN, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
        }
    }
}
项目:HCFCore    文件:RogueClass.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    Entity entity = event.getEntity();
    Entity damager = event.getDamager();
    if (entity instanceof Player && damager instanceof Player) {
        Player attacker = (Player) damager;
        if (plugin.getPvpClassManager().getEquippedClass(attacker) == this) {
            ItemStack stack = attacker.getItemInHand();
            if (stack != null && stack.getType() == Material.GOLD_SWORD && stack.getEnchantments().isEmpty()) {
                Player player = (Player) entity;
                player.sendMessage(SettingsYML.ENEMY_COLOUR + attacker.getName() + ChatColor.YELLOW + " has backstabbed you.");
                player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1.0F, 1.0F);

                attacker.sendMessage(ChatColor.YELLOW + "You have backstabbed " + SettingsYML.ENEMY_COLOUR + player.getName() + ChatColor.YELLOW + '.');
                attacker.setItemInHand(new ItemStack(Material.AIR, 1));
                player.setHealth(12);
                attacker.playSound(player.getLocation(), Sound.ITEM_BREAK, 1.0F, 1.0F);

                event.setDamage(3.0);
            }
        }
    }
}
项目:MockBukkit    文件:PlayerMock.java   
@Override
public void damage(double amount, Entity source)
{
    Map<DamageModifier, Double> modifiers = new EnumMap<>(DamageModifier.class);
    modifiers.put(DamageModifier.BASE, 1.0);
    Map<DamageModifier, Function<Double, Double>> modifierFunctions = new EnumMap<>(DamageModifier.class);
    modifierFunctions.put(DamageModifier.BASE, damage -> damage);

    EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(source, this, DamageCause.ENTITY_ATTACK, modifiers, modifierFunctions);
    event.setDamage(amount);
    Bukkit.getPluginManager().callEvent(event);
    if (!event.isCancelled())
    {
        setHealth(health - amount);
    }
}
项目:mczone    文件:KitEvents.java   
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    if ((event.getDamager() instanceof Player)) {
        Player p = (Player)event.getDamager();

        if (Kit.getKit(p).getName().equalsIgnoreCase("woodcutter") && (p.getItemInHand().getType().name().contains("_AXE"))) {
            Random r = new Random();

            double multiplier = 1.0D + 1.0D * r.nextDouble() - r.nextDouble() + 0.5D;

            if (multiplier < 1.0D)
                multiplier = 1.0D;
            if (multiplier >= 2.0D) {
                multiplier = 2.0D;
            }
            event.setDamage((int)(event.getDamage() * multiplier));
        }
    }
}
项目:mczone    文件:PetEvents.java   
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    if (event.getDamager() instanceof Player == false)
        return;

    PetInstance pet = PetInstance.get(event.getEntity());

    if (pet == null)
        return;

    event.setCancelled(true);

    if (pet.getOwner().equalsIgnoreCase(((Player) event.getDamager()).getName())) {
        Chat.player((Player) event.getDamager(), "&2[Pets] &aYou have removed your pet. Spawn it with &b/pet spawn");
        pet.despawn();
        pet.setToSpawn(false);
    }
    else {
        Chat.player((Player) event.getDamager(), "&2[Pets] &cBuy pets at www.mczone.co/shop");
    }
}
项目:ArchersBattle    文件:PlayerListener.java   
@EventHandler
public void onDamage(EntityDamageByEntityEvent e) {
    if (e.isCancelled()) {
        return;
    }
    if (!(e.getDamager() instanceof Player)) {
        return;
    }
    Player p = (Player) e.getDamager();
    long left = CooldownManager.getInstance().getLeft(p, 3000);
    if (left == 0) {
        CooldownManager.getInstance().add(p);
        return;
    }
    e.setCancelled(true);
    p.sendMessage(Messages.prefix + Messages.Cooldown.replace("%time%", String.valueOf(left)));
}
项目:UltimateSpawn    文件:BasicFeatures.java   
@EventHandler
public void onEntityDamage(EntityDamageByEntityEvent e) {
    if (ConfigGServerEvent.getConfig().getBoolean("Server.Disable.Damage.Enable")) {
        if (ConfigGServerEvent.getConfig().getBoolean("Server.Disable.Damage.Options.Entity.Enable")) {
      if (ConfigGServerEvent.getConfig().getBoolean("Server.Disable.Damage.Options.Entity.EntityDamageByEntity")) {
        if (!ConfigGServerEvent.getConfig().getBoolean("Server.Disable.Damage.World.All_World")) {
            if (WorldUtils.getWD().contains(e.getEntity().getWorld().getName())) {
                e.setCancelled(true);
                if (e.getEntity() instanceof ItemFrame) {
                      e.setCancelled(true);
                }
            }
        } else {
            e.setCancelled(true);
            if (e.getEntity() instanceof ItemFrame) {
                      e.setCancelled(true);
                }
        }
      }
        }
    }
}
项目:Kineticraft    文件:Parties.java   
@EventHandler(ignoreCancelled = true) // Prevent players from being damaged in the party world unless in a game.
public void onPlayerDamage(EntityDamageEvent evt) {
    if (!isParty(evt.getEntity()))
        return;

    if (!(evt.getEntity() instanceof LivingEntity))
        evt.setCancelled(true); // Default to no damage, if the entity isn't alive.

    if (!(evt.getEntity() instanceof Player))
        return; // If the damaged isn't a player, ignore this next bit that may uncancel it.
    Player p = (Player) evt.getEntity();
    evt.setCancelled(!checkParty(p, PartyGame::allowDamage));
    if (evt instanceof EntityDamageByEntityEvent) { // Handle combat differently.
        EntityDamageByEntityEvent dmg = (EntityDamageByEntityEvent) evt;
        boolean isMob = evt.getEntity() instanceof Creature;
        boolean isPlayer = dmg.getEntity() instanceof Player && dmg.getDamager() instanceof Player;
        evt.setCancelled((!checkParty(p, PartyGame::allowMobCombat) && isMob) || (!checkParty(p, PartyGame::allowPlayerCombat) && isPlayer));
    }
}
项目:Crescent    文件:KillauraB.java   
@Override
public void call(Event event) {
    if (event instanceof EntityDamageByEntityEvent) {
        EntityDamageByEntityEvent edbe = (EntityDamageByEntityEvent) event;

        if (edbe.getCause() != DamageCause.ENTITY_ATTACK) {
            return;
        }

        callback(!isInLineOfSight(edbe.getEntity(), 2.0));
    }
}
项目:AsgardAscension    文件:AbilityListener.java   
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    if(!(event.getEntity() instanceof Player) || !(event.getDamager() instanceof Player))
        return;

    Player player = (Player) event.getDamager();
    Player victim = (Player) event.getEntity();

    if(!Utility.canAttack(player, victim))
        return;

    ItemStack item = player.getInventory().getItemInMainHand();
    if(item == null)
        return;
    if(!plugin.getAbilityManager().hasAbility(item))
        return;

    Ability ability = plugin.getAbilityManager().getAbility(item);

    switch(ability.getName()) {
        case "Poison":
            handlePoison(player, victim);
            return;
        case "Flame":
            handleFlame(player, victim);
            return;
        default:
            return;
    }
}
项目:ZentrelaRPG    文件:DungeonManager.java   
@EventHandler
public void onPlayerHitDungeonDisplay(EntityDamageByEntityEvent event) {
    if (event.getEntityType() == EntityType.ENDER_CRYSTAL) {
        if (event.getDamager() instanceof Player)
            handleBossSpawn(event.getDamager(), event.getEntity());
        event.setCancelled(true);
    } else if (event.getEntityType() == EntityType.ARMOR_STAND) {
        if (event.getDamager() instanceof Player)
            handleRewards(event.getDamager(), event.getEntity());
    }
}
项目:ZentrelaRPG    文件:BuffManager.java   
@EventHandler
public static void onPlayerHitBuffEvent(EntityDamageByEntityEvent event) {
    if (event.getEntityType() == EntityType.ENDER_CRYSTAL) {
        if (event.getDamager() instanceof Player)
            handleBuff(event.getDamager(), event.getEntity());
        else if (event.getDamager() instanceof Projectile) {
            if (((Projectile) event.getDamager()).getShooter() instanceof Player)
                handleBuff(((Player) ((Projectile) event.getDamager()).getShooter()), event.getEntity());
        }
        event.setCancelled(true);
    }
}
项目:HCFCore    文件:CoreListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onHangingDamageByEntity(final EntityDamageByEntityEvent event) {
    final Entity entity = event.getEntity();
    if (entity instanceof Hanging) {
        final Player attacker = BukkitUtils.getFinalAttacker((EntityDamageEvent)event, false);
        if (!attemptBuild((Entity)attacker, entity.getLocation(), ChatColor.GRAY + "You may not build in the territory of %1$s" + ChatColor.GRAY + '.')) {
            event.setCancelled(true);
        }
    }
}
项目:Chambers    文件:GameDamageListener.java   
@EventHandler
public void onDamageByEntity(EntityDamageByEntityEvent event) {
    if (event.isCancelled()) {
        return;
    }
    if (event.getEntity() instanceof Player && event.getDamager() instanceof Player) {
        Game game = Chambers.getInstance().getGameManager().getGame();
        if (game.getInvincibilityTime() > 0) {
            Player damager = (Player) event.getDamager();
            damager.sendMessage(ChatColor.RED + "The invincibility timer is still on.");
            event.setCancelled(true);
        }
    }
}
项目:Scorch    文件:ThunderingStrike.java   
@Override
public void offenseEffect(LivingEntity user, LivingEntity target, EntityDamageByEntityEvent event){

    int randomNum = ThreadLocalRandom.current().nextInt(1, 6 + 1);
    switch (randomNum){
        case 4:
            target.getLocation().getWorld().strikeLightning(target.getLocation());
            break;
    }
}
项目:Scorch    文件:LastHope.java   
@Override
public void offenseEffect(LivingEntity user, LivingEntity target, EntityDamageByEntityEvent event){
    double health = user.getHealth();
    if (health == 3.0 || health == 2.5) {
        event.setDamage(event.getDamage() + 0.5);
    } else if (health == 2.0 || health == 1.5) {
        event.setDamage(event.getDamage() + 1.0);
    } else if (health == 1.0){
        event.setDamage(event.getDamage() + 1.5);
    } else if (health == 0.5){
        event.setDamage(event.getDamage() + 2.0);
    }

}
项目:AsgardAscension    文件:PlayerListener.java   
@EventHandler
public void onDamage(EntityDamageByEntityEvent event) {
    // Cancelling team damage
    if(event.getDamager() instanceof Player && event.getEntity() instanceof Player) {
        Player victim = (Player) event.getEntity();
        Player damager = (Player) event.getDamager();
        if(!Utility.canAttack(victim, damager)){
            event.setCancelled(true);
        }
    }
}
项目:HCFCore    文件:ClaimWandListener.java   
@EventHandler(ignoreCancelled = false, priority = EventPriority.NORMAL)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    if (event.getDamager() instanceof Player) {
        Player player = (Player) event.getDamager();
        if (isClaimingWand(player.getItemInHand())) {
            player.setItemInHand(new ItemStack(Material.AIR, 1));
            plugin.getClaimHandler().clearClaimSelection(player);
        }
    }
}
项目:bskyblock    文件:IslandGuard1_8.java   
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void ArmorStandDestroy(EntityDamageByEntityEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.8 " + "IslandGuard New " + e.getEventName());
    }
    if (!(e.getEntity() instanceof LivingEntity)) {
        return;
    }
    if (!Util.inWorld(e.getEntity())) {
        return;
    }
    final LivingEntity livingEntity = (LivingEntity) e.getEntity();
    if (!livingEntity.getType().equals(EntityType.ARMOR_STAND)) {
        return;
    }
    if (e.getDamager() instanceof Player) {
        Player p = (Player) e.getDamager();
        if (p.isOp() || VaultHelper.hasPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) {
            return;
        }
        // Check if on island
        if (plugin.getIslands().playerIsOnIsland(p)) {
            return;
        }
        // Check island
        Island island = plugin.getIslands().getIslandAt(e.getEntity().getLocation());
        if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.BREAK_BLOCKS)) {
            return;
        }
        if (island != null && island.getFlag(SettingsFlag.BREAK_BLOCKS)) {
            return;
        }
        Util.sendMessage(p, plugin.getLocale(p.getUniqueId()).get("island.protected"));
        e.setCancelled(true);
    }
}
项目:Absorption    文件:PlayerListener.java   
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent e) {
    e.setCancelled(true);

    if(e.getDamager() instanceof Player && e.getEntity() instanceof Player) {
        GamePlayer damager = Absorption.getPlayer((Player) e.getDamager());
        GamePlayer player = Absorption.getPlayer((Player) e.getEntity());

        if(damager == null || player == null) return;

        player.hitByPlayer(damager);
    }
}
项目:AddGun    文件:Guns.java   
/**
 * Doesn't seem to work right now but basically, if you smack someone over the head
 * with the gun instead of shoot it, do less damage.
 * 
 * @param event The hit event
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void weakDamageDirectWithGun(EntityDamageByEntityEvent event) {
    if (event.getDamager() instanceof LivingEntity) {
        LivingEntity damager = (LivingEntity) event.getDamager();
        EntityEquipment equips = damager.getEquipment();
        StandardGun gun = findGun(equips.getItemInMainHand());
        if (gun != null) {
            // modify damage!
            event.setDamage(gun.getBluntDamage());
        }
    }
}