Package org.bukkit.entity

Examples of org.bukkit.entity.Villager


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


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

            // If it's a Villager, we need to spawn a Zombie instead.
            // This is kind of messy, and can be improved upon.
            // TODO: Improve upon.
            else if (infected.getBukkitEntity() instanceof Villager) {
                Villager villager = (Villager) infected.getBukkitEntity();
                // Make a new entity
                Zombie infect = (Zombie) villager.getLocation().getWorld().spawnEntity(infected.getLocation(), EntityType.ZOMBIE);
                infect.setVillager(true);
                // Set health
                infect.setHealth(villager.getHealth());
                // Set equipment
                infect.getEquipment().setArmorContents(villager.getEquipment().getArmorContents());
                // Remove the Villager
                villager.remove();
                // Set the dEntity to the new entity
                infected.setEntity(infect);
            }

            // Much much easier
View Full Code Here

   */
  private boolean interactWithVillager(Player player, Entity entity) {
    boolean cancelEvent = false;
    ItemStack stack = player.getItemInHand();
    Material material = stack.getType();
    Villager villager = (Villager) entity;
    UUID id = villager.getUniqueId();
    WorkerInfo info = workerStack.get(id);
    boolean reassign = true;
    if (info != null) {
      if (!player.hasPermission("usefulvillagers.give")) {
        player.sendMessage(NO_GIVE_PERMISSION_MESSAGE);
        return cancelEvent;
      }
      cancelEvent = give(info, player, stack, material);
      reassign = !cancelEvent;
    }

    if (reassign) {
      WorkerCreator creator = PROFESSION_TRIGGER.get(material);
      if (creator != null) {
        Villager.Profession profession = creator.getProfession();
        if ((profession != null)
            && (!(profession.equals(villager.getProfession()) && (info != null)))) {
          // It's ok, we can convert it !
          if (!player.hasPermission(creator.getPermission())) {
            player.sendMessage(NO_JOB_PERMISSION_MESSAGE);
            return cancelEvent;
          }
          villager.setProfession(profession);
          info = creator.create();
          info.setConfiguration(configurationHandler);
          workerStack.put(id, info);
          player.sendMessage(creator.getMessage());
          cancelEvent = true;
View Full Code Here

  }
 
  @Override
  @Nullable
  public Villager spawn(final Location loc) {
    final Villager v = super.spawn(loc);
    if (v == null)
      return null;
    if (profession == null)
      v.setProfession(CollectionUtils.getRandom(Profession.values()));
    return v;
  }
View Full Code Here

TOP

Related Classes of org.bukkit.entity.Villager

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.