-
-
Notifications
You must be signed in to change notification settings - Fork 0
API NPC Basics
Eisi05 edited this page Jan 21, 2026
·
1 revision
Common constructors:
NPC npc1 = new NPC(location, NpcName.empty());
NPC npc2 = new NPC(location, NpcName.ofLegacy("&eShop"));Notes:
- Creating an
NPCautomatically registers it intoNpcManager. - NPCs are not automatically shown to players until you call one of the show methods.
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 thenpc.adminpermission. - The player is in a different world.
- The NPC chunk is not loaded.
- The NPC is disabled (
npc.setEnabled(true);
// internally triggers npc.reload();
npc.setEnabled(false);Some changes require a reload() (unless you enable auto-update via config).
npc.setLocation(newLocation);
npc.setName(NpcName.ofLegacy("&bNew Name"));
npc.reload();Deletes the NPC and its saved .npc file (if present):
npc.delete();delete() throws IOException, so handle it.