Citizens API

Discussion in 'Plugin Development' started by NeguinDaFarofa, Jul 29, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    NeguinDaFarofa

    Guys, want your help to equip armor on something in the hand of npc: D Here's the code I've done so far:
    Code:
            @EventHandler
            public void onClick(PlayerInteractEvent e) {
                Player p = e.getPlayer();
                if (e.getPlayer().getItemInHand().getType().equals(Material.COMPASS)
                        && (e.getPlayer().getItemInHand().hasItemMeta())) {
                if (e.getPlayer().getItemInHand().getItemMeta().getDisplayName().equals("§aNPC")) {
                    if (e.getAction().equals(Action.RIGHT_CLICK_AIR)
                        || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
                       
                        p.sendMessage("§aSucess");
                        NPC n = CitizensAPI.getNPCRegistry().createNPC(EntityType.PLAYER, p.getName());
                        n.spawn(p.getLocation());
                       
                    }
                }
                }
                    }
           
               @EventHandler
                public void onNPCInteract(NPCRightClickEvent e){
                   Player p = e.getClicker();
                    if(e.getNPC().getName().equalsIgnoreCase(p.getName())) {
                        p.sendMessage("§f§lYou clicked");
                    }
                }
    And if possible could you tell me how do I see it in my direction and begin to attack?

    Bump.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 11, 2016
Thread Status:
Not open for further replies.

Share This Page