1.14.4 How to check if Citizens NPC exists?

Discussion in 'Spigot Plugin Development' started by kinukin, Jan 31, 2020.

  1. How can I check if an NPC exists in a world?

    I'm using citizens API.
     
  2. I tried using this code but it can't tell if any NPCs exist.

    Code (Text):
    for(Entity entity: Bukkit.getWorld("world").getEntities()) {
    if(CitizensAPI.getNPCRegistry().isNPC(entity)) {
    System.out.println("npc exist!");
    } else {
    System.out.println("no npcs exist!");
    }
    }