Package net.citizensnpcs.api.npc
Interface NPCRegistry
- All Known Implementing Classes:
CitizensNPCRegistry
Controls the registration and lookup of a set of
NPCs.-
Method Summary
Modifier and TypeMethodDescriptioncreateNPC(EntityType type, String name) Creates an despawnedNPC.createNPC(EntityType type, String name, Location loc) Creates an spawnedNPCat the given location.createNPC(EntityType type, UUID uuid, int id, String name) Creates anNPCwith the given id.createNPCUsingItem(EntityType type, String name, ItemStack item) Creates an despawnedNPCusing the given ItemStack to configure it if possible.voidderegister(NPC npc) Deregisters theNPCand removes all data about it from the data store.voidDeregisters allNPCs from this registry.voiddespawnNPCs(DespawnReason reason) Despawn all NPCs within the registry.getById(int id) Gets theNPCwith the given ID if it exists.getByUniqueId(UUID uuid) Gets theNPCwith the given unique ID if it exists.getByUniqueIdGlobal(UUID uuid) Gets theNPCwith the given unique ID if it exists, otherwise null.getName()Gets the name of the registry.booleanvoidSaves the NPCs to the internalNPCDataStoresorted()Returns a sorted view of this registry, sorted by NPC id.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
createNPC
Creates an despawnedNPC.- Parameters:
type-EntityTypeto assign to the NPCname- Name to give the NPC- Returns:
- Created NPC
-
createNPC
Creates an spawnedNPCat the given location.- Parameters:
type-EntityTypeto assign to the NPCname- Name to give the NPCloc- The location to spawn at- Returns:
- Created NPC
-
createNPC
Creates anNPCwith the given id. WARNING: may overwrite any existing NPC in the registry with the same ID.- Parameters:
type- TheEntityTypeof the NPC.id- The NPC IDname- The NPC name- Returns:
- The created NPC
-
createNPCUsingItem
Creates an despawnedNPCusing the given ItemStack to configure it if possible.- Parameters:
type-EntityTypeto assign to the NPCname- Name to give the NPCitem- ItemStack to configure with- Returns:
- Created NPC
-
deregister
Deregisters theNPCand removes all data about it from the data store.- Parameters:
npc- The NPC to deregister
-
deregisterAll
void deregisterAll()Deregisters allNPCs from this registry.deregister(NPC) -
despawnNPCs
Despawn all NPCs within the registry.- Parameters:
reason- The reason to despawn
-
getById
Gets theNPCwith the given ID if it exists.- Parameters:
id- ID of the NPC- Returns:
- NPC with the given ID (may or may not be spawned)
-
getByUniqueId
Gets theNPCwith the given unique ID if it exists.- Parameters:
uuid- UUID of the NPC- Returns:
- NPC with the given ID (may or may not be spawned)
-
getByUniqueIdGlobal
Gets theNPCwith the given unique ID if it exists, otherwise null.- Parameters:
uuid- ID of the NPC- Returns:
- NPC with the given UUID
-
getName
String getName()Gets the name of the registry. Not null. -
getNPC
- Parameters:
entity- Entity to get the NPC from- Returns:
- NPC from the given entity or null if not found.
-
isNPC
- Parameters:
entity- Entity to check- Returns:
- Whether the given entity is an NPC
-
saveToStore
void saveToStore()Saves the NPCs to the internalNPCDataStore -
sorted
Returns a sorted view of this registry, sorted by NPC id.- Returns:
- A sorted view of the registry
-