Package org.bukkit.entity

Examples of org.bukkit.entity.Entity


        return true;
      }
    }
   

    final Entity entity1;
   
    if (toSpawn == EntityType.DROPPED_ITEM){
      entity1 = target.getWorld().dropItem(target.getEyeLocation(), new ItemStack(ClosestMatches.material(type.split(":")[1].replaceFirst(":", "")).get(0)));
    } else {
      entity1 = target.getWorld().spawn(target.getEyeLocation(), toSpawn.getEntityClass());
    }
   
    if (toSpawn == EntityType.OCELOT){
      final Ocelot ocelot = (Ocelot) entity1;
      Random random = new Random();
      int i = random.nextInt(Ocelot.Type.values().length);
      ocelot.setCatType(Ocelot.Type.values()[i]);
    }
   
    if (type != null){
      if (type.equalsIgnoreCase("fire")){
        entity1.setFireTicks(40);
      } else if (type.equalsIgnoreCase("baby")){
        Ageable age = (Ageable) entity1;
        age.setBaby();
      } else if (type.equalsIgnoreCase("tamed")){
        Tameable tame = (Tameable) entity1;
        tame.setTamed(true);
      } else if (type.equalsIgnoreCase("angry")){
        if (toSpawn == EntityType.WOLF){
          Wolf wolf = (Wolf) entity1;
          wolf.setAngry(true);
        }
       
        if (toSpawn == EntityType.PIG_ZOMBIE){
          PigZombie pigzombie = (PigZombie) entity1;
          pigzombie.setAngry(true);
        }
      } else if (type.equalsIgnoreCase("charged")){
        Creeper creep = (Creeper) entity1;
        creep.setPowered(true);
      } else if (toSpawn == EntityType.ENDERMAN && ClosestMatches.material(type).size() > 0){
        Enderman enderman = (Enderman) entity1;
        enderman.setCarriedMaterial(new MaterialData(ClosestMatches.material(type).get(0)));
      } else if (toSpawn == EntityType.VILLAGER && ClosestMatches.villagerProfessions(type).size() > 0){
        Villager villager = (Villager) entity1;
        villager.setProfession(ClosestMatches.villagerProfessions(type).get(0));
      } else if (type.startsWith("item:") && toSpawn == EntityType.DROPPED_ITEM){

      } else if (dye != null){
        Sheep sheep = (Sheep) entity1;
        sheep.setColor(dye);
      }
    }
   
    entity1.setVelocity(target.getEyeLocation().getDirection().multiply(2));
    entity1.setFallDistance(-999999999999F);
    LogHelper.showInfo("cannonCreated", sender);
    // required for task, has to be final
    final int newExplosionStrength = explosionStrength;
    Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CommandsEX.plugin, new Runnable() {
      public void run() {
        final Location loc = entity1.getLocation();
        entity1.remove();
        loc.getWorld().createExplosion(loc, newExplosionStrength);
      }
    }, 20L);
    return true;
  }
View Full Code Here


    Afk.resetPlayerIdleTime(e.getPlayer().getName());
  }
 
  @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
  public void onPlayerDamage(EntityDamageByEntityEvent e){
    Entity en = e.getDamager();
    if (en instanceof Player){
      Afk.resetPlayerIdleTime(((Player) en).getName());
    }
  }
View Full Code Here

    }
   

    for (Player p : Bukkit.getOnlinePlayers()){
      if (p != sender){
        final Entity entity1;
        if (toSpawn == EntityType.DROPPED_ITEM){
          entity1 = p.getWorld().dropItem(p.getEyeLocation(), new ItemStack(ClosestMatches.material(type.split(":")[1].replaceFirst(":", "")).get(0)));
        } else {
          entity1 = p.getWorld().spawn(p.getEyeLocation(), toSpawn.getEntityClass());
        }
       
        if (toSpawn == EntityType.OCELOT){
          final Ocelot ocelot = (Ocelot) entity1;
          Random random = new Random();
          int i = random.nextInt(Ocelot.Type.values().length);
          ocelot.setCatType(Ocelot.Type.values()[i]);
        }
       
        if (type != null){
          if (type.equalsIgnoreCase("fire")){
            entity1.setFireTicks(40);
          } else if (type.equalsIgnoreCase("baby")){
            Ageable age = (Ageable) entity1;
            age.setBaby();
          } else if (type.equalsIgnoreCase("tamed")){
            Tameable tame = (Tameable) entity1;
            tame.setTamed(true);
          } else if (type.equalsIgnoreCase("angry")){
            if (toSpawn == EntityType.WOLF){
              Wolf wolf = (Wolf) entity1;
              wolf.setAngry(true);
            }
           
             if (toSpawn == EntityType.PIG_ZOMBIE){
               PigZombie pigzombie = (PigZombie) entity1;
               pigzombie.setAngry(true);
             }
          } else if (type.equalsIgnoreCase("charged")){
            Creeper creep = (Creeper) entity1;
            creep.setPowered(true);
          } else if (type.equalsIgnoreCase("saddle")){
            Pig pig = (Pig) entity1;
            pig.setSaddle(true);
          } else if (toSpawn == EntityType.ENDERMAN && ClosestMatches.material(type).size() > 0){
            Enderman enderman = (Enderman) entity1;
            enderman.setCarriedMaterial(new MaterialData(ClosestMatches.material(type).get(0)));
          } else if (toSpawn == EntityType.VILLAGER && ClosestMatches.villagerProfessions(type).size() > 0){
            Villager villager = (Villager) entity1;
            villager.setProfession(ClosestMatches.villagerProfessions(type).get(0));
          } else if (type.startsWith("item:") && toSpawn == EntityType.DROPPED_ITEM){

          } else if (dye != null){
            Sheep sheep = (Sheep) entity1;
            sheep.setColor(dye);
          }
        }
       
        entity1.setVelocity(p.getEyeLocation().getDirection().multiply(2));
        entity1.setFallDistance(-999999999999F);
        // required for task, has to be final
        final int newExplosionStrength = explosionStrength;
        Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CommandsEX.plugin, new Runnable() {
          public void run() {
            final Location loc = entity1.getLocation();
            entity1.remove();
            loc.getWorld().createExplosion(loc, newExplosionStrength);
          }
        }, 20L);
      }
View Full Code Here

    } else {
      // unknown
      e.setDeathMessage(replacements(config.getString("deathUnknown"), victim));
      return;
    }
    Entity killer = null;
    // put this in a try catch incase we get an NPE here
    try {
      killer = (((EntityDamageByEntityEvent) damev).getDamager());
    } catch (Exception ex){
      // no killer
    }
    String message = null;
   
    // check if player died via pvp
    if (killer instanceof Player){
      message = replacements(config.getString("deathPvP"), victim).replaceAll("%killer%", Nicknames.getNick(((Player) killer).getName()));
    }
   
    // check if drowned
    if (cause == DamageCause.DROWNING){
      message = replacements(config.getString("deathDrown"), victim);
    }
   
    // check if they fell
    if (cause == DamageCause.FALL){
      message = replacements(config.getString("deathFall"), victim);
    }
   
    // check if fire
    if (cause == DamageCause.FIRE || cause == DamageCause.FIRE_TICK){
      message = replacements(config.getString("deathFire"), victim);
    }
   
    // check if lava
    if (cause == DamageCause.LAVA){
      message = replacements(config.getString("deathLava"), victim);
    }
   
    // check if magic
    if (cause == DamageCause.MAGIC){
      message = replacements(config.getString("deathMagic"), victim);
    }
   
    // check if starved
    if (cause == DamageCause.STARVATION){
      message = replacements(config.getString("deathStarvation"), victim);
    }
   
    // check if struck by lightning
    if (cause == DamageCause.LIGHTNING){
      message = replacements(config.getString("deathLightning"), victim);
    }
   
    // check if poisoned
    if (cause == DamageCause.POISON){
      message = replacements(config.getString("deathPoison"), victim);
    }
   
    // check if suffocated
    if (cause == DamageCause.SUFFOCATION){
      message = replacements(config.getString("deathSuffocate"), victim);
    }
   
    // check if suicide
    if (cause == DamageCause.SUICIDE){
      message = replacements(config.getString("deathSuicide"), victim);
    }
   
    // check if void
    if (cause == DamageCause.VOID){
      message = replacements(config.getString("deathVoid"), victim);
    }

    if ((cause == DamageCause.CONTACT || cause == DamageCause.ENTITY_ATTACK) && !(killer instanceof Player)){
      //System.out.println(killer.getType().getName());
      message = replacements(config.getString("death" + killer.getType().getName()), victim);
    }

    // check if explosion
    if (cause == DamageCause.BLOCK_EXPLOSION || cause == DamageCause.ENTITY_EXPLOSION){
      if (killer != null){
        // check if tnt
        if (killer.getType() == EntityType.PRIMED_TNT){
          message = replacements(config.getString("deathTNT"), victim);
        } else if (killer.getType() == EntityType.CREEPER){
          message = replacements(config.getString("deathCreeper"), victim);
        }
      } else {
        message = replacements(config.getString("deathOtherExplosion"), victim);
      }
View Full Code Here

    CommandsEX.plugin.getServer().getPluginManager().registerEvents(this, CommandsEX.plugin);
  }
 
  @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
  public void onEntityExplode(EntityExplodeEvent e){
    Entity entity = e.getEntity();
    Location loc = e.getLocation();
   
    // Check what entity caused the explosion, and is it set to block that kind of explosion in the config?
    if ((entity instanceof Creeper && CommandsEX.getConf().getBoolean("blockCreeperExplosions")) || (entity instanceof TNTPrimed && CommandsEX.getConf().getBoolean("blockTNTExplosions")) || ((entity instanceof Fireball || entity instanceof SmallFireball) && CommandsEX.getConf().getBoolean("blockFireballExplosions"))){
      // Clear the blocks the explosion will break
View Full Code Here

   
  }
 
  @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
  public void onEntityDamageByEntity(EntityDamageByEntityEvent e){
    Entity damager = e.getDamager();
    if ((damager instanceof TNTPrimed || damager instanceof Creeper || damager instanceof Fireball || damager instanceof SmallFireball)){
      // If the entity is an item, or if the config has blockMobDamage set to true then cancel the damage
      // This stops items from despawning from damage caused by explosions
      if (e.getEntity() instanceof Item || CommandsEX.getConf().getBoolean("blockMobExplosionDamage")){
        e.setCancelled(true);
View Full Code Here

    }
   
    for (int i = 0; i < amount; i++){
      Location location = player.getTargetBlock(null, 50).getLocation();
      location.setY(location.getY() + 1);
      Entity entity = player.getWorld().spawnEntity(location, toSpawn);
     
      if (type != null){
        if (type.equalsIgnoreCase("baby")){
          Ageable ageable = (Ageable) entity;
          ageable.setBaby();
View Full Code Here

  @Override
  public void onDamage(DamageSource damagesource, double damage) {
    if (this.entity.isDead()) {
      return;
    }
    final Entity damager = damagesource.getEntity();
    try {
      // Call CraftBukkit event
      VehicleDamageEvent event = new VehicleDamageEvent(this.entity.getEntity(), damager, damage);
      if (CommonUtil.callEvent(event).isCancelled()) {
        return;
View Full Code Here

   * Gets the inventory of a potential Player passenger
   *
   * @return the passenger Player inventory, or null if there is no player
   */
  public PlayerInventory getPlayerInventory() {
    Entity passenger = entity.getPassenger();
    if (passenger instanceof Player) {
      return ((Player) passenger).getInventory();
    } else {
      return null;
    }
View Full Code Here

   * @param to location to eject/teleport to
   */
  public void eject(final Location to) {
    if (entity.hasPassenger()) {
      TCListener.ignoreNextEject = true;
      final Entity passenger = this.entity.getPassenger();
      this.eject();
      EntityUtil.teleportNextTick(passenger, to);
      TCListener.ignoreNextEject = false;
    }
  }
View Full Code Here

TOP

Related Classes of org.bukkit.entity.Entity

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.