Package net.citizensnpcs.npc
Class CitizensNPCRegistry
java.lang.Object
net.citizensnpcs.npc.CitizensNPCRegistry
- All Implemented Interfaces:
Iterable<NPC>
,NPCRegistry
-
Constructor Summary
ConstructorDescriptionCitizensNPCRegistry
(NPCDataStore store) CitizensNPCRegistry
(NPCDataStore store, String registryName) -
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
iterator()
void
Saves the NPCs to the internalNPCDataStore
sorted()
Returns a sorted view of this registry, sorted by NPC id.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
CitizensNPCRegistry
-
CitizensNPCRegistry
-
-
Method Details
-
createNPC
Description copied from interface:NPCRegistry
Creates an despawnedNPC
.- Specified by:
createNPC
in interfaceNPCRegistry
- Parameters:
type
-EntityType
to assign to the NPCname
- Name to give the NPC- Returns:
- Created NPC
-
createNPC
Description copied from interface:NPCRegistry
Creates an spawnedNPC
at the given location.- Specified by:
createNPC
in interfaceNPCRegistry
- Parameters:
type
-EntityType
to assign to the NPCname
- Name to give the NPCloc
- The location to spawn at- Returns:
- Created NPC
-
createNPC
Description copied from interface:NPCRegistry
Creates anNPC
with the given id. WARNING: may overwrite any existing NPC in the registry with the same ID.- Specified by:
createNPC
in interfaceNPCRegistry
- Parameters:
type
- TheEntityType
of the NPC.id
- The NPC IDname
- The NPC name- Returns:
- The created NPC
-
createNPCUsingItem
Description copied from interface:NPCRegistry
Creates an despawnedNPC
using the given ItemStack to configure it if possible.- Specified by:
createNPCUsingItem
in interfaceNPCRegistry
- Parameters:
type
-EntityType
to assign to the NPCname
- Name to give the NPCitem
- ItemStack to configure with- Returns:
- Created NPC
-
deregister
Description copied from interface:NPCRegistry
Deregisters theNPC
and removes all data about it from the data store.- Specified by:
deregister
in interfaceNPCRegistry
- Parameters:
npc
- The NPC to deregister
-
deregisterAll
public void deregisterAll()Description copied from interface:NPCRegistry
Deregisters allNPC
s from this registry.NPCRegistry.deregister(NPC)
- Specified by:
deregisterAll
in interfaceNPCRegistry
-
despawnNPCs
Description copied from interface:NPCRegistry
Despawn all NPCs within the registry.- Specified by:
despawnNPCs
in interfaceNPCRegistry
- Parameters:
reason
- The reason to despawn
-
getById
Description copied from interface:NPCRegistry
Gets theNPC
with the given ID if it exists.- Specified by:
getById
in interfaceNPCRegistry
- Parameters:
id
- ID of the NPC- Returns:
- NPC with the given ID (may or may not be spawned)
-
getByUniqueId
Description copied from interface:NPCRegistry
Gets theNPC
with the given unique ID if it exists.- Specified by:
getByUniqueId
in interfaceNPCRegistry
- Parameters:
uuid
- UUID of the NPC- Returns:
- NPC with the given ID (may or may not be spawned)
-
getByUniqueIdGlobal
Description copied from interface:NPCRegistry
Gets theNPC
with the given unique ID if it exists, otherwise null.- Specified by:
getByUniqueIdGlobal
in interfaceNPCRegistry
- Parameters:
uuid
- ID of the NPC- Returns:
- NPC with the given UUID
-
getName
Description copied from interface:NPCRegistry
Gets the name of the registry. Not null.- Specified by:
getName
in interfaceNPCRegistry
-
getNPC
Description copied from interface:NPCRegistry
- Specified by:
getNPC
in interfaceNPCRegistry
- Parameters:
entity
- Entity to get the NPC from- Returns:
- NPC from the given entity or null if not found.
-
isNPC
Description copied from interface:NPCRegistry
- Specified by:
isNPC
in interfaceNPCRegistry
- Parameters:
entity
- Entity to check- Returns:
- Whether the given entity is an NPC
-
iterator
-
saveToStore
public void saveToStore()Description copied from interface:NPCRegistry
Saves the NPCs to the internalNPCDataStore
- Specified by:
saveToStore
in interfaceNPCRegistry
-
sorted
Description copied from interface:NPCRegistry
Returns a sorted view of this registry, sorted by NPC id.- Specified by:
sorted
in interfaceNPCRegistry
- Returns:
- A sorted view of the registry
-