Skip to content

API NPC Basics

Eisi05 edited this page Jan 21, 2026 · 1 revision

Creating an NPC

Common constructors:

NPC npc1 = new NPC(location, NpcName.empty());
NPC npc2 = new NPC(location, NpcName.ofLegacy("&eShop"));

Notes:

  • Creating an NPC automatically registers it into NpcManager.
  • NPCs are not automatically shown to players until you call one of the show methods.

Showing / hiding

npc.showNpcToAllPlayers();

npc.showNPCToPlayer(player);

npc.hideNpcFromPlayer(player);

npc.hideNpcFromAllPlayers();

Important behaviors:

  • showNPCToPlayer(...) won’t show the NPC to a player if:
    • The NPC is disabled (setEnabled(false)) and the player is not OP / doesn’t have the npc.admin permission.
    • The player is in a different world.
    • The NPC chunk is not loaded.

Enabling / disabling

npc.setEnabled(true);
// internally triggers npc.reload();

npc.setEnabled(false);

Updating properties

Some changes require a reload() (unless you enable auto-update via config).

npc.setLocation(newLocation);

npc.setName(NpcName.ofLegacy("&bNew Name"));

npc.reload();

Deleting

Deletes the NPC and its saved .npc file (if present):

npc.delete();

delete() throws IOException, so handle it.

Clone this wiki locally