Examples of HumanNPC


Examples of net.citizensnpcs.resources.npclib.HumanNPC

    @EventHandler(ignoreCancelled = true)
    public void onEntityDeath(EntityDeathEvent event) {
        CreatureTask.onEntityDeath(event.getEntity());
        if (NPCManager.isNPC(event.getEntity())) {
            HumanNPC npc = NPCManager.get(event.getEntity());
            npc.callDeathEvent(event);
            NPCManager.removeForRespawn(npc.getUID());
        }
    }
View Full Code Here

Examples of net.citizensnpcs.resources.npclib.HumanNPC

        }
        if (NPCManager.isNPC(event.getTarget())) {
            NPCManager.get(event.getTarget()).callTargetEvent(event);
        }
        NPCTargetEvent e = event;
        HumanNPC npc = NPCManager.get(e.getEntity());
        if (npc != null && event.getTarget() instanceof Player) {
            Player player = (Player) event.getTarget();
            if (npc.getNPCData().isLookClose()) {
                NPCManager.faceEntity(npc, player);
            }
            if (UtilityProperties.isHoldingTool("SelectItems", player)) {
                if (!NPCManager.hasSelected(player, npc.getUID())) {
                    NPCDataManager.selectNPC(player, npc);
                    if (PermissionManager.hasPermission(player, "citizens.basic.modify.select"))
                        Messaging.send(player, npc, Settings.getString("SelectionMessage"));
                    if (!Settings.getBoolean("QuickSelect")) {
                        return;
                    }
                }
            }
            // Call NPC talk event
            if (npc.getNPCData().isTalk() && UtilityProperties.isHoldingTool("TalkItems", player)) {
                Player target = (Player) e.getTarget();
                NPCTalkEvent talkEvent = new NPCTalkEvent(npc, target, MessageUtils.getText(npc, target));
                Bukkit.getServer().getPluginManager().callEvent(talkEvent);
                if (!talkEvent.isCancelled()) {
                    if (!talkEvent.getText().isEmpty()) {
                        Messaging.send(target, npc, talkEvent.getText());
                    }
                }
            }
            NPCRightClickEvent rightClickEvent = new NPCRightClickEvent(npc, player);
            Bukkit.getServer().getPluginManager().callEvent(rightClickEvent);
            if (!rightClickEvent.isCancelled()) {
                NPCDataManager.handleEquipmentEditor(rightClickEvent);
                NPCDataManager.handlePathRestart(rightClickEvent);
                if (npc.getWaypoints().isStarted() && npc.getWaypoints().current() != null) {
                    npc.getWaypoints().scheduleDelay(npc, npc.getWaypoints().current().getLocation(),
                            Settings.getInt("RightClickPause"));
                }
                npc.callRightClick(player, npc);
            }
        }
    }
View Full Code Here

Examples of net.citizensnpcs.resources.npclib.HumanNPC

    @EventHandler(ignoreCancelled = true)
    public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
        if (event.isCancelled())
            return;
        HumanNPC npc = NPCManager.get(event.getRightClicked());
        if (npc != null) {
            EntityTargetEvent rightClickEvent = new NPCTargetEvent(npc.getPlayer(), event.getPlayer());
            Bukkit.getServer().getPluginManager().callEvent(rightClickEvent);
        }
    }
View Full Code Here

Examples of net.citizensnpcs.resources.npclib.HumanNPC

                throw new MissingNestedCommandException("Unknown command: " + cmdName, getNestedUsage(args, level - 1,
                        parent, player));
            }
        }

        HumanNPC npc = (HumanNPC) methodArgs[2];
        if (methodArgs[1] instanceof Player) {
            if (!hasPermission(method, player)) {
                throw new CommandPermissionsException();
            }
        }

        int argsCount = args.length - 1 - level;

        if (method.isAnnotationPresent(NestedCommand.class)) {
            if (argsCount == 0) {
                throw new MissingNestedCommandException("Sub-command required.", getNestedUsage(args, level, method,
                        player));
            } else {
                executeMethod(method, args, player, methodArgs, level + 1);
            }
        } else if (methodArgs[1] instanceof Player) {
            CommandRequirements requirements = this.requirements.get(method);

            if (requirements != null) {
                if (requirements.requireEconomy() && !Economy.hasEconomy()) {
                    throw new RequirementMissingException(MessageUtils.noEconomyMessage);
                }
                if (requirements.requiredMoney() != -1 && !Economy.hasEnough(player, requirements.requiredMoney())) {
                    throw new RequirementMissingException("You need at least "
                            + StringUtils.wrap(Economy.format(requirements.requiredMoney())));
                }
                if (requirements.requireSelected() && npc == null) {
                    throw new RequirementMissingException(MessageUtils.mustHaveNPCSelectedMessage);
                }
                if (requirements.requireOwnership() && npc != null && !NPCManager.isOwner(player, npc.getUID())) {
                    throw new RequirementMissingException(MessageUtils.notOwnerMessage);
                }
                if (npc != null && !requirements.requiredType().isEmpty()) {
                    if (!npc.isType(requirements.requiredType())) {
                        throw new RequirementMissingException("Your NPC isn't a " + requirements.requiredType()
                                + " yet.");
                    }
                }
            } else {
View Full Code Here

Examples of net.citizensnpcs.resources.npclib.HumanNPC

        return NPCTexts.get(UID);
    }

    public static void handleEquipmentEditor(NPCRightClickEvent event) {
        Player player = event.getPlayer();
        HumanNPC npc = event.getNPC();
        if (equipmentEditors.containsKey(player) && equipmentEditors.get(player) == npc.getUID()) {
            equip(player, npc);
        }
    }
View Full Code Here

Examples of net.citizensnpcs.resources.npclib.HumanNPC

    public static void handlePathEditor(PlayerInteractEvent event) {
        Player player = event.getPlayer();
        if (pathEditors.get(player) == null)
            return;
        PathEditingSession session = pathEditors.get(player);
        HumanNPC npc = session.getNPC();
        if (npc == null) {
            pathEditors.remove(player);
            player.sendMessage(ChatColor.GRAY + "Something went wrong (NPC is dead?).");
            return;
        }
        switch (event.getAction()) {
        case LEFT_CLICK_BLOCK:
            Location loc = event.getClickedBlock().getLocation();
            if (!npc.getWorld().equals(player.getWorld())) {
                player.sendMessage(ChatColor.GRAY + "Waypoints must be in the same world as the npc.");
                break;
            }
            if (npc.getWaypoints().size() > 0
                    && session.getCurrentLocation(npc.getWaypoints()).distance(loc) > Settings
                            .getDouble("PathfindingRange")) {
                player.sendMessage(ChatColor.GRAY + "Points can't be more than "
                        + StringUtils.wrap(Settings.getDouble("PathfindingRange"), ChatColor.GRAY)
                        + " blocks away from each other.");
                break;
            }
            session.insert(npc.getWaypoints(), new Waypoint(loc));
            event.getPlayer().sendMessage(
                    StringUtils.wrap("Added") + " waypoint at index " + StringUtils.wrap(session.getIndex()) + " ("
                            + StringUtils.wrap(loc.getBlockX()) + ", " + StringUtils.wrap(loc.getBlockY()) + ", "
                            + StringUtils.wrap(loc.getBlockZ()) + ") (" + StringUtils.wrap(npc.getWaypoints().size())
                            + " " + StringUtils.pluralise("waypoint", npc.getWaypoints().size()) + ")");
            break;
        case RIGHT_CLICK_BLOCK:
        case RIGHT_CLICK_AIR:
            if (npc.getWaypoints().size() > 0) {
                session.remove(npc.getWaypoints());
                event.getPlayer().sendMessage(
                        StringUtils.wrap("Undid") + " the last waypoint ("
                                + StringUtils.wrap(npc.getWaypoints().size()) + " remaining)");

            } else
                event.getPlayer().sendMessage(ChatColor.GRAY + "No more waypoints.");
            break;
        }
View Full Code Here

Examples of net.citizensnpcs.resources.npclib.HumanNPC

    }
    private void spawnCreature(CreatureNPCType type, Location location) {
        if (spawned.get(type) == null) {
            spawned.put(type, 0);
        } else if (type.canSpawn(spawned.get(type))) {
            HumanNPC npc = type.spawn(location);
            if (npc != null) {
                spawned.put(type, spawned.get(type) + 1);
                creatureNPCs.put(npc.getPlayer().getEntityId(), (CreatureNPC) npc.getHandle());
                onSpawn(creatureNPCs.get(npc.getPlayer().getEntityId()));
            }
        }
    }
View Full Code Here

Examples of net.citizensnpcs.resources.npclib.HumanNPC

              || !type.isSpawn())
            continue;
          if (areEntitiesOnBlock(
              world.getChunkAt(shiftedX, shiftedZ), x, y, z))
            continue;
          HumanNPC npc = NPCSpawner.spawnNPC(
              new Location(loc.getWorld(), x, y, z, random
                  .nextInt(360), 0), type);
          Bukkit.getPluginManager()
              .callEvent(
                  new NPCCreateEvent(npc,
View Full Code Here

Examples of net.citizensnpcs.resources.npclib.HumanNPC

        for (World world : Bukkit.getServer().getWorlds()) {
            for (Entity entity : world.getEntities()) {
                net.minecraft.server.v1_6_R3.Entity mcEntity = ((CraftEntity) entity).getHandle();
                if (!(mcEntity instanceof CraftNPC) || mcEntity instanceof CreatureNPC)
                    continue;
                HumanNPC found = ((CraftNPC) mcEntity).npc;
                if (NPCManager.get(found.getUID()) == found)
                    continue;
                NPCSpawner.despawnNPC(found, NPCRemoveReason.OTHER);
                ++count;
            }
        }
View Full Code Here

Examples of net.citizensnpcs.resources.npclib.HumanNPC

            return;
        }
        PropertyManager.save(npc);
        int newUID = NPCManager.register(npc.getName(), player.getLocation(), player.getName(),
                NPCCreateReason.COMMAND);
        HumanNPC newNPC = NPCManager.get(newUID);
        PropertyManager.copyNPCs(npc.getUID(), newUID);
        PropertyManager.load(newNPC);
        newNPC.teleport(player.getLocation());
        newNPC.getNPCData().setLocation(player.getLocation());
        player.sendMessage(StringUtils.wrap(npc.getName()) + " has been copied at your location.");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.