Package org.bukkit.entity

Examples of org.bukkit.entity.LivingEntity


     */
    private final int RADIUS = 5;
   
    @Override
    public void execute(Arena arena, MABoss boss) {
        LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), false);
        if (target == null) return;
       
        for (Player p : AbilityUtils.getNearbyPlayers(arena, boss.getEntity(), RADIUS)) {
            Location loc = p.getLocation();
            loc.setYaw(loc.getYaw() + 45 + AbilityUtils.random.nextInt(270));
View Full Code Here


     * @param random Grab a random player if no target was found
     * @return The target player, or null
     */
    public static LivingEntity getTarget(Arena arena, LivingEntity entity, boolean random) {
        if (entity instanceof Creature) {
            LivingEntity target = ((Creature) entity).getTarget();
           
            if (target instanceof Player && arena.inArena((Player) target)) {
                return target;
            }
        }
View Full Code Here

        && !plugin.worlds.contains(event.getEntity().getLocation()
            .getWorld().getName().toLowerCase()))
      return;
    if (!(event.getEntity() instanceof LivingEntity))
      return;
    LivingEntity entity = (LivingEntity) event.getEntity();
    LivingEntity damager = null;
    if (event.getDamager() instanceof LivingEntity) {
      damager = (LivingEntity) event.getDamager();
    } else if (event.getDamager() instanceof Projectile) {
      damager = ((Projectile) event.getDamager()).getShooter();
    }
    if ((entity == null) || (damager == null))
      return;
    if (entity.getWorld() != damager.getWorld())
      return;
    EffectsAPI.handlePluginEffects(entity, damager, event);
  }
View Full Code Here

    plugin = instance;
  }

  @EventHandler(priority = EventPriority.LOW)
  public void onSpawn(final CreatureSpawnEvent event) {
    LivingEntity entity = event.getEntity();
    if (!(entity instanceof Monster))
      return;
    if ((plugin.worlds.size() > 0)
        && plugin.getConfig().getBoolean("Worlds.Enabled", false)
        && !plugin.worlds.contains(entity.getLocation().getWorld()
            .getName().toLowerCase()))
      return;
    if (plugin.getConfig().getBoolean("Reason.Spawner", true)
        && event.getSpawnReason().equals(SpawnReason.SPAWNER))
      return;
    if (plugin.getConfig().getBoolean("Reason.Egg", true)
        && (event.getSpawnReason().equals(SpawnReason.EGG) || event
            .getSpawnReason().equals(SpawnReason.SPAWNER_EGG)))
      return;
    EntitySpawnEvent ese = new EntitySpawnEvent(entity, plugin
        .getSingleRandom().nextInt(100) + 1);
    plugin.getServer().getPluginManager().callEvent(ese);
    if ((entity instanceof Monster)
        && (plugin.getConfig().getInt("Percentages.ChancePerSpawn", 3) >= ese
            .getChance())) {
      List<ItemStack> items = new ArrayList<ItemStack>();
      for (int i = 0; i < (plugin.getSingleRandom().nextInt(5) + 1); i++) {
        ItemStack ci = plugin.getDropAPI().getItem();
        while (ci == null) {
          ci = plugin.getDropAPI().getItem();
        }
        if (plugin.getConfig().getBoolean("Custom.Only", false)
            && plugin.getConfig()
                .getBoolean("Custom.Enabled", true)) {
          ci = plugin.custom.get(plugin.getSingleRandom().nextInt(
              plugin.custom.size()));
        }
        if (ci != null) {
          items.add(ci);
        }
      }
      EntitySpawnWithItemEvent eswi = new EntitySpawnWithItemEvent(
          entity, items);
      plugin.getServer().getPluginManager().callEvent(eswi);
      if (eswi.isCancelled())
        return;

      for (ItemStack cis : eswi.getItems()) {
        if (cis != null) {
          float dropChance = 2.0F;
          if (true) {
            Tier tier = plugin.getDropAPI().getTier(cis);
            if (tier != null)
              dropChance = (tier.getDropChance() * 0.01F);
          }
          if (plugin.getItemAPI().isHelmet(cis.getType())
              || cis.getType().equals(Material.SKULL_ITEM)) {
            entity.getEquipment().setHelmet(cis);
            entity.getEquipment().setHelmetDropChance(dropChance);
          } else if (plugin.getItemAPI().isChestPlate(cis.getType())) {
            entity.getEquipment().setChestplate(cis);
            entity.getEquipment().setChestplateDropChance(
                dropChance);
          } else if (plugin.getItemAPI().isLeggings(cis.getType())) {
            entity.getEquipment().setLeggings(cis);
            entity.getEquipment().setLeggingsDropChance(dropChance);
          } else if (plugin.getItemAPI().isBoots(cis.getType())) {
            entity.getEquipment().setBoots(cis);
            entity.getEquipment().setBootsDropChance(dropChance);
          } else {
            entity.getEquipment().setItemInHand(cis);
            entity.getEquipment().setItemInHandDropChance(
                dropChance);

          }
        }
      }
View Full Code Here

            return;
        }

        // Get the last entity on the list
        final Entity entity = entities.get(entities.size() - 1).getBukkitEntity();
        final LivingEntity finalController = controller != null ? controller.getLivingEntity() : null;

        BukkitRunnable task = new BukkitRunnable() {

            Location location = null;
            Boolean flying = true;

            public void run() {

                if (freeflight) {

                    // If freeflight is on, and the flying entity
                    // is ridden by another entity, let it keep
                    // flying where the controller is looking

                    if (!entity.isEmpty() && finalController.isInsideVehicle()) {
                        location = finalController.getEyeLocation()
                                     .add(finalController.getEyeLocation().getDirection()
                                     .multiply(30));
                    }
                    else {
                        flying = false;
                    }
View Full Code Here

                }

            }
            else {

                LivingEntity livingEntity = entity.getLivingEntity();

                if (livingEntity != null) {

                    if (equipment.get("hand"!= null) livingEntity.getEquipment().setItemInHand(equipment.get("hand").getItemStack());
                    if (equipment.get("head"!= null) livingEntity.getEquipment().setHelmet(equipment.get("head").getItemStack());
                    if (equipment.get("chest") != null) livingEntity.getEquipment().setChestplate(equipment.get("chest").getItemStack());
                    if (equipment.get("legs"!= null) livingEntity.getEquipment().setLeggings(equipment.get("legs").getItemStack());
                    if (equipment.get("boots") != null) livingEntity.getEquipment().setBoots(equipment.get("boots").getItemStack());
                }
            }
        }
    }
View Full Code Here

  public void onProjectileLaunch(final ProjectileLaunchEvent event) {
    if (!War.war.isLoaded()) {
      return;
    }
    if (event.getEntityType() == EntityType.EGG) {
      LivingEntity shooter = event.getEntity().getShooter();
      if (shooter instanceof Player) {
        Player player = (Player) shooter;
        Warzone zone = Warzone.getZoneByPlayerName(player.getName());
        Team team = Team.getTeamByPlayerName(player.getName());
        if (zone != null) {
View Full Code Here

        if (!event.getNPC().hasTrait(AssignmentTrait.class)) return;
        npc.action("begin navigation", null);

        if (event.getNPC().getNavigator().getTargetType() == TargetType.ENTITY) {
            LivingEntity entity = event.getNPC().getNavigator().getEntityTarget().getTarget();

            // If the NPC has an entity target, is aggressive towards it
            // and that entity is not dead, trigger "on attack" command
            if (event.getNPC().getNavigator().getEntityTarget().isAggressive()
                && !entity.isDead()) {

                dPlayer player = null;

                // Check if the entity attacked by this NPC is a player
                if (entity instanceof Player)
                    player = dPlayer.mirrorBukkitPlayer((Player) entity);

                // <--[action]
                // @Actions
                // attack
                // attack on <entity>
                //
                // @Triggers when the NPC is about to attack an enemy.
                //
                // @Context
                // None
                //
                // -->
                npc.action("attack", player);

                npc.action("attack on "
                        + entity.getType().toString(), player);
            }
            previousLocations.put(event.getNPC().getId(), npc.getLocation());
        }
    }
View Full Code Here

    @EventHandler(priority=EventPriority.MONITOR)
    public void onEntityDeath(EntityDeathEvent event) {
        // Entity that died must be living
        if(!(event.getEntity() instanceof LivingEntity))
            return;
        LivingEntity lVictim = (LivingEntity)event.getEntity();

        // mob spawner, no payment or experience
        if (lVictim.hasMetadata(mobSpawnerMetadata)) {
            lVictim.removeMetadata(mobSpawnerMetadata, plugin);
            return;
        }
       
        // make sure plugin is enabled
        if(!plugin.isEnabled())
            return;
       
        if (event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent){
            EntityDamageByEntityEvent e = (EntityDamageByEntityEvent)event.getEntity().getLastDamageCause();
            org.bukkit.entity.Player pDamager = null;
            if(e.getDamager() instanceof org.bukkit.entity.Player) {
                pDamager = (org.bukkit.entity.Player) e.getDamager();
            } else if(e.getDamager() instanceof Projectile && ((Projectile)e.getDamager()).getShooter() instanceof org.bukkit.entity.Player) {
                pDamager = (org.bukkit.entity.Player)((Projectile)e.getDamager()).getShooter();
            } else if(e.getDamager() instanceof Tameable) {
                Tameable t = (Tameable) e.getDamager();
                if (t.isTamed() && t.getOwner() instanceof org.bukkit.entity.Player) {
                    pDamager = (org.bukkit.entity.Player) t.getOwner();
                }
            }
            if(pDamager != null) {
                // check if in creative
                if (pDamager.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative())
                    return;
               
                if (!Jobs.getPermissionHandler().hasWorldPermission(pDamager, pDamager.getLocation().getWorld().getName()))
                    return;
               
                // restricted area multiplier
                double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(pDamager);
                // pay
                JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(pDamager);
                Jobs.action(jDamager, new EntityActionInfo(lVictim.getType(), ActionType.KILL), multiplier);
            }
        }
    }
View Full Code Here

            return;
        if(!event.getSpawnReason().equals(SpawnReason.SPAWNER))
            return;
        if(ConfigManager.getJobsConfiguration().payNearSpawner())
            return;
        LivingEntity creature = (LivingEntity)event.getEntity();
        creature.setMetadata(mobSpawnerMetadata, new FixedMetadataValue(plugin, true));
    }
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.