Package net.citizensnpcs.api.npc
Interface NPCRegistry
- All Known Implementing Classes:
CitizensNPCRegistry
Controls the registration and lookup of a set of
NPC
s.-
Method Summary
Modifier and TypeMethodDescriptioncreateNPC
(EntityType type, String name) Creates an despawnedNPC
.createNPC
(EntityType type, String name, Location loc) Creates an spawnedNPC
at the given location.createNPC
(EntityType type, UUID uuid, int id, String name) Creates anNPC
with the given id.createNPCUsingItem
(EntityType type, String name, ItemStack item) Creates an despawnedNPC
using the given ItemStack to configure it if possible.void
deregister
(NPC npc) Deregisters theNPC
and removes all data about it from the data store.void
Deregisters allNPC
s from this registry.void
despawnNPCs
(DespawnReason reason) Despawn all NPCs within the registry.getById
(int id) Gets theNPC
with the given ID if it exists.getByUniqueId
(UUID uuid) Gets theNPC
with the given unique ID if it exists.getByUniqueIdGlobal
(UUID uuid) Gets theNPC
with the given unique ID if it exists, otherwise null.getName()
Gets the name of the registry.boolean
void
Saves the NPCs to the internalNPCDataStore
sorted()
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
-EntityType
to assign to the NPCname
- Name to give the NPC- Returns:
- Created NPC
-
createNPC
Creates an spawnedNPC
at the given location.- Parameters:
type
-EntityType
to assign to the NPCname
- Name to give the NPCloc
- The location to spawn at- Returns:
- Created NPC
-
createNPC
Creates anNPC
with the given id. WARNING: may overwrite any existing NPC in the registry with the same ID.- Parameters:
type
- TheEntityType
of the NPC.id
- The NPC IDname
- The NPC name- Returns:
- The created NPC
-
createNPCUsingItem
Creates an despawnedNPC
using the given ItemStack to configure it if possible.- Parameters:
type
-EntityType
to assign to the NPCname
- Name to give the NPCitem
- ItemStack to configure with- Returns:
- Created NPC
-
deregister
Deregisters theNPC
and removes all data about it from the data store.- Parameters:
npc
- The NPC to deregister
-
deregisterAll
void deregisterAll()Deregisters allNPC
s from this registry.deregister(NPC)
-
despawnNPCs
Despawn all NPCs within the registry.- Parameters:
reason
- The reason to despawn
-
getById
Gets theNPC
with 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 theNPC
with 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 theNPC
with 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
-