Java 类org.bukkit.event.entity.EntityDamageEvent.DamageCause 实例源码

项目:Crescent    文件:AntiDamageA.java   
@Override
public void call(Event event) {
    if (event instanceof EntityDamageEvent) {
        final EntityDamageEvent ede = (EntityDamageEvent) event;
        final DamageCause cause = ede.getCause();

        if (cause == DamageCause.FIRE || cause == DamageCause.CONTACT) {
            final Player player = profile.getPlayer();

            if (cause == DamageCause.FIRE && player.getFoodLevel() < 20) {
                // The AntiFire cheat only works when the hunger bar is
                // full.
                return;
            }

            final double previousHealth = player.getHealth();

            // Check a little later.
            Bukkit.getScheduler().runTaskLater(Crescent.getInstance(), () -> {
                if (player.getHealth() > previousHealth - ede.getDamage()) {
                    callback(true);
                }
            }, 2L);
        }
    }
}
项目:Warzone    文件:DamageAPI.java   
/**
 * Inflicts the given damage on an entity.
 *
 * This method will call the appropriate damage method and fire an {@link EntityDamageEvent}.
 *
 * @param entity Entity to inflict damage upon
 * @param damage Amount of half-hearts of damage to inflict
 * @param info {@link DamageInfo} object that details the type of damage
 * @return the final {@link Damage} object (never null)
 *
 * @throws NullPointerException if entity or info is null
 * throws IllegalArgumentExcpetion if hearts is less than zero
 */
public static @Nonnull
Damage inflictDamage(@Nonnull LivingEntity entity, int damage, @Nonnull DamageInfo info) {
    Preconditions.checkNotNull(entity, "living entity");
    Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero");
    Preconditions.checkNotNull(info, "damage info");

    DamageAPIHelper helper = DamageAPIHelper.get();

    EntityDamageEvent event = new EntityDamageEvent(entity, DamageCause.CUSTOM, damage);
    helper.setEventDamageInfo(event, info);

    Bukkit.getPluginManager().callEvent(event);

    if(event.isCancelled()) {
        return null;
    }

    entity.damage(event.getDamage());

    helper.setEventDamageInfo(event, null);

    return helper.getOurEvent(event).toDamageObject();
}
项目: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;
}
项目:Uranium    文件:CraftEventFactory.java   
private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions) {
    EntityDamageEvent event;
    if (damager != null) {
        event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
    } else {
        event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
    }

    callEvent(event);

    if (!event.isCancelled()) {
        event.getEntity().setLastDamageCause(event);
    }

    return event;
}
项目:ZentrelaRPG    文件:EnvironmentManager.java   
@EventHandler
public void onItemDamage(EntityDamageEvent event) {
    if (event.getEntityType() == EntityType.DROPPED_ITEM && (event.getCause() == DamageCause.LAVA || event.getCause() == DamageCause.FIRE_TICK || event.getCause() == DamageCause.FIRE)) {
        Vector v = Vector.getRandom().normalize();
        v = v.setX(v.getX() - 0.5f);
        v = v.setZ(v.getZ() - 0.5f);
        v = v.multiply(0.35);
        if (v.getX() > 0 && v.getX() < 0.10)
            v.setX(0.10);
        if (v.getZ() > 0 && v.getZ() < 0.10)
            v.setZ(0.10);
        if (v.getX() < 0 && v.getX() > -0.10)
            v.setX(-0.10);
        if (v.getZ() < 0 && v.getZ() > -0.10)
            v.setZ(-0.10);
        v.setY(0.3);
        event.getEntity().setVelocity(v);
        event.setCancelled(true);
        RScheduler.schedule(plugin, () -> {
            event.getEntity().setFireTicks(0);
        }, RTicks.seconds(1));
    }
    if (event.getEntityType() == EntityType.ARMOR_STAND && (event.getCause() == DamageCause.LAVA || event.getCause() == DamageCause.FIRE_TICK || event.getCause() == DamageCause.FIRE)) {
        event.setCancelled(true);
    }
}
项目:ProjectAres    文件:DisableDamageModule.java   
public static DisableDamageModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException {
    SetMultimap<DamageCause, PlayerRelation> causes = HashMultimap.create();
    for(Element damageCauseElement : doc.getRootElement().getChildren("disabledamage")) {
        for(Element damageEl : damageCauseElement.getChildren("damage")) {
            DamageCause cause = XMLUtils.parseEnum(damageEl, DamageCause.class, "damage type");
            for(PlayerRelation damagerType : PlayerRelation.values()) {
                // Legacy syntax used "other" instead of "neutral"
                String attrName = damagerType.name().toLowerCase();
                Node attr = damagerType == PlayerRelation.NEUTRAL ? Node.fromAttr(damageEl, attrName, "other")
                                                                  : Node.fromAttr(damageEl, attrName);
                if(XMLUtils.parseBoolean(attr, true)) {
                    causes.put(cause, damagerType);

                    // Bukkit 1.7.10 changed TNT from BLOCK_EXPLOSION to ENTITY_EXPLOSION,
                    // so we include them both to keep old maps working.
                    if(cause == DamageCause.BLOCK_EXPLOSION) {
                        causes.put(DamageCause.ENTITY_EXPLOSION, damagerType);
                    }
                }
            }
        }
    }
    return new DisableDamageModule(causes);
}
项目: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);
        }
    }
}
项目:SkyWarsReloaded    文件:LobbyListener.java   
@EventHandler
public void onEntityDamage(EntityDamageEvent e) {
    Entity ent = e.getEntity();
     if(ent instanceof Player) {
         if (!hasIgnorePermission((Player) ent)) {
             if (inLobbyWorld((Player) ent) && SkyWarsReloaded.getCfg().LobbyFallDamageDisabled()) {
                    if (e.getCause().equals(DamageCause.FALL)) {
                        e.setCancelled(true);
                    }
             }
             if (inLobbyWorld((Player) ent) && SkyWarsReloaded.getCfg().damageDisabled()) {
                    if (!e.getCause().equals(DamageCause.VOID)) {
                        e.setCancelled(true);
                    }
             }
         }
     }
}
项目:MockBukkit    文件:PlayerMock.java   
@Override
public void damage(double amount)
{
    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);

    EntityDamageEvent event = new EntityDamageEvent(this, DamageCause.CUSTOM, modifiers, modifierFunctions);
    event.setDamage(amount);
    Bukkit.getPluginManager().callEvent(event);
    if (!event.isCancelled())
    {
        setHealth(health - amount);
    }
}
项目: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 Stomper(EntityDamageEvent e) {
    if (e.getEntity() instanceof Player) {
        Player p = (Player) e.getEntity();
        if (Kit.getKit(p).getName().equalsIgnoreCase("stomper")) {
            if (e.getCause() == DamageCause.FALL) {
                List<Entity> nearbyEntities = e.getEntity()
                        .getNearbyEntities(5, 5, 5);
                for (Entity target : nearbyEntities) {
                    if (target instanceof Player) {
                        Player t = (Player) target;
                        if (Team.getTeam(p) == Team.getTeam(t))
                            continue;
                        if (t.isSneaking())
                            t.damage(e.getDamage() / 2, e.getEntity());
                        else
                            t.damage(e.getDamage(), e.getEntity());
                    }
                }
                e.setDamage(0);
            }
        }
    }
}
项目:mczone    文件:Events.java   
@EventHandler
public void onPlayerDamage(EntityDamageEvent event) {
    if (!(event.getEntity() instanceof Player))
        return;
    event.setCancelled(true);

    if (event.getCause()==DamageCause.VOID) {
        Location l = event.getEntity().getWorld().getSpawnLocation();
        l.setX(14.5);
        l.setY(10.5);
        l.setZ(-795.5);
        l.setPitch(0.5F);
        l.setYaw(90 * RandomUtil.between(1, 4));
        event.getEntity().teleport(l);
    }
}
项目: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()))));
                    }
                }
            }
        }
    }
}
项目:BiteSkywars    文件:PlayerListener.java   
@EventHandler
public void onCancell(EntityDamageEvent event){
Entity e = event.getEntity();
if(!(e instanceof Player)){
    return;
}
Player p = (Player)e;
Arena a = new ArenaManager().getArena(p);

if(a==null){
    event.setCancelled(true);
    return;
}
if(a.isEnd()){
    event.setCancelled(true);

}
if(a.fallMode()==true){
    if(event.getCause() == DamageCause.FALL||event.getCause() == DamageCause.VOID){
    event.setCancelled(true);
    }
}
}
项目:AthenaGM    文件:DeathMessageModule.java   
/**
 * Suppress regular death messages, replacing them with custom ones local to the player's Match
 */
@EventHandler
public void onAthenaDeath(AthenaDeathEvent event) {
    DamageCause cause = event.getPlayer().getLastDamageCause().getCause();
    if (event.isPvP()) {
        switch (cause) {
            case FALL:
                handleGroundFall(event);
                break;
            case PROJECTILE:
                handleProjectile(event);
                break;
            case VOID:
                handleVoid(event);
                break;
            default:
                broadcast(event, event.getDeathEvent().getDeathMessage());
        }
    } else {
        broadcast(event, event.getDeathEvent().getDeathMessage());
    }
    event.getDeathEvent().setDeathMessage(null); //disable vanilla death broadcast
}
项目:TreysDoubleJump    文件:NoFallDamage.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void noFall(EntityDamageEvent e) {
    if (ConfigManager.getConfig().getBoolean("NoFall.Enabled")){
        if (e.getEntity() instanceof Player){
            Player p = (Player) e.getEntity();
            if (p.hasPermission("tdj.nofall")){
                if (!DoubleJumpCommand.DisablePlayers.contains(p.getUniqueId().toString())){
                    if (ConfigManager.getConfig().getStringList("EnabledWorlds").contains(p.getWorld().getName())){
                        if (e.getCause().equals(DamageCause.FALL)){
                            e.setCancelled(true);
                        }
                    }
                }
            }
        }
    }
}
项目:Skript    文件:DefaultComparators.java   
@Override
public Relation compare(final DamageCause dc, final EntityData e) {
    switch (dc) {
        case ENTITY_ATTACK:
            return Relation.get(e.isSupertypeOf(EntityData.fromClass(Entity.class)));
        case PROJECTILE:
            return Relation.get(e.isSupertypeOf(EntityData.fromClass(Projectile.class)));
        case WITHER:
            return Relation.get(e.isSupertypeOf(EntityData.fromClass(Wither.class)));
        case FALLING_BLOCK:
            return Relation.get(e.isSupertypeOf(EntityData.fromClass(FallingBlock.class)));
            //$CASES-OMITTED$
        default:
            return Relation.NOT_EQUAL;
    }
}
项目:Skript    文件:ClassesTest.java   
@Test
public void test() {
    final Object[] random = {
            // Java
            (byte) 127, (short) 2000, -1600000, 1L << 40, -1.5f, 13.37,
            "String",

            // Skript
            Color.BLACK, StructureType.RED_MUSHROOM, WeatherType.THUNDER,
            new Date(System.currentTimeMillis()), new Timespan(1337), new Time(12000), new Timeperiod(1000, 23000),
            new Experience(15), new Direction(0, Math.PI, 10), new Direction(new double[] {0, 1, 0}),
            new EntityType(new SimpleEntityData(HumanEntity.class), 300), new CreeperData(), new SimpleEntityData(Snowball.class), new HorseData(Variant.SKELETON_HORSE), new WolfData(), new XpOrbData(50),

            // Bukkit - simple classes only
            GameMode.ADVENTURE, Biome.EXTREME_HILLS, DamageCause.FALL,

            // there is also at least one variable for each class on my test server which are tested whenever the server shuts down.
    };

    for (final Object o : random) {
        Classes.serialize(o); // includes a deserialisation test
    }
}
项目:world-of-icerealm    文件:LightningReflexesPerk.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerHit(EntityDamageEvent evt) {
    if (evt.getEntity() instanceof Player) {
        if (evt.getCause().equals(DamageCause.ENTITY_ATTACK) || evt.getCause().equals(DamageCause.PROJECTILE)) {
            Player player = (Player)evt.getEntity();

            if (perkService.playerHasPerk(player, ArcherTree.LightningReflexesId)) {
                if (windRunPerk.isActive(player) && new Random(Calendar.getInstance().getTimeInMillis()).nextInt(99) < 90) {
                    evt.setCancelled(true);
                } else if (new Random(Calendar.getInstance().getTimeInMillis()).nextInt(5) == 1) {
                    evt.setCancelled(true);
                }
            }
        }
    }
}
项目:world-of-icerealm    文件:Mayhem.java   
@EventHandler(priority = EventPriority.NORMAL)
public void monsterDies(EntityDeathEvent event) {

    if (_apocalypseOn && event.getEntity().getLastDamageCause().getCause() != DamageCause.FIRE_TICK) {

        if (event.getEntity() instanceof Monster) {
            _monsterDead++;
        }

        if (_monsterDead >= _maxMonsters) {
            _completed = true;
            distributeLoot();
            resetEvent();
        }       

        try {
            _spawner.spawnMonsterCloseToPlayer(event.getEntity().getLocation());
        }
        catch (Exception ex) {
            _logger.info("exception raised in Mayhem.monsterDies(EntityDeathEvent event) while using the ApocalypseSpawner");
        }

    }
}
项目:world-of-icerealm    文件:CustomMonsterListener.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onMonsterDamage(EntityDamageEvent event) {      

    if (event instanceof EntityDamageByEntityEvent) {

        EntityDamageByEntityEvent damageEvent = (EntityDamageByEntityEvent)event;
        CustomMonster damager = _damageMonsters.get(damageEvent.getDamager().getEntityId());

        if (damager != null && damageEvent.getDamager() instanceof Monster && event.getEntity() instanceof Player) {
            int damageDone = (int)(event.getDamage() + (2 * (int)damager.DamageModifier));
            //logger.info("damage done is: " + damageDone + " modifier is: " + (int)damager.DamageModifier + " base damage is: " + event.getDamage());
            event.setDamage(damageDone);
        }
    }

    CustomMonster noBurn = _noBurnMonsters.get(event.getEntity().getEntityId());
    if (noBurn != null && event.getEntity() instanceof Monster && event.getCause() == DamageCause.FIRE_TICK) {
        event.setCancelled(true);
        event.getEntity().setFireTicks(0);
    }
}
项目:ThermosRebased    文件:CraftEventFactory.java   
private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions) {
    EntityDamageEvent event;
    if (damager != null) {
        event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
    } else {
        event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
    }

    callEvent(event);

    if (!event.isCancelled()) {
        event.getEntity().setLastDamageCause(event);
    }

    return event;
}
项目:Breakpoint    文件:FlagManager.java   
private void damagePlayer(Player target)
{   
    if (!target.isDead())
    {
        if (target.getGameMode() == GameMode.CREATIVE)
            return;

        double newHealth = ((Damageable) target).getHealth() - 1;

        if (newHealth < 0)
            newHealth = 0;

        target.setHealth(newHealth);
        target.setLastDamageCause(new EntityDamageEvent(target, DamageCause.CUSTOM, 1.0));
    }
}
项目:Breakpoint    文件:PVPListener.java   
private void hitByEntityExplosion(EntityDamageByEntityEvent event, BPPlayer bpDamager, Player shooter, BPPlayer bpVictim, Player victim)
    {
//      Entity exploded = event.getDamager();
//      if(exploded instanceof Projectile)
//      {
//          if(shooter != null)
//          {
//              CTFProperties damagerProps = (CTFProperties) bpDamager.getGameProperties();
//              if(damagerProps.isEnemy(bpVictim))
//              {
                    EntityDamageEvent dmgCause = new EntityDamageByEntityEvent(shooter, victim, DamageCause.ENTITY_ATTACK, event.getDamage());
                    victim.setLastDamageCause(dmgCause);
                    return;
//              }
//          }
//          
//          event.setCancelled(true);
//      }
    }
项目:AnnihilationPro    文件:Thor.java   
@EventHandler(priority= EventPriority.NORMAL)
public void checkStrike(EntityDamageEvent event)
{
    if(event.getEntityType() == EntityType.PLAYER && event.getCause() == DamageCause.LIGHTNING)
    {
        AnniPlayer player = AnniPlayer.getPlayer(event.getEntity().getUniqueId());
        if(player != null && !player.getKit().equals(this))
        {
            Object obj = player.getData("LH");
            if(obj != null)
            {
                Long l = (Long)obj;
                if(System.currentTimeMillis()-l <= 30000)
                {
                    event.setCancelled(true);
                    player.setData("LH", null);
                    return;
                }
            }
            event.setDamage(4);
            player.setData("LH", System.currentTimeMillis());
        }
    }
}
项目:QuestManager    文件:ReflectEffect.java   
@EventHandler
public void onUserDamaged(EntityDamageByEntityEvent e) {
    if (victims.isEmpty())
        return;

    if (e.getCause() == DamageCause.CUSTOM)
        return;

    if (e.getEntity() instanceof LivingEntity)
        for (UserRecord record : victims)
        if (record.user.getEntity() != null && record.user.getEntity().getUniqueId().equals(e.getEntity().getUniqueId())) {
            //activate
            double amount;
            if (percentage)
                amount = damage * e.getFinalDamage();
            else
                amount = damage;

            e.setDamage(e.getDamage() - amount);
            ((LivingEntity) e.getDamager()).damage(amount, e.getEntity());

            return;
        }
}
项目:Cardinal-Plus    文件:DisableDamage.java   
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
    if (damageTypes.contains(event.getCause()) && (event.getCause() != DamageCause.BLOCK_EXPLOSION || event.getCause() != DamageCause.ENTITY_EXPLOSION)) {
        event.setCancelled(true);
    } else if (event.getCause() == DamageCause.BLOCK_EXPLOSION || event.getCause() == DamageCause.ENTITY_EXPLOSION) {
        if (event instanceof EntityDamageByEntityEvent) {
            if (event.getEntity() instanceof Player && TntTracker.getWhoPlaced(((EntityDamageByEntityEvent) event).getDamager()) != null) {
                Player player = (Player) event.getEntity();
                UUID source = TntTracker.getWhoPlaced(((EntityDamageByEntityEvent) event).getDamager());
                Match match = GameHandler.getGameHandler().getMatch();
                if (Bukkit.getOfflinePlayer(source).isOnline()) {
                    if (Bukkit.getPlayer(source).equals(player)) {
                        event.setCancelled(!blockExplosionSelf);
                    } else if (TeamUtils.getTeamByPlayer(Bukkit.getPlayer(source)) == TeamUtils.getTeamByPlayer(player)) {
                        event.setCancelled(!blockExplosionAlly);
                    } else if (TeamUtils.getTeamByPlayer(Bukkit.getPlayer(source)) != TeamUtils.getTeamByPlayer(player)) {
                        event.setCancelled(!blockExplosionEnemy);
                    } else {
                        event.setCancelled(!blockExplosionOther);
                    }
                }
            }
        } else if (damageTypes.contains(DamageCause.BLOCK_EXPLOSION)) event.setCancelled(true);
    }
}
项目:Thermos    文件:CraftEventFactory.java   
private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions) {
    EntityDamageEvent event;
    if (damager != null) {
        event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
    } else {
        event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
    }

    callEvent(event);

    if (!event.isCancelled()) {
        event.getEntity().setLastDamageCause(event);
    }

    return event;
}
项目:KCauldron    文件:CraftEventFactory.java   
private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions) {
    EntityDamageEvent event;
    if (damager != null) {
        event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
    } else {
        event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
    }

    callEvent(event);

    if (!event.isCancelled()) {
        event.getEntity().setLastDamageCause(event);
    }

    return event;
}
项目:CauldronGit    文件:CraftEventFactory.java   
private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions) {
    EntityDamageEvent event;
    if (damager != null) {
        event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
    } else {
        event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
    }

    callEvent(event);

    if (!event.isCancelled()) {
        event.getEntity().setLastDamageCause(event);
    }

    return event;
}
项目:BiteSkywars    文件:PlayerListener.java   
@EventHandler
public void onCancell(EntityDamageEvent event){
Entity e = event.getEntity();
if(!(e instanceof Player)){
    return;
}
Player p = (Player)e;
Arena a = new ArenaManager().getArena(p);

if(a==null){
    event.setCancelled(true);
    return;
}
if(a.isEnd()){
    event.setCancelled(true);

}
if(a.fallMode()==true){
    if(event.getCause() == DamageCause.FALL||event.getCause() == DamageCause.VOID){
    event.setCancelled(true);
    }
}
}
项目:Cauldron-Old    文件:CraftEventFactory.java   
private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions) {
    EntityDamageEvent event;
    if (damager != null) {
        event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
    } else {
        event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
    }

    callEvent(event);

    if (!event.isCancelled()) {
        event.getEntity().setLastDamageCause(event);
    }

    return event;
}
项目:Cauldron-Reloaded    文件:CraftEventFactory.java   
private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions) {
    EntityDamageEvent event;
    if (damager != null) {
        event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
    } else {
        event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
    }

    callEvent(event);

    if (!event.isCancelled()) {
        event.getEntity().setLastDamageCause(event);
    }

    return event;
}
项目:FFoKC    文件:CraftEventFactory.java   
private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions) {
    EntityDamageEvent event;
    if (damager != null) {
        event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
    } else {
        event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
    }

    callEvent(event);

    if (!event.isCancelled()) {
        event.getEntity().setLastDamageCause(event);
    }

    return event;
}
项目:CraftBukkit    文件:CraftEventFactory.java   
private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions) {
    EntityDamageEvent event;
    if (damager != null) {
        event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
    } else {
        event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
    }

    callEvent(event);

    if (!event.isCancelled()) {
        event.getEntity().setLastDamageCause(event);
    }

    return event;
}
项目:AncientGates    文件:PluginEntityListener.java   
@EventHandler
public void onEntityDamage(final EntityDamageEvent event) {

    if (event.getCause() == DamageCause.DROWNING || event.getCause() == DamageCause.SUFFOCATION || event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK || event.getCause() == DamageCause.LAVA) {

        // Ok so an entity damage event begins
        // Find the nearest gate!
        final WorldCoord entityCoord = new WorldCoord(event.getEntity().getLocation());
        final WorldCoord entityCoordUp = new WorldCoord(event.getEntity().getLocation().getBlock().getRelative(BlockFace.UP));
        final Gate nearestGate = GateUtil.nearestGate(entityCoord, false);
        final Gate nearestGateUp = GateUtil.nearestGate(entityCoordUp, false);

        if (nearestGate != null || nearestGateUp != null) {
            event.setCancelled(true);
            event.getEntity().setFireTicks(0);
        }
    }
}
项目:Ultra-Hardcore-1.8    文件:UhcDmg.java   
private String[] fE(DamageCause a) {
    switch (a) {
    case DROWNING:
        return o("Drowning");
    case FALL:
        return o("Fall");
    case FIRE:
        return o("Fire");
    case FIRE_TICK:
        return o("Burning");
    case FLY_INTO_WALL:
        return o("Fly Into Wall");
    case MAGIC:
    case POISON:
        return o("Poison");
    case SUFFOCATION:
        return o("Suffocation");
    case STARVATION:
        return o("Starvation");
    case WITHER:
        return o("Wither Poison");
    default:
        return o("Unknown 0x3." + a.ordinal() + " {" + a + "}");
    }
}
项目:Ultra-Hardcore-1.8    文件:EvGame.java   
@EventHandler
public void damager(EntityDamageEvent a) {
    if (eA.mC.cFa && eA.mA.i() > 3 && eA.mA.i() < 7 && a.getEntity() instanceof Player) {
        if (eA.mA.i() != 6 && a.getCause().equals(DamageCause.VOID)) {
            a.getEntity().teleport(a.getEntity().getWorld().getSpawnLocation().add(0.5, 1, 0.5), TeleportCause.PLUGIN);
            a.getEntity().setFallDistance(0f);
        }
        a.setCancelled(true);
        return;
    }
    if (eA.mC.cOa && eA.mA.i() == 7 && a.getEntity() instanceof Player) {
        UHCPlayer b = eA.mB.getPlayer(a.getEntity().getName());
        if (eA.mE.getIngamePlayers().contains(b.uB.getName())) {
            b.dmgStorage(eA.mE.gL, a.getDamage(), eA.mE.gF.source(a));
        }
    }
}
项目:Breakpoint    文件:FlagManager.java   
private void damagePlayer(Player target)
{   
    if (!target.isDead())
    {
        if (target.getGameMode() == GameMode.CREATIVE)
            return;

        double newHealth = ((Damageable) target).getHealth() - 1;

        if (newHealth < 0)
            newHealth = 0;

        target.setHealth(newHealth);
        target.setLastDamageCause(new EntityDamageEvent(target, DamageCause.CUSTOM, 1.0));
    }
}