Package org.bukkit.entity

Examples of org.bukkit.entity.LivingEntity


  public void fight(EntityDamageByEntityEvent event) {
    Entity damager = event.getDamager();
    if (damager instanceof Player) {
      prevent(event, (Player) damager, "fight");
    } else if (damager instanceof Projectile) {
      LivingEntity shooter = ((Projectile) damager).getShooter();
      if (shooter instanceof Player) {
        prevent(event, (Player) shooter, "fight");
      }
    }
  }
View Full Code Here


        if (Misc.isNPCEntity(defender) || !defender.isValid() || !(defender instanceof LivingEntity)) {
            return;
        }

        LivingEntity target = (LivingEntity) defender;

        if (CombatUtils.isInvincible(target, damage)) {
            return;
        }
View Full Code Here

        if (Misc.isNPCEntity(entity) || !entity.isValid() || !(entity instanceof LivingEntity)) {
            return;
        }

        LivingEntity livingEntity = (LivingEntity) entity;

        if (CombatUtils.isInvincible(livingEntity, damage)) {
            return;
        }
View Full Code Here

     *
     * @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);
        }
    }
View Full Code Here

     *
     * @param event The event to watch
     */
    @EventHandler(priority = EventPriority.MONITOR)
    public void onEntityDeath(EntityDeathEvent event) {
        LivingEntity entity = event.getEntity();

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

View Full Code Here

    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onCreatureSpawn(CreatureSpawnEvent event) {
        switch (event.getSpawnReason()) {
            case SPAWNER:
            case SPAWNER_EGG:
                LivingEntity entity = event.getEntity();
                Entity passenger = entity.getPassenger();

                entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);

                if (passenger != null) {
                    passenger.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
                }
                return;
View Full Code Here

        if (event instanceof FakeEntityTameEvent) {
            return;
        }

        Player player = (Player) event.getOwner();
        LivingEntity entity = event.getEntity();

        if (!UserManager.hasPlayerDataKey(player) || Misc.isNPCEntity(entity) || entity.hasMetadata(mcMMO.entityMetadataKey)) {
            return;
        }

        entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
        UserManager.getPlayer(player).getTamingManager().awardTamingXP(entity);
    }
View Full Code Here

        for (int i = 0; i < amount; i++) {
            if (!summonAmountCheck(type)) {
                return;
            }

            LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(location, type);

            FakeEntityTameEvent event = new FakeEntityTameEvent(entity, player);
            mcMMO.p.getServer().getPluginManager().callEvent(event);

            if (event.isCancelled()) {
                continue;
            }

            entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
            ((Tameable) entity).setOwner(player);
            entity.setRemoveWhenFarAway(false);

            addToTracker(entity);

            switch (type) {
                case OCELOT:
                    ((Ocelot) entity).setCatType(Ocelot.Type.values()[1 + Misc.getRandom().nextInt(3)]);
                    break;

                case WOLF:
                    entity.setMaxHealth(20.0);
                    entity.setHealth(entity.getMaxHealth());
                    break;

                case HORSE:
                    Horse horse = (Horse) entity;

                    entity.setMaxHealth(15.0 + (Misc.getRandom().nextDouble() * 15));
                    entity.setHealth(entity.getMaxHealth());
                    horse.setColor(Horse.Color.values()[Misc.getRandom().nextInt(Horse.Color.values().length)]);
                    horse.setStyle(Horse.Style.values()[Misc.getRandom().nextInt(Horse.Style.values().length)]);
                    horse.setJumpStrength(Math.max(AdvancedConfig.getInstance().getMinHorseJumpStrength(), Math.min(Math.min(Misc.getRandom().nextDouble(), Misc.getRandom().nextDouble()) * 2, AdvancedConfig.getInstance().getMaxHorseJumpStrength())));
                    //TODO: setSpeed, once available
                    break;

                default:
                    break;
            }

            if (Permissions.renamePets(player)) {
                entity.setCustomName(LocaleLoader.getString("Taming.Summon.Name.Format", player.getName(), StringUtils.getPrettyEntityTypeString(type)));
            }

            ParticleEffectUtils.playCallOfTheWildEffect(entity);
        }

View Full Code Here

    @Override
    public void run() {
        for (Iterator<Entry<LivingEntity, Integer>> bleedIterator = bleedList.entrySet().iterator(); bleedIterator.hasNext(); ) {
            Entry<LivingEntity, Integer> entry = bleedIterator.next();
            LivingEntity entity = entry.getKey();

            if (entry.getValue() <= 0 || !entity.isValid()) {
                bleedIterator.remove();
                continue;
            }

            double damage;

            if (entity instanceof Player) {
                damage = AdvancedConfig.getInstance().getBleedDamagePlayer();
                Player player = (Player) entity;

                if (!player.isOnline()) {
                    continue;
                }

                // Never kill with Bleeding
                if (player.getHealth() - damage > 0) {
                    CombatUtils.dealDamage(player, damage);
                    ParticleEffectUtils.playBleedEffect(entity);
                }

                entry.setValue(entry.getValue() - 1);

                if (entry.getValue() <= 0) {
                    player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Stopped"));
                }
            }
            else {
                damage = AdvancedConfig.getInstance().getBleedDamageMobs();

                // Anticipate the entity's death to prevent CME because of our EntityDeathEvent listener
                if (entity.getHealth() - damage > 0) {
                    entry.setValue(entry.getValue() - 1);
                }
                else {
                    bleedIterator.remove();
                }
View Full Code Here

            if (Misc.isNPCEntity(entity) || !(entity instanceof LivingEntity) || !shouldBeAffected(attacker, entity)) {
                continue;
            }

            LivingEntity livingEntity = (LivingEntity) entity;
            EventUtils.callFakeArmSwingEvent(attacker);

            switch (type) {
                case SWORDS:
                    if (entity instanceof Player) {
View Full Code Here

TOP

Related Classes of org.bukkit.entity.LivingEntity

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.