Package org.bukkit.entity

Examples of org.bukkit.entity.EntityType


   
    List<Entity> entities = player.getNearbyEntities(radius, radius, radius);
    int killCount = 0;
   
    for (Entity entity : entities){
      EntityType eType = entity.getType();
      if (eType.isAlive() && eType.isSpawnable()){
        LivingEntity lEntity = (LivingEntity) entity;
        String typeOfEntity = Utils.typeOfEntity(entity.getType());
        if (typeOfEntity.equalsIgnoreCase(typeToKill) || typeToKill.equalsIgnoreCase("all")
            || eType == ClosestMatches.livingEntity(typeToKill).get(0)){
         
View Full Code Here


    if (args.length == 1){
      Block block = player.getTargetBlock(null, 30);
      if (block.getType() == Material.MOB_SPAWNER){
        String entityType = args[0];
        // Get the entity from the string
        EntityType entity = EntityType.fromName(entityType);
        // If the entity is not null and the list contains the entity
        // Then set the spawner to the entity type
        if (entity != null && list.contains(entity.getName())){
          CreatureSpawner spawner = (CreatureSpawner) block.getState();
          // Set the spawner type
          spawner.setSpawnedType(entity);
          LogHelper.showInfo("spawnerSuccess#####[" + Utils.userFriendlyNames(entity.getName()), sender, ChatColor.GREEN);
        } else {
          LogHelper.showInfo("spawnerInvalid", sender, ChatColor.RED);
        }
      } else {
        LogHelper.showInfo("spawnerLookAtSpawner", sender, ChatColor.RED);
View Full Code Here

    if (args.length > 3){
      Commands.showCommandHelpAndUsage(sender, "cex_cannon", alias);
      return true;
    }
   
    EntityType toSpawn = null;
    int explosionStrength = CommandsEX.getConf().getInt("CannonExplosionStrength");
    Player target = null;
    String type = null;
    String entity = null;
   
    if (args.length == 1 || args.length == 2){
      if (sender instanceof Player){
        target = (Player) sender;
        if (args[0].contains(":")){
          String[] data = args[0].split(":");
          entity = data[0];
          if (data.length == 2){ type = data[1]; }
        } else {
          entity = args[0];
        }
       
        List<EntityType> matches = ClosestMatches.spawnableEntity(entity);
        if (matches.size() > 0){
          toSpawn = matches.get(0);
        } else {
          LogHelper.showInfo("cannonInvalid", sender, ChatColor.RED);
          return true;
        }
      } else {
        Commands.showCommandHelpAndUsage(sender, "cex_cannon", alias);
        return true;
      }
    }
   
    if (args.length == 2){
      if (args[1].matches(CommandsEX.intRegex)){
        explosionStrength = Integer.valueOf(args[1]);
        if (explosionStrength > explosionStrengthLimit){
          LogHelper.showInfo("cannonLimit", sender, ChatColor.RED);
          explosionStrength = explosionStrengthLimit;
        }
      } else {
        LogHelper.showInfo("cannonInteger", sender, ChatColor.RED);
        return true;
      }
    }
   
    if (args.length == 3){
      target = Bukkit.getPlayer(args[0]);
      if (target == null){
        LogHelper.showInfo("invalidPlayer", sender, ChatColor.RED);
        return true;
      }
     
      if (args[1].contains(":")){
        String[] data = args[1].split(":");
        entity = data[0];
        if (data.length == 2){ type = data[1]; }
      } else {
        entity = args[1];
      }
     
      if (ClosestMatches.spawnableEntity(entity).size() > 0){
        List<EntityType> matches = ClosestMatches.spawnableEntity(entity);
        toSpawn = matches.get(0);
      } else {
        LogHelper.showInfo("cannonInvalid", sender, ChatColor.RED);
        return true;
      }
     
      if (args[2].matches(CommandsEX.intRegex)){
        explosionStrength = Integer.valueOf(args[2]);
        if (explosionStrength > explosionStrengthLimit){
          LogHelper.showInfo("cannonLimit", sender, ChatColor.RED);
          explosionStrength = explosionStrengthLimit;
        }
      } else {
        LogHelper.showInfo("cannonInteger", sender, ChatColor.RED);
        return true;
      }
    }
   
    DyeColor dye = null;

    try {
      for (DyeColor d : DyeColor.values()){
        String lower = d.name().toLowerCase();
        if (lower.equalsIgnoreCase(type)){
          dye = d;
        }
      }
    } catch (Exception e){

    }

    if (type != null){
      if (type.equalsIgnoreCase("fire")){
       
      } else if (type.equalsIgnoreCase("charged") || type.equalsIgnoreCase("powered") && toSpawn == EntityType.CREEPER){
        type = "charged";
      } else if (type.equalsIgnoreCase("baby") || type.equalsIgnoreCase("child") && (toSpawn == EntityType.PIG || toSpawn == EntityType.COW
          || toSpawn == EntityType.CHICKEN || toSpawn == EntityType.SHEEP || toSpawn == EntityType.OCELOT || toSpawn == EntityType.WOLF)){
        type = "baby";
      } else if (type.equalsIgnoreCase("tamed") && (toSpawn == EntityType.WOLF || toSpawn == EntityType.OCELOT)){
       
      } else if (type.equalsIgnoreCase("angry") && (toSpawn == EntityType.WOLF || toSpawn == EntityType.PIG_ZOMBIE)){
       
      } else if (toSpawn == EntityType.ENDERMAN && ClosestMatches.material(type).size() > 0){
       
      } else if (toSpawn == EntityType.VILLAGER && ClosestMatches.villagerProfessions(type).size() > 0){
       
      } else if (toSpawn == EntityType.DROPPED_ITEM && ClosestMatches.material(type).size() > 0){
        type = "item:" + type;
      } else if (toSpawn == EntityType.SHEEP && dye != null){
        // Correct, nothing to do here
      } else {
        LogHelper.showInfo("cannonInvalidType", sender, ChatColor.RED);
        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();
View Full Code Here

    if (args.length > 2){
      Commands.showCommandHelpAndUsage(sender, "cex_cannon", alias);
      return true;
    }
   
    EntityType toSpawn = null;
    int explosionStrength = CommandsEX.getConf().getInt("CannonExplosionStrength");
    String type = null;
    String entity = null;
   
    if (args[0].contains(":")){
      String[] data = args[0].split(":");
      entity = data[0];
      if (data.length == 2){ type = data[1]; }
    } else {
      entity = args[0];
    }

    List<EntityType> matches = ClosestMatches.spawnableEntity(entity);
    if (matches.size() > 0){
      toSpawn = matches.get(0);
    } else {
      LogHelper.showInfo("cannonInvalid", sender, ChatColor.RED);
      return true;
    }
   
    if (args.length == 2){
      if (args[1].matches(CommandsEX.intRegex)){
        explosionStrength = Integer.valueOf(args[1]);
        if (explosionStrength > explosionStrengthLimit){
          LogHelper.showInfo("cannonLimit", sender, ChatColor.RED);
          explosionStrength = explosionStrengthLimit;
        }
      } else {
        LogHelper.showInfo("cannonInteger", sender, ChatColor.RED);
        return true;
      }
    }
   
    DyeColor dye = null;

    try {
      for (DyeColor d : DyeColor.values()){
        String lower = d.name().toLowerCase();
        if (lower.equalsIgnoreCase(type)){
          dye = d;
        }
      }
    } catch (Exception e){

    }

    if (type != null){
      if (type.equalsIgnoreCase("fire")){
       
      } else if (type.equalsIgnoreCase("charged") || type.equalsIgnoreCase("powered") && toSpawn == EntityType.CREEPER){
        type = "charged";
      } else if (type.equalsIgnoreCase("baby") || type.equalsIgnoreCase("child") && (toSpawn == EntityType.PIG || toSpawn == EntityType.COW
          || toSpawn == EntityType.CHICKEN || toSpawn == EntityType.SHEEP || toSpawn == EntityType.OCELOT || toSpawn == EntityType.WOLF)){
        type = "baby";
      } else if (type.equalsIgnoreCase("tamed") && (toSpawn == EntityType.WOLF || toSpawn == EntityType.OCELOT)){
       
      } else if (type.equalsIgnoreCase("angry") && (toSpawn == EntityType.WOLF || toSpawn == EntityType.PIG_ZOMBIE)){
       
      } else if (type.equalsIgnoreCase("saddle") && toSpawn == EntityType.PIG){
       
      } else if (toSpawn == EntityType.ENDERMAN && ClosestMatches.material(type).size() > 0){
       
      } else if (toSpawn == EntityType.VILLAGER && ClosestMatches.villagerProfessions(type).size() > 0){
       
      } else if (toSpawn == EntityType.DROPPED_ITEM && ClosestMatches.material(type).size() > 0){
        type = "item:" + type;
      } else if (toSpawn == EntityType.SHEEP && dye != null){

      } else {
        LogHelper.showInfo("cannonInvalidType", sender, ChatColor.RED);
        return true;
      }
    }
   

    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();
View Full Code Here

    if (args.length > 2){
      Commands.showCommandHelpAndUsage(sender, "cex_mob", alias);
      return true;
    }
   
    EntityType toSpawn = null;
    String type = null;
    int amount = 1;
    int limit = CommandsEX.getConf().getInt("spawnMobLimit");
   
    if (args[0].contains(":")){
      String[] data = args[0].split(":");
     
      if (data.length == 0){
        LogHelper.showInfo("mobsInvalid", sender, ChatColor.RED);
        return true;
      }
     
      if (data.length == 1){
        LogHelper.showInfo("mobsInvalidType", sender, ChatColor.RED);
        return true;
      }
     
      if (ClosestMatches.livingEntity(data[0]).size() > 0){
        toSpawn = ClosestMatches.livingEntity(data[0]).get(0);
      } else {
        LogHelper.showInfo("mobsInvalid", sender, ChatColor.RED);
        return true;
      }
     
      type = data[1];
      if ((type.equalsIgnoreCase("baby") && isAgeable(toSpawn)) || (type.equalsIgnoreCase("charged") &&
          toSpawn == EntityType.CREEPER) || ((type.equalsIgnoreCase("angry") || type.equalsIgnoreCase("tamed")) &&
          toSpawn == EntityType.WOLF) || (type.equalsIgnoreCase("tamed") && toSpawn == EntityType.OCELOT)){
        // Nothing to do here
      } else if (toSpawn == EntityType.OCELOT && ClosestMatches.catType(type).size() > 0){
        type = "ocelottype:" + ClosestMatches.catType(type).get(0).name().replaceAll("_", "").toLowerCase().replaceAll("cat", "").replaceAll("ocelot", "");
      } else if (toSpawn == EntityType.SHEEP && ClosestMatches.dyeColor(type).size() > 0){
        type = "sheepcolor:" + ClosestMatches.dyeColor(type).get(0).name().replaceAll("_", "").toLowerCase();
      } else {
        LogHelper.showInfo("mobsInvalidType", sender, ChatColor.RED);
        return true;
      }
    } else {
      if (ClosestMatches.livingEntity(args[0]).size() > 0){
        toSpawn = ClosestMatches.livingEntity(args[0]).get(0);
      } else {
        LogHelper.showInfo("mobsInvalid", sender, ChatColor.RED);
        return true;
      }
    }
   
    if (args.length == 2){
      try {
        amount = Integer.valueOf(args[1]);
      } catch (Exception e){
        LogHelper.showInfo("mobsInt", sender, ChatColor.RED);
        return true;
      }
    }
   
    if (amount > limit && !player.hasPermission("cex.mob.spawn.bypasslimit")){
      LogHelper.showInfo("mobsLimit", sender, ChatColor.RED);
      amount = limit;
    }
   
    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();
        }
       
        if (type.equalsIgnoreCase("tamed")){
          Tameable tame = (Tameable) entity;
          tame.setTamed(true);
          tame.setOwner((AnimalTamer) player);
        }
       
        if (type.equalsIgnoreCase("angry")){
          Wolf wolf = (Wolf) entity;
          wolf.setAngry(true);
        }
       
        if (type.equalsIgnoreCase("charged")){
          Creeper creep = (Creeper) entity;
          creep.setPowered(true);
        }
       
        if (type.startsWith("ocelottype:")){
          type = type.replaceFirst("ocelottype:", "");
          Ocelot oce = (Ocelot) entity;
          if (!type.startsWith("wild")){
            oce.setTamed(true);
            oce.setOwner((AnimalTamer) player);
          }
         
          oce.setCatType(ClosestMatches.catType(type).get(0));
        }
       
        if (type.startsWith("sheepcolor:")){
          type = type.split(":")[1];
          Sheep sheep = (Sheep) entity;
          sheep.setColor(ClosestMatches.dyeColor(type).get(0));
        }
      }
    }
   
    LogHelper.showInfo("mobsSuccess#####[" + amount + " " + Utils.userFriendlyNames((type != null ? type + " " : "") + toSpawn.name()), sender, ChatColor.AQUA);
   
    return true;
  }
View Full Code Here

  public static MinecartMember<?> spawnBy(Location at, Player player) {
    ItemStack item = player.getItemInHand();
    if (LogicUtil.nullOrEmpty(item)) {
      return null;
    }
    EntityType type = Conversion.toMinecartType.convert(item.getType());
    if (type == null) {
      return null;
    }

    // subtract held item
View Full Code Here

  @Override
  public boolean handle(MinecartGroup group, String text, SignActionEvent event) {
    if (isSize(text.toLowerCase(Locale.ENGLISH))) {
      return Util.evaluate(group.size(), text);
    }
    final EntityType type = Conversion.toMinecartType.convert(text);
    if (type == null) {
      return false;
    } else {
      return Util.evaluate(group.size(type), text);
    }
View Full Code Here

                        break;
                }
                break;

            case ENTITY:
                EntityType ent = entity.getEntityType();
                switch (act) {
                    case ADD:
                        for (dPlayer player : players.filter(dPlayer.class))
                            player.incrementStatistic(stat, ent, amt);
                        break;
View Full Code Here

        return mat == null ? 0 : mat.getId();
    }

    @Override
    public boolean isValidMobType(String type) {
        final EntityType entityType = EntityType.fromName(type);
        return entityType != null && entityType.isAlive();
    }
View Full Code Here

      final List list = world.getEntities(mcEntity, box);
      @SuppressWarnings("rawtypes")
      Iterator iterator = list.iterator();
      while (iterator.hasNext()) {
        final net.minecraft.server.v1_4_6.Entity other = (net.minecraft.server.v1_4_6.Entity) iterator.next();
        final EntityType type = other.getBukkitEntity().getType();
        if (type != EntityType.BOAT && type != EntityType.MINECART) continue;
        final AxisAlignedBB otherBox = other.boundingBox;
        if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
        else {
          return true;
View Full Code Here

TOP

Related Classes of org.bukkit.entity.EntityType

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.