Package net.citizensnpcs.resources.npclib

Examples of net.citizensnpcs.resources.npclib.HumanNPC


public class CitizensOneSupport {
 
  public SpoutPlayer getCitizenAsPlayer(int id) {
    SpoutPlayer sp = null;
    HumanNPC npc = CitizensManager.getNPC(id);
    if(npc != null) {
      if(npc.getPlayer() instanceof Player) {
        sp = SpoutManager.getPlayer((Player) npc.getPlayer());
      }
    }
    return sp;
  }
View Full Code Here


    this.toggles = toggles;
  }

  @Override
  public void grant(Player player, int UID) {
    HumanNPC spawned = NPCManager.get(NPCManager.register(name,
        at != null ? at : player.getLocation(), player.getName(),
        NPCCreateReason.COMMAND));
    for (String type : toggles) {
      spawned.addType(type);
    }
  }
View Full Code Here

                            + " enroute.");
        }

        @EventHandler
        public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
            HumanNPC npc = NPCManager.get(event.getRightClicked());
            boolean holding = UtilityProperties.isHoldingTool("SoldierSelectTool", event.getPlayer());
            if (npc == null) {
                if (holding && event.getRightClicked() instanceof LivingEntity)
                    attack(event.getPlayer(), (LivingEntity) event.getRightClicked(), getSelection(event.getPlayer()));
                return;
            }
            if (isSoldier(npc)) {
                if (holding) {
                    select(event.getPlayer(), npc, getSelection(event.getPlayer()));
                } else if (UtilityProperties.isHoldingTool("SoldierReturnTool", event.getPlayer())) {
                    npc.getHandle().cancelTarget();
                    npc.teleport(npc.getBaseLocation());
                }
                return;
            }
        }
View Full Code Here

    public boolean isAggressive() {
        return isAggressive;
    }

    private boolean isCoOwned(Entity damager, HumanNPC npc) {
        HumanNPC other = NPCManager.get(damager);
        return other != null && other.getOwner().equalsIgnoreCase(npc.getOwner());
    }
View Full Code Here

        if (!(event instanceof EntityDamageByEntityEvent))
            return;
        EntityDamageByEntityEvent ev = (EntityDamageByEntityEvent) event;
        if (!(ev.getDamager() instanceof LivingEntity))
            return;
        HumanNPC npc = NPCManager.get(event.getEntity());
        if (isOwner(ev.getDamager(), npc) || isCoOwned(ev.getDamager(), npc)) {
            event.setCancelled(true);
            return;
        }
        if (guardState != GuardState.NULL)
View Full Code Here

        event.setCancelled(false);
    }

    @Override
    public void onDeath(EntityDeathEvent event) {
        HumanNPC npc = NPCManager.get(event.getEntity());
        Player player = Bukkit.getServer().getPlayerExact(npc.getOwner());
        if (player != null) {
            player.sendMessage(ChatColor.GRAY + "Your guard NPC "
                    + StringUtils.wrap(npc.getName(), ChatColor.GRAY) + " died.");
        }
        event.getDrops().clear();
        TickTask.scheduleRespawn(npc, Settings.getInt("GuardRespawnDelay"));
    }
View Full Code Here

            return false;
        if (progress.getObjective().hasParameter("leeway") && progress.getObjective().hasParameter("npcid")) {
            int leeway = progress.getObjective().getParameter("leeway").getInt();
            for (String string : Splitter.on(",").split(
                    progress.getObjective().getParameter("npcid").getString())) {
                HumanNPC npc = NPCManager.get(Integer.parseInt(string));
                if (npc == null)
                    continue;
                if (!LocationUtils.withinRange(progress.getPlayer().getLocation(), npc.getLocation(), leeway))
                    return false;
            }
        }
        String message = ((AsyncPlayerChatEvent) event).getMessage();
        for (String match : Splitter.on(",").split(progress.getObjective().getString())) {
View Full Code Here

    @Override
    public boolean update(Event event, ObjectiveProgress progress) {
        if (event instanceof EntityDeathEvent) {
            EntityDeathEvent ev = (EntityDeathEvent) event;
            HumanNPC npc = NPCManager.get(ev.getEntity());
            if (npc == null) {
                CreatureNPC cNPC = CreatureTask.getCreature(ev.getEntity());
                if (cNPC != null)
                    npc = cNPC.npc;
            }
            if (npc != null) {
                String search = progress.getObjective().getString().toLowerCase();
                boolean found = false, reversed = !search.isEmpty() && search.charAt(0) == '-';
                if (search.contains("*") || search.contains(npc.getUID() + ",")
                        || search.contains(npc.getName().toLowerCase() + ",")
                        || (search.contains("evil") && npc.getHandle() instanceof EvilCreatureNPC)) {
                    found = true;
                }
                if (reversed ^ found) {
                    progress.addAmount(1);
                }
View Full Code Here

                    boolean value = handleMistake(sender, split[0], modifier);
                    return value;
                }
            }

            HumanNPC npc = null;
            if (player != null && NPCManager.hasSelected(player)) {
                npc = NPCManager.get(NPCDataManager.getSelected(player));
            }
            try {
                commands.execute(split, player, player == null ? sender : player, npc);
View Full Code Here

public class EntityListen implements Listener {
    @EventHandler(ignoreCancelled = true)
    public void onEntityDamage(EntityDamageEvent event) {
        CreatureTask.onDamage(event.getEntity(), event);
        HumanNPC npc = NPCManager.get(event.getEntity());
        if (npc != null) {
            npc.callDamageEvent(event);
        }
        if (event instanceof EntityDamageByEntityEvent) {
            EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
            if (npc != null) {
                if (e.getDamager() instanceof Player) {
                    Player player = (Player) e.getDamager();
                    npc.callLeftClick(player, npc);
                }
            } else if (e.getDamager() instanceof Player) {
                CreatureTask.onDamage(e.getEntity(), event);
            }
        }
View Full Code Here

TOP

Related Classes of net.citizensnpcs.resources.npclib.HumanNPC

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.