-
-
Notifications
You must be signed in to change notification settings - Fork 0
API Events
Eisi05 edited this page Jan 21, 2026
·
1 revision
NpcAPI fires NpcInteractEvent when a player interacts with an NPC.
-
NpcInteractListenercallsnpc.getClickEvent().call(event)automatically. - You can either set a click action on the NPC or listen to the Bukkit event.
npc.setClickEvent(event -> {
event.getPlayer().sendMessage("Clicked: " + event.getNpc().getUUID());
});Note:
-
NpcClickActionisSerializableand is saved when you callnpc.save(). Avoid lambdas that capture non-serializable objects.
@EventHandler
public void onNpcInteract(NpcInteractEvent event) {
// event.getPlayer(), event.getNpc(), event.getAction()
}When an NPC is shown to a player:
-
NpcPreShowEvent(cancellable)- provides
wasViewer()to distinguish first show vs refresh
- provides
-
NpcPostShowEvent- also provides
wasViewer()
- also provides
When an NPC is hidden from a player:
NpcHideEvent
When walking starts:
-
NpcStartWalkingEvent(cancellable)- you can modify speed and the
changeRealLocationflag
- you can modify speed and the
When walking stops:
-
NpcStopWalkingEvent- provides a
WalkingResult(SUCCESS/CANCELLED) - you can decide whether the NPC’s real location should be updated
- provides a