Citizen (instance of NPC not working)

Discussion in 'Spigot Plugin Development' started by EG_AKM, Oct 12, 2018.

  1. Code (Text):
    public class OnNPCInteract implements Listener{
            public void interactent(PlayerInteractEntityEvent e) {
                Player p =e.getPlayer();
                if (e.getRightClicked() instanceof NPC) {
    I expected chatting says Test but It doesn't work although I'm using 1.12.2 CItizen plugin.
  2. You can use Citizens API NPCClickEvent to listen for npc click.

    Other problem may be with wrong NPC import (you might use bukkit one but you should import Citizens one).

    Next thing you can use is entity#hasMetadata("NPC"); to check if entity is NPC
    Every citizen npc has this metadata.

    API reference:

Share This Page