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

项目:MagicAPI    文件:MagicMobDeathEvent.java   
public MagicMobDeathEvent(MageController controller, EntityData entityData, EntityDeathEvent deathEvent) {
    this.controller = controller;
    this.entityData = entityData;
    this.deathEvent = deathEvent;

    LivingEntity killed = deathEvent.getEntity();
    EntityDamageEvent damageEvent = killed.getLastDamageCause();
    if (damageEvent instanceof EntityDamageByEntityEvent)
    {
        EntityDamageByEntityEvent damageByEvent = (EntityDamageByEntityEvent)damageEvent;
        Entity damagingEntity = damageByEvent.getDamager();
        if (damagingEntity instanceof Projectile) {
            Projectile projectile = (Projectile)damagingEntity;
            damagingEntity = (LivingEntity)projectile.getShooter();
        }
        if (damagingEntity != null && damagingEntity instanceof Player)
        {
            player = (Player)damagingEntity;
            mage = controller.getRegisteredMage(player.getUniqueId().toString());
        }
    }
}
项目:bskyblock    文件:IslandGuard.java   
/**
 * Drops the Enderman's block when he dies if he has one
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEndermanDeath(final EntityDeathEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!Settings.endermanDeathDrop)
        return;
    if (!Util.inWorld(e.getEntity())) {
        return;
    }
    if (!(e.getEntity() instanceof Enderman)) {
        // plugin.getLogger().info("Not an Enderman!");
        return;
    }
    // Get the block the enderman is holding
    Enderman ender = (Enderman) e.getEntity();
    MaterialData m = ender.getCarriedMaterial();
    if (m != null && !m.getItemType().equals(Material.AIR)) {
        // Drop the item
        // plugin.getLogger().info("Dropping item " + m.toString());
        e.getEntity().getWorld().dropItemNaturally(e.getEntity().getLocation(), m.toItemStack(1));
    }
}
项目:WC    文件:WorldInteract.java   
@EventHandler
public void onMobDie(EntityDeathEvent e){
    AllItems items = new AllItems();
    Location l = e.getEntity().getLocation();
    World w = l.getWorld();

    e.getDrops().clear();
    e.setDroppedExp(0);

    if (e.getEntity() instanceof Zombie){
        if (new Random().nextInt(5) >= 3){
            w.dropItemNaturally(l, new ItemMaker(Material.EMERALD).setAmount(new Random().nextInt(4) + 1).build());
            if (new Random().nextBoolean()){
                w.dropItemNaturally(l, items.weapons.get(new Random().nextInt(items.weapons.size())));
            } else {
                w.dropItemNaturally(l, items.health.get(new Random().nextInt(items.health.size())));
            }
        }
    }

    if (e.getEntity() instanceof Giant){
        if (new Random().nextInt(5) > 3){
            w.dropItemNaturally(l, new ItemMaker(Material.NETHER_STAR).setAmount(new Random().nextInt(4) + 1).build());
        }
    }
}
项目:OpenUHC    文件:GoldenFleece.java   
/**
 * Utilizes a random chance to either spawn a skeleton with gold armor or resources.
 *
 * @param event The event
 */
@EventHandler
public void onEntityDeath(EntityDeathEvent event) {
  Entity entity = event.getEntity();
  if (entity instanceof Sheep) {
    double chance = Math.random();
    if (0.25 > chance) {
      Skeleton skeleton = entity.getWorld().spawn(entity.getLocation(), Skeleton.class);
      skeleton.getEquipment().setArmorContents(
          new ItemStack[]{
              new ItemStack(Material.GOLD_HELMET),
              new ItemStack(Material.GOLD_CHESTPLATE),
              new ItemStack(Material.GOLD_LEGGINGS),
              new ItemStack(Material.GOLD_BOOTS)
          }
      );
    } else if (0.5 > chance) {
      event.getDrops().add(new ItemStack(Material.IRON_INGOT));
    } else if (0.75 > chance) {
      event.getDrops().add(new ItemStack(Material.GOLD_INGOT));
    } else {
      event.getDrops().add(new ItemStack(Material.DIAMOND));
    }
  }
}
项目:SurvivalAPI    文件:RapidFoodModule.java   
/**
 * Drop cooked food
 * 
 * @param event Event
 */
@EventHandler
public void onEntityDeath(EntityDeathEvent event)
{
    LivingEntity entity = event.getEntity();
    List<ItemStack> newDrops = null;

    if (this.drops.containsKey(entity.getType()))
    {
        newDrops = new ArrayList<>();

        for (ConfigurationBuilder.IRapidFoodHook rapidFoodHook : this.drops.get(entity.getType()))
            newDrops.addAll(rapidFoodHook.getDrops(event.getDrops(), this.random));
    }

    if (newDrops != null && !newDrops.isEmpty())
    {
        event.getDrops().clear();
        event.getDrops().addAll(newDrops);
    }

    event.setDroppedExp(event.getDroppedExp() * 2);
}
项目:Kineticraft    文件:Pinata.java   
@EventHandler
public void onEntityDeath(EntityDeathEvent evt) { // If a pinata is killed, have a 12% chance of dropping something extra.
    if (evt.getEntity() instanceof Zombie && getArena().contains(evt.getEntity().getLocation()) && Utils.randChance(8))
        evt.getDrops().add(Utils.randElement(
                ItemManager.createItem(Material.DIAMOND, ChatColor.AQUA + "Rock Candy", "So delicious, so rare."),
                ItemManager.createItem(Material.CAKE, ChatColor.LIGHT_PURPLE + "Birthday Cake", "Happy 3rd Anniversary, Kineticraft!"),
                ItemManager.createItem(Material.SEA_LANTERN, ChatColor.RED + "Jaw Breaker", "Suck it, Piñatas!"),
                ItemManager.createItem(Material.IRON_BLOCK, ChatColor.RED + "Hershey's Kiss", "Mmmm, so chocolatey."),
                ItemManager.createItem(Material.TNT, ChatColor.LIGHT_PURPLE + "Pop Rocks", "An explosion for your taste buds."),
                ItemManager.createItem(Material.MAGMA_CREAM, ChatColor.RED + "Atomic Fireball", "It burns so good."),
                ItemManager.createItem(Material.EXP_BOTTLE, ChatColor.AQUA + "Soda", "Refreshing and fizzy."),
                ItemManager.createItem(Material.SLIME_BALL, ChatColor.AQUA + "Taffy", "Chewy...careful not to glue your teeth together!"),
                ItemManager.createItem(Material.NETHER_STALK, ChatColor.RED + "Twizzlers", "Gimme some sugar."),
                ItemManager.createItem(Material.MYCEL, ChatColor.RED + "Fudge", "What the fudge!?"),
                ItemManager.createItem(Material.WEB, ChatColor.LIGHT_PURPLE + "Cotton Candy", "So fluffy!"),
                ItemManager.createItem(Material.RAW_FISH, (byte) 1, ChatColor.LIGHT_PURPLE + "Swedish Fish", "A yummy, gummy candy."),
                ItemManager.createItem(Material.RED_ROSE, (byte) 2, ChatColor.AQUA + "Lollipop", "I'm a sucker for puns."),
                ItemManager.createItem(Material.COOKIE, ChatColor.YELLOW + "Birthday Cookie", "You're one smart cookie!"),
                ItemManager.createItem(Material.BLAZE_ROD, ChatColor.RED + "Hot Tamale", "You're one hot Tamale!"),
                ItemManager.createItem(Material.PUMPKIN_PIE, ChatColor.GOLD + "Seasonal Treat", "Pumpkin Spice flavor ALL THE THINGS!"),
                ItemManager.createItem(Material.EMERALD, ChatColor.GREEN + "Gumball", "I chews you! <3"),
                ItemManager.createItem(Material.GOLDEN_APPLE, ChatColor.GOLD + "Caramel Apple", "...and we lived apple-y ever after <3"),
                ItemManager.createItem(Material.HUGE_MUSHROOM_2, ChatColor.RED + "Strawberry Bon Bon", "You're the berry best."),
                evt.getEntity().getEquipment().getHelmet(),
                evt.getEntity().getEquipment().getItemInMainHand()));
}
项目:HCFCore    文件:ExpMultiplierListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onEntityDeath(EntityDeathEvent event) {
    double amount = event.getDroppedExp();
    Player killer = event.getEntity().getKiller();
    if (killer != null && amount > 0) {
        ItemStack stack = killer.getItemInHand();
        if (stack != null && stack.getType() != Material.AIR) {
            int enchantmentLevel = stack.getEnchantmentLevel(Enchantment.LOOT_BONUS_MOBS);
            if (enchantmentLevel > 0L) {
                double multiplier = enchantmentLevel * SettingsYML.EXP_MULTIPLIER_LOOTING_PER_LEVEL;
                int result = (int) Math.ceil(amount * multiplier);
                event.setDroppedExp(result);
            }
        }
    }
}
项目:HCFCore    文件:ExpMultiplierListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onEntityDeath(EntityDeathEvent event) {
    double amount = event.getDroppedExp();
    Player killer = event.getEntity().getKiller();
    if (killer != null && amount > 0) {
        ItemStack stack = killer.getItemInHand();
        if (stack != null && stack.getType() != Material.AIR) {
            int enchantmentLevel = stack.getEnchantmentLevel(Enchantment.LOOT_BONUS_MOBS);
            if (enchantmentLevel > 0L) {
                double multiplier = enchantmentLevel * SettingsYML.EXP_MULTIPLIER_LOOTING_PER_LEVEL;
                int result = (int) Math.ceil(amount * multiplier);
                event.setDroppedExp(result);
            }
        }
    }
}
项目:PA    文件:GameEvents.java   
@EventHandler
public void onEntityDeath(EntityDeathEvent e) {
    if (e.getEntity() instanceof Monster && e.getEntity().getKiller() instanceof Player) {
        TOAUser u = TOA.getPlayer(e.getEntity().getKiller());
        String name = e.getEntity().getCustomName().split(" ")[1];
        int level = Utils.isInt(name) ? Integer.parseInt(name) : 0;

        new Experience(u).addExp(Mob.getXP(level));

        e.getDrops().clear();
        e.setDroppedExp(0);

        Drop.drop(MobType.parseMobType(e.getEntityType()), u.getUserData().getKit()).forEach(d -> {
            BagEvents.addItem(u, d);
            u.sendSound(Sounds.ITEM_PICKUP);
        });

        if (plugin.getSpawnTask().getCount() == 0) return;
        plugin.getSpawnTask().setCount(plugin.getSpawnTask().getCount() - 1);
    }
}
项目:AsgardAscension    文件:ChallengeListener.java   
@EventHandler
public void onMobDeath(EntityDeathEvent event) {
    if(event.getEntity() instanceof Entity){
        Entity e = (Entity) event.getEntity();
        if(e.hasMetadata("challenge")){
            event.getDrops().clear();
            String[] meta = e.getMetadata("challenge").get(0).asString().split(", ");
            final String player = meta[1];
            plugin.getChallenges().addKill(Bukkit.getPlayer(player));
            Bukkit.getPlayer(player).setLevel(plugin.getChallenges().getKillsLeft(Bukkit.getPlayer(player)));
            if(e.getType().equals(EntityType.MAGMA_CUBE) || e.getType().equals(EntityType.SLIME)) {
                e.remove();
            }
            if(plugin.getChallenges().getKillsLeft(Bukkit.getPlayer(player)) == 0){
                plugin.getChallenges().finishChallenge(Bukkit.getPlayer(player), false);
            }
        }
    }
}
项目:DragonEggDrop    文件:DragonLifeListeners.java   
@EventHandler
public void onDragonDeath(EntityDeathEvent event) {
    if (!(event.getEntity() instanceof EnderDragon)) return;

    EnderDragon dragon = (EnderDragon) event.getEntity();
    DragonBattle dragonBattle = plugin.getNMSAbstract().getEnderDragonBattleFromDragon(dragon);

    World world = event.getEntity().getWorld();
    EndWorldWrapper worldWrapper = plugin.getDEDManager().getWorldWrapper(world);

    BattleStateChangeEvent bscEventCrystals = new BattleStateChangeEvent(dragonBattle, dragon, BattleState.BATTLE_COMMENCED, BattleState.BATTLE_END);
    Bukkit.getPluginManager().callEvent(bscEventCrystals);

    new BukkitRunnable() {
        @Override
        public void run() {
            if (plugin.getNMSAbstract().getEnderDragonDeathAnimationTime(dragon) >= 185) { // Dragon is dead at 200
                new DragonDeathRunnable(plugin, worldWrapper, dragon);
                this.cancel();
            }
        }
    }.runTaskTimer(plugin, 0L, 1L);
}
项目:BukkitPluginDevelopment    文件:Main.java   
@EventHandler(ignoreCancelled = true)
public void kill(EntityDeathEvent e) {
    // 殺されたエンティティ
    LivingEntity entity = e.getEntity();
    // エンティティを殺したプレイヤー
    Player player = entity.getKiller();

    // null=プレイヤーが殺したのではないなら
    if (player == null) {
        return; // 何もしない
    }

    // 出力する
    player.sendMessage("このMOBはスポナーから沸いたMOB" +
            (isSpawnerSpawn(entity) ? "です。" : "ではありません。")); // <-三項演算子、説明は要らないよね?
}
项目:Skript    文件:ExprAttackerAlt.java   
private static Object getAttacker(final Event e) {
    if (e instanceof EntityDamageByEntityEvent) {
        if (((EntityDamageByEntityEvent) e).getDamager() instanceof Projectile) {
            return ((Projectile) ((EntityDamageByEntityEvent) e).getDamager()).getShooter();
        }
        return ((EntityDamageByEntityEvent) e).getDamager();
    } else if (e instanceof EntityDamageByBlockEvent) {
        return ((EntityDamageByBlockEvent) e).getDamager();
    } else if (e instanceof EntityDeathEvent) {
        return getAttacker(((EntityDeathEvent) e).getEntity().getLastDamageCause());
    } else if (e instanceof VehicleDamageEvent) {
        return ((VehicleDamageEvent) e).getAttacker();
    } else if (e instanceof VehicleDestroyEvent) {
        return ((VehicleDestroyEvent) e).getAttacker();
    }
    return null;
}
项目:Skript    文件:ExprAttacked.java   
@SuppressWarnings("unchecked")
@Override
public boolean init(final Expression<?>[] vars, final int matchedPattern, final Kleenean isDelayed, final ParseResult parser) {
    if (!ScriptLoader.isCurrentEvent(EntityDamageEvent.class, EntityDeathEvent.class)) {
        Skript.error("The expression 'victim' can only be used in a damage or death event", ErrorQuality.SEMANTIC_ERROR);
        return false;
    }
    final String type = parser.regexes.size() == 0 ? null : parser.regexes.get(0).group();
    if (type == null) {
        this.type = EntityData.fromClass(Entity.class);
    } else {
        final EntityData<?> t = EntityData.parse(type);
        if (t == null) {
            Skript.error("'" + type + "' is not an entity type", ErrorQuality.NOT_AN_EXPRESSION);
            return false;
        }
        this.type = t;
    }
    return true;
}
项目:Skript    文件:ExprAttacker.java   
@Nullable
    private static Entity getAttacker(final @Nullable Event e) {
        if (e == null)
            return null;
        if (e instanceof EntityDamageByEntityEvent) {
            if (((EntityDamageByEntityEvent) e).getDamager() instanceof Projectile) {
                final Object o = ProjectileUtils.getShooter((Projectile) ((EntityDamageByEntityEvent) e).getDamager());
                if (o instanceof Entity)
                    return (Entity) o;
                return null;
            }
            return ((EntityDamageByEntityEvent) e).getDamager();
//      } else if (e instanceof EntityDamageByBlockEvent) {
//          return ((EntityDamageByBlockEvent) e).getDamager();
        } else if (e instanceof EntityDeathEvent) {
            return getAttacker(((EntityDeathEvent) e).getEntity().getLastDamageCause());
        } else if (e instanceof VehicleDamageEvent) {
            return ((VehicleDamageEvent) e).getAttacker();
        } else if (e instanceof VehicleDestroyEvent) {
            return ((VehicleDestroyEvent) e).getAttacker();
        }
        return null;
    }
项目:world-of-icerealm    文件:KillObjective.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onEntityDeath(EntityDeathEvent event) {
    Entity killedEntity = event.getEntity();

    if (killedEntity instanceof LivingEntity) {
        LivingEntity livingEntity = (LivingEntity)killedEntity;
        Player killer = livingEntity.getKiller();

        if (killer != null && getPlayer() == killer) {
            if (entityIds.contains(EntityUtilities.getEntityId(livingEntity)) && 
                (getZone() == null || getZone().isInside(livingEntity.getLocation()))) {
                advance();
            }
        }
    }
}
项目:world-of-icerealm    文件:MonsterFuryListener.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onEntityDeath(EntityDeathEvent event) {
    if (_scenario.isActive() && _currentWave != null) {
        Entity entity = event.getEntity();
        if (entity instanceof Player) {

            try {
                _scenario.getPlayers().remove((Player)entity);
                if (_scenario.getEventListener() != null) {
                    _scenario.getEventListener().playerDied((Player)entity, _scenario.getPlayers());
                }
            }
            catch (Exception ex) { }
        }
        else {
            _currentWave.processEntityDeath(entity);
        }
    }


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

    if (_livingEntities.contains(event.getEntity())) {

        _livingEntities.remove(event.getEntity());

        if (_greeter.getEntityId() == event.getEntity().getEntityId()) {
            sendMessageToPlayers("The quest giver is dead! You failed the mission!");
            activateCoolDown();
            resetEvent();
        }
        else {
            if (_globalTrigger.survivorDied(event.getEntity()) == 0) {
                sendMessageToPlayers("All the survivors died, you failed the mission!");
                activateCoolDown();
                resetEvent();
            }
            else {
                sendMessageToPlayers("A survivor died! Defend them against monsters!");
            }
        }
    }
}
项目: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");
        }

    }
}
项目:QuestManager    文件:VanquishRequirement.java   
/**
 * Catches entity death events and changes state to reflect whether or not this requirement
 * is satisfied
 */
@EventHandler
public void onVanquish(EntityDeathEvent e) {

    if (!state && foe.isDead()) {
        state = true;

        //remove NPC
        QuestManagerPlugin.questManagerPlugin.getManager().unregisterNPC(foeNPC);

        //unregister listen, as we'll never need to check again
        HandlerList.unregisterAll(this);
        updateQuest();
    }

}
项目:ExilePearl    文件:CoreDamageLoggerTest.java   
@SuppressWarnings("deprecation")
@Test
public void testEntityDeath() {
    dut.start();

    List<Player> damagers = dut.getSortedDamagers(player);
    assertEquals(0, damagers.size());

    EntityDamageByEntityEvent damageEvent = new EntityDamageByEntityEvent(d1, player, null, 5);
    dut.onEntityDamageByEntity(damageEvent);
    damagers = dut.getSortedDamagers(player);
    assertEquals(1, damagers.size());
    assertEquals(d1, damagers.get(0));

    EntityDeathEvent deathEvent = new EntityDeathEvent(player, null);
    dut.onEntityDeath(deathEvent);
    damagers = dut.getSortedDamagers(player);
    assertEquals(0, damagers.size());
}
项目:Pokkit    文件:EntityEvents.java   
@EventHandler(ignoreCancelled = false)
public void onEntityDeath(cn.nukkit.event.entity.EntityDeathEvent event) {
    if (canIgnore(EntityDeathEvent.getHandlerList())) {
        return;
    }

    List<ItemStack> bukkitDrops = new ArrayList<ItemStack>();
    for (Item item : event.getDrops()) {
        bukkitDrops.add(PokkitItemStack.toBukkitCopy(item));
    }

    EntityDeathEvent bukkitEvent = new EntityDeathEvent(
            PokkitLivingEntity.toBukkit((EntityLiving) event.getEntity()), bukkitDrops);

    callUncancellable(bukkitEvent);
    event.setDrops(bukkitEvent.getDrops().stream().map(PokkitItemStack::toNukkitCopy).toArray(Item[]::new));
}
项目:BloodMoon    文件:ExtendedNightListener.java   
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityDeath(EntityDeathEvent event) {
    if (hostileTypes.contains(event.getEntityType())) {
        World world = event.getEntity().getWorld();
        String worldName = world.getName();
        PluginConfig worldConfig = plugin.getConfig(world);

        if (plugin.isFeatureEnabled(world, Feature.EXTENDED_NIGHT) && killCount.containsKey(worldName)) {
            killCount.put(worldName, killCount.get(worldName) + 1);

            if (killCount.get(worldName) > worldConfig.getInt(Config.FEATURE_EXTENDED_NIGHT_MIN_KILLS)) {
                world.setGameRuleValue("doDaylightCycle", "true");
            }
        }
    }
}
项目:BloodMoon    文件:SpawnOnKillListener.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityDeath(EntityDeathEvent event) {
    Entity entity = event.getEntity();
    World world = entity.getWorld();
    PluginConfig worldConfig = plugin.getConfig(world);

    if (entity instanceof Creature && plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.SPAWN_ON_KILL)) {
        Creature creature = (Creature) entity;
        EntityDamageEvent lastDamage = entity.getLastDamageCause();

        if (lastDamage != null && creature.getTarget() instanceof Player && playerCauses.contains(lastDamage.getCause()) && worldConfig.getStringList(Config.FEATURE_SPAWN_ON_KILL_MOBS).contains(creature.getType().name().toUpperCase())) {
            if (this.random.nextInt(100) < worldConfig.getInt(Config.FEATURE_SPAWN_ON_KILL_CHANCE)) {
                String mobName = ListUtils.getRandom(worldConfig.getStringList(Config.FEATURE_SPAWN_ON_KILL_SPAWN));
                EntityType creatureType = EntityType.fromName(mobName.toUpperCase());

                if (creatureType != null) {
                    world.spawnEntity(creature.getLocation(), creatureType);
                    //world.spawn(creature.getLocation(), creatureType.getEntityClass(), SpawnReason.NATURAL);
                }
            }
        }
    }
}
项目:MCAnalytics    文件:EventListener.java   
@EventHandler
public void onEntityDeath(EntityDeathEvent e) {
    Player killer = e.getEntity().getKiller();
    if ((e.getEntity() instanceof Player)) {
        Player playerKilled = (Player) e.getEntity();
        incrementStatistic(Statistic.PLAYERS_KILLED);
        incrementPlayerStat(playerKilled, PlayerStat.DEATHS);
        if (killer instanceof Player) {
            incrementPlayerStat(killer, PlayerStat.PLAYERS_KILLED);
        }
    } else {
        incrementStatistic(Statistic.MOBS_KILLED);
        if (killer instanceof Player) {
            incrementPlayerStat(killer, PlayerStat.MOBS_KILLED);
        }
    }
}
项目:UberHardcore    文件:SpiderDeathHandler.java   
@EventHandler
public void on(EntityDeathEvent event) {
    if (!(event.getEntity() instanceof Spider)) return;

    Entity entity = ((CraftEntity) event.getEntity()).getHandle();

    // spawn 5 random webs
    for (int i = 0; i < 5; i++) {
        spawnRandomWeb(entity);
    }

    // spawn 30 random particle effects
    for (int i = 0; i < 30; i++) {
        spawnRandomRedstoneParticle(entity);
    }
}
项目:UberHardcore    文件:CreeperDeathHandler.java   
@EventHandler
public void on(EntityDeathEvent event) {
    if (!(event.getEntity() instanceof Creeper)) return;

    Creeper creeper = (Creeper) event.getEntity();

    // explode after 2 seconds ticks
    ExplosionTask task = new ExplosionTask(creeper.getLocation(), creeper.isPowered() ? 6 : 3, false);
    task.runTaskLater(plugin, 40);

    // set up some layered smoke effects
    for (int i = 0; i < 5; i++) {
        // increase the count over time
        ImpendingExplosionParticleTask smoke = new ImpendingExplosionParticleTask(creeper.getLocation(), 20 * (i+1));
        smoke.runTaskLater(plugin, 10 + (i * 10));
    }
}
项目:UberHardcore    文件:SpiderDeathHandler.java   
@EventHandler
public void on(EntityDeathEvent event) {
    if (!(event.getEntity() instanceof Spider)) return;

    Entity entity = ((CraftEntity) event.getEntity()).getHandle();

    // spawn 5 random webs
    for (int i = 0; i < 5; i++) {
        spawnRandomWeb(entity);
    }

    // spawn 30 random particle effects
    for (int i = 0; i < 30; i++) {
        spawnRandomRedstoneParticle(entity);
    }
}
项目:UberHardcore    文件:CreeperDeathHandler.java   
@EventHandler
public void on(EntityDeathEvent event) {
    if (!(event.getEntity() instanceof Creeper)) return;

    Creeper creeper = (Creeper) event.getEntity();

    // explode after 2 seconds ticks
    ExplosionTask task = new ExplosionTask(creeper.getLocation(), creeper.isPowered() ? 6 : 3, false);
    task.runTaskLater(plugin, 40);

    // set up some layered smoke effects
    for (int i = 0; i < 5; i++) {
        // increase the count over time
        ImpendingExplosionParticleTask smoke = new ImpendingExplosionParticleTask(creeper.getLocation(), 20 * (i+1));
        smoke.runTaskLater(plugin, 10 + (i * 10));
    }
}
项目:UberHardcore    文件:SpiderDeathHandler.java   
@EventHandler
public void on(EntityDeathEvent event) {
    if (!(event.getEntity() instanceof Spider)) return;

    Entity entity = ((CraftEntity) event.getEntity()).getHandle();

    // spawn 5 random webs
    for (int i = 0; i < 5; i++) {
        spawnRandomWeb(entity);
    }

    // spawn 30 random particle effects
    for (int i = 0; i < 30; i++) {
        spawnRandomRedstoneParticle(entity);
    }
}
项目:UberHardcore    文件:CreeperDeathHandler.java   
@EventHandler
public void on(EntityDeathEvent event) {
    if (!(event.getEntity() instanceof Creeper)) return;

    Creeper creeper = (Creeper) event.getEntity();

    // explode after 2 seconds ticks
    ExplosionTask task = new ExplosionTask(creeper.getLocation(), creeper.isPowered() ? 6 : 3, false);
    task.runTaskLater(plugin, 40);

    // set up some layered smoke effects
    for (int i = 0; i < 5; i++) {
        // increase the count over time
        ImpendingExplosionParticleTask smoke = new ImpendingExplosionParticleTask(creeper.getLocation(), 20 * (i+1));
        smoke.runTaskLater(plugin, 10 + (i * 10));
    }
}
项目:civcraft    文件:CustomItemManager.java   
@EventHandler(priority = EventPriority.LOW)
public void OnEntityDeath(EntityDeathEvent event) {
    if (event.getEntity() instanceof Player) {
        return;
    }

    /* Remove any vanilla item IDs that can't be crafted from vanilla drops. */
    LinkedList<ItemStack> removed = new LinkedList<ItemStack>();
    for (ItemStack stack : event.getDrops()) {
        Integer key = ItemManager.getId(stack);

        if (CivSettings.removedRecipies.containsKey(key)) {
            if (!LoreMaterial.isCustom(stack)) {
                removed.add(stack);
            }
        }
    }

    event.getDrops().removeAll(removed);
}
项目:acidisland    文件:IslandGuard.java   
/**
 * Drops the Enderman's block when he dies if he has one
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEndermanDeath(final EntityDeathEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!Settings.endermanDeathDrop)
        return;
    if (!inWorld(e.getEntity())) {
        return;
    }
    if (!(e.getEntity() instanceof Enderman)) {
        // plugin.getLogger().info("Not an Enderman!");
        return;
    }
    // Get the block the enderman is holding
    Enderman ender = (Enderman) e.getEntity();
    MaterialData m = ender.getCarriedMaterial();
    if (m != null && !m.getItemType().equals(Material.AIR)) {
        // Drop the item
        // plugin.getLogger().info("Dropping item " + m.toString());
        e.getEntity().getWorld().dropItemNaturally(e.getEntity().getLocation(), m.toItemStack(1));
    }
}
项目:EpicDrop    文件:MobDeath.java   
public static void checkMobDrop(EntityType Entity, EntityDeathEvent e, Player p){
    FileConfiguration gc = Core.plugin.getConfig();

    //Checks to see if killed entity is a Player
    if(Entity.equals(EntityType.PLAYER)){
        if(!Globals.PlayerDrops){e.getDrops().clear();}
    }else{
        if(!Globals.BothDrops){ e.getDrops().clear(); };
    }

    //Shows Killed Entity and What item is in config according to said Entity.
    if(Globals.Debug){
        p.sendMessage(Globals.Debug(Entity.name()));
        p.sendMessage(Globals.Debug(gc.getString("eDrop.Mobs." + Entity.name() + ".Item")));
    }

    Material    m = Material.valueOf(gc.getString("eDrop.Mobs." + Entity.name() + ".Item"));    // Gets Mobs Item
    int         a = gc.getInt("eDrop.Mobs." + Entity.name() + ".ItemAmount");                   // Gets Mobs Item Amount

    // e.getDrops().addAll(Storage.get(e.getEntityType().name()));

    e.getDrops().add(new ItemStack(m,a)); // Sets the Mobs Drop     

}
项目:EpicDrop    文件:MobDeath.java   
public static void checkMobInventoy(EntityType Entity, Player p, EntityDeathEvent ede){

    PlayerInventory pi = p.getInventory();
    FileConfiguration gc = Core.plugin.getConfig();

    //Checks to see if killed entity is a Player
    if(Entity.equals(EntityType.PLAYER)){
        if(!Globals.PlayerDrops){ede.getDrops().clear();}
    }else{
        if(!Globals.BothDrops){ ede.getDrops().clear(); };
    }

    //Shows Killed Entity and What item is in config according to said Entity.
    if(Globals.Debug){
        p.sendMessage(Globals.Debug(Entity.name()));
        p.sendMessage(Globals.Debug(gc.getString("eDrop.Mobs." + Entity.name() + ".Item")));
    }

    Material m = Material.valueOf(gc.getString("eDrop.Mobs." + Entity.name() + ".Item"));   //Gets Mobs Item
    int a = gc.getInt("eDrop.Mobs." + Entity.name() + ".ItemAmount");                       //Gets Mobs Item Amount

    pi.addItem(new ItemStack(m, a)); //Adds Item to Inventory of Player

}
项目:Bukkit-DropProtect    文件:EntityDeathRespawnListener.java   
@EventHandler(priority=EventPriority.HIGHEST)
public void onEntityDeath(EntityDeathEvent event) {
    if (event.getEntity() instanceof Player) {
        Player player = (Player) event.getEntity();

        // only active in survival mode
        if (!player.getGameMode().equals(GameMode.SURVIVAL)) {
            return;
        }

        int numProtectedSlots = this.dropProtect.getNumProtectedSlotsForPlayer(player);

        ProtectedItemsSnapshot protectedItemsSnapshot = new ProtectedItemsSnapshot(player, event.getDrops(), numProtectedSlots);

        // add the snapshot to load after the player respawns
        playerItemSnapshots.put(player.getName(), protectedItemsSnapshot);
    }
}
项目:askyblock    文件:IslandGuard.java   
/**
 * Drops the Enderman's block when he dies if he has one
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEndermanDeath(final EntityDeathEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!Settings.endermanDeathDrop)
        return;
    if (!inWorld(e.getEntity())) {
        return;
    }
    if (!(e.getEntity() instanceof Enderman)) {
        // plugin.getLogger().info("Not an Enderman!");
        return;
    }
    // Get the block the enderman is holding
    Enderman ender = (Enderman) e.getEntity();
    MaterialData m = ender.getCarriedMaterial();
    if (m != null && !m.getItemType().equals(Material.AIR)) {
        // Drop the item
        // plugin.getLogger().info("Dropping item " + m.toString());
        e.getEntity().getWorld().dropItemNaturally(e.getEntity().getLocation(), m.toItemStack(1));
    }
}
项目:Annihilation    文件:BossListener.java   
@EventHandler
public void onDeath(EntityDeathEvent event) {
    if (event.getEntity() instanceof IronGolem) {
        IronGolem g = (IronGolem) event.getEntity();
        if (g.getCustomName() == null)
            return;

        Boss b = plugin.getBossManager().bossNames.get(g.getCustomName());
        if (b == null)
            return;

        event.getDrops().clear();

        b.spawnLootChest();

        if (g.getKiller() != null) {
            Player killer = g.getKiller();
            ChatUtil.bossDeath(b, killer, PlayerMeta.getMeta(killer)
                    .getTeam());
            respawn(b);
            Util.spawnFirework(event.getEntity().getLocation(), PlayerMeta.getMeta(killer).getTeam().getColor(PlayerMeta.getMeta(killer).getTeam()), PlayerMeta.getMeta(killer).getTeam().getColor(PlayerMeta.getMeta(killer).getTeam()));
        } else {
            g.teleport(b.getSpawn());
        }
    }
}
项目:McMMOPlus    文件:EntityListener.java   
/**
 * Monitor EntityDeath events.
 *
 * @param event The event to watch
 */
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDeathLowest(EntityDeathEvent event) {
    LivingEntity entity = event.getEntity();

    if (Misc.isNPCEntity(entity)) {
        return;
    }

    if (entity.hasMetadata(mcMMO.customNameKey)) {
        entity.setCustomName(entity.getMetadata(mcMMO.customNameKey).get(0).asString());
        entity.removeMetadata(mcMMO.customNameKey, plugin);
    }

    if (entity.hasMetadata(mcMMO.customVisibleKey)) {
        entity.setCustomNameVisible(entity.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean());
        entity.removeMetadata(mcMMO.customVisibleKey, plugin);
    }
}
项目:ultrahardcore    文件:GhastDropsFeature.java   
@EventHandler
public void onEntityDeathEvent(EntityDeathEvent ede)
{
    //if we're enabled and a ghast died
    if(isEnabled() && ede.getEntityType() == EntityType.GHAST) {
        //if ghasts can't drop tears in this world
        if(featureEnabledForWorld(ede.getEntity().getWorld().getName())) {

            //get the list of drops
            List<ItemStack> drops = ede.getDrops();

            //for all the items dropped
            Iterator<ItemStack> iterator = drops.iterator();
            Collection<ItemStack> toAdd = new ArrayList<ItemStack>();
            while(iterator.hasNext()) {
                ItemStack is = iterator.next();
                //if it was a ghast tear drop the same amount of gold ingots
                if(is.getType() == Material.GHAST_TEAR) {
                    iterator.remove();
                    toAdd.add(new ItemStack(Material.GOLD_INGOT, is.getAmount()));
                }
            }
            drops.addAll(toAdd);
        }
    }
}