Package org.randomgd.bukkit.workers.info

Examples of org.randomgd.bukkit.workers.info.WorkerInfo


    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


   */
  private void interactWithGolem(Player player, Entity entity) {
    ItemStack stack = player.getItemInHand();
    Material material = stack.getType();
    UUID uuid = entity.getUniqueId();
    WorkerInfo currentInfo = workerStack.get(uuid);
    if (material.equals(Material.TORCH)) {
      if (currentInfo == null) {
        currentInfo = new GolemInfo();
        workerStack.put(uuid, currentInfo);
      }
      give(currentInfo, player, stack, material);
    } else if (material.equals(Material.STICK)) {
      if (currentInfo != null) {
        currentInfo.printInfoToPlayer(player);
      }
    }
  }
View Full Code Here

          FileInputStream input = new FileInputStream(dataFile);
          JsonReader reader = new JsonReader(new InputStreamReader(
              input, "UTF-8"));
          reader.beginArray();
          while (reader.hasNext()) {
            WorkerInfo info = deserializer.fromJson(reader,
                WorkerInfo.class);
            workerStack.put(adapter.getCurrentUUID(), info);
          }
          reader.endArray();
          reader.close();
View Full Code Here

  public boolean perform() {
    boolean result = true;
    if (entity.isDead()) {
      result = false;
    } else {
      WorkerInfo information = database.get(id);
      if (information != null) {
        Location currentLocation = entity.getLocation();
        int x = currentLocation.getBlockX();
        int y = currentLocation.getBlockY();
        int z = currentLocation.getBlockZ();
        World world = entity.getWorld();
        information.perform(entity, x, y, z, world);
      }
    }
    return result;
  }
View Full Code Here

  /**
   * @return A worker information handler.
   */
  public WorkerInfo create() {
    WorkerInfo result = null;
    try {
      result = constructor.newInstance();
    } catch (Exception ex) {
      // ... Really ?? Too bad ...
      System.err.println("The code must be lame ...");
View Full Code Here

TOP

Related Classes of org.randomgd.bukkit.workers.info.WorkerInfo

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.