Package org.bukkit.event.entity

Examples of org.bukkit.event.entity.EntityDamageEvent


       
        Location loc = smited.getLocation();
        // smite the player
        smited.getWorld().strikeLightningEffect(loc);
        // set last damage cause for custom death messages
        smited.setLastDamageCause(new EntityDamageEvent(smited, DamageCause.LIGHTNING, 20));
        smited.setHealth(0);
     
        // show the sender a message
        LogHelper.showInfo("smitePlayer#####[" + Nicknames.getNick(smited.getName()), sender);
       
View Full Code Here


      }
    }
   
    target.setHealth(0);
    target.getWorld().createExplosion(target.getLocation(), explosionStrength);
    target.setLastDamageCause(new EntityDamageEvent(target, DamageCause.ENTITY_EXPLOSION, 20));
    LogHelper.showInfo("explodePlayer#####[" + Nicknames.getNick(target.getName()), sender, ChatColor.AQUA);
    if (CommandsEX.getConf().getBoolean("showMessageOnExplode") && sender != target){
      LogHelper.showInfo("explodeRecieveExplode#####[" + Nicknames.getNick(sender.getName()), sender, ChatColor.RED);
    }
   
View Full Code Here

 
  @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
  public void onPlayerDeath(PlayerDeathEvent e){
    FileConfiguration config = CommandsEX.getConf();
    Player victim = e.getEntity();
    EntityDamageEvent damev = victim.getLastDamageCause();
    DamageCause cause;
    if (damev != null){
      cause = damev.getCause();
    } else {
      // unknown
      e.setDeathMessage(replacements(config.getString("deathUnknown"), victim));
      return;
    }
View Full Code Here

    private void onMountDeath(EntityDeathEvent event) {
        // 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
View Full Code Here

        if (entity.isNPC()) npc = entity.getDenizenNPC();
        else if (entity.isPlayer()) player = new dPlayer(entity.getPlayer());

        // If this entity has a stored killer, get it and then
        // remove it from the entityKillers map
        EntityDamageEvent lastDamage = entity.getBukkitEntity().getLastDamageCause();
        if (lastDamage != null && lastDamage instanceof EntityDamageByEntityEvent) {
            context.put("damager", new dEntity(((EntityDamageByEntityEvent) lastDamage).getDamager()));
        }

        PlayerDeathEvent subEvent = null;
View Full Code Here

  }


    private void dealFallDamage(final Player player, final double damage) {
      // TODO: Byte code compatibility ?
    final EntityDamageEvent event = BridgeHealth.getEntityDamageEvent(player, DamageCause.FALL, damage);
        Bukkit.getPluginManager().callEvent(event);
        if (!event.isCancelled()){
          // TODO: account for no damage ticks etc.
          player.setLastDamageCause(event);
            mcAccess.dealFallDamage(player, BridgeHealth.getDamage(event));
        }
        // TODO: let this be done by the damage event (!).
View Full Code Here

  }
 
  @SuppressWarnings("deprecation")
  public static EntityDamageEvent getEntityDamageEvent(final Entity entity, final DamageCause damageCause, final double damage){
    try{
      return new EntityDamageEvent(entity, damageCause, damage);
    }
    catch(IncompatibleClassChangeError e){
      return new EntityDamageEvent(entity, damageCause, (int) Math.round(damage));
    }
  }
View Full Code Here

            Player attacker = null;

            // find attacker

            EntityDamageEvent lastDamageCause = victim.getLastDamageCause();

            if (lastDamageCause instanceof EntityDamageByEntityEvent)
            {
                EntityDamageByEntityEvent entityEvent = (EntityDamageByEntityEvent) lastDamageCause;
View Full Code Here

     * @param deathMessage The original death message
     * @param player The player who died
     * @return the fixed death message
     */
    public static String fixDeathMessage(String deathMessage, Player player) {
        EntityDamageEvent lastDamageCause = player.getLastDamageCause();
        String replaceString = lastDamageCause instanceof EntityDamageByEntityEvent ? StringUtils.getPrettyEntityTypeString(((EntityDamageByEntityEvent) lastDamageCause).getDamager().getType()) : "a mob";

        return deathMessage.replaceAll("(?:\u00A7(?:[0-9A-FK-ORa-fk-or]){1}(?:[\u2764\u25A0]{1,10})){1,2}", replaceString);
    }
View Full Code Here

        return callFakeDamageEvent(attacker, target, DamageCause.ENTITY_ATTACK, new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, damage)));
    }

    @Deprecated
    public static double callFakeDamageEvent(Entity attacker, Entity target, DamageCause damageCause, double damage) {
        EntityDamageEvent damageEvent = attacker == null ? new FakeEntityDamageEvent(target, damageCause, damage) : new FakeEntityDamageByEntityEvent(attacker, target, damageCause, damage);
        mcMMO.p.getServer().getPluginManager().callEvent(damageEvent);

        if (damageEvent.isCancelled()) {
            return 0;
        }

        return damageEvent.getFinalDamage();
    }
View Full Code Here

TOP

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

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.