Skip to content

API Persistence & Loading

Eisi05 edited this page Jan 21, 2026 · 1 revision

Saving

NPCs can be saved to disk:

npc.save();

This writes to:

  • <plugin data folder>/NPC/<uuid>.npc

You can check:

boolean saved = npc.isSaved();

Auto-loading on startup

NpcApi.createInstance(...) calls NpcManager.loadNPCs().

Loading behavior:

  • NPCs are read from the NPC/ folder.
  • If the NPC’s world isn’t loaded yet, it is queued and spawned when the world loads.

Working with the manager

import de.eisi05.npc.api.manager.NpcManager;

List<NPC> npcs = NpcManager.getList();

NpcManager.fromUUID(uuid).ifPresent(npc -> {
  // do something
});

Disabling

Call NpcApi.disable() in your plugin shutdown to:

  • hide NPCs
  • uninject packet readers
  • stop tasks
  • clear static state

Clone this wiki locally