Package net.citizensnpcs.npc
Class CitizensNPCRegistry
java.lang.Object
net.citizensnpcs.npc.CitizensNPCRegistry
- All Implemented Interfaces:
Iterable<NPC>,NPCRegistry
-
Constructor Summary
ConstructorsConstructorDescriptionCitizensNPCRegistry(NPCDataStore store) CitizensNPCRegistry(NPCDataStore store, String registryName) -
Method Summary
Modifier and TypeMethodDescriptioncreateNPC(EntityType type, String name) Creates an despawnedNPC.createNPC(EntityType type, UUID uuid, int id, String name) Creates anNPCwith the given id.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.booleaniterator()voidSaves the NPCs to the internalNPCDataStoresorted()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, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
CitizensNPCRegistry
-
CitizensNPCRegistry
-
-
Method Details
-
createNPC
Description copied from interface:NPCRegistryCreates an despawnedNPC.- Specified by:
createNPCin interfaceNPCRegistry- Parameters:
type-EntityTypeto assign to the NPCname- Name to give the NPC- Returns:
- Created NPC
-
createNPC
Description copied from interface:NPCRegistryCreates anNPCwith the given id. WARNING: may overwrite any existing NPC in the registry with the same ID.- Specified by:
createNPCin interfaceNPCRegistry- Parameters:
type- TheEntityTypeof the NPC.id- The NPC IDname- The NPC name- Returns:
- The created NPC
-
deregister
Description copied from interface:NPCRegistryDeregisters theNPCand removes all data about it from the data store.- Specified by:
deregisterin interfaceNPCRegistry- Parameters:
npc- The NPC to deregister
-
deregisterAll
public void deregisterAll()Description copied from interface:NPCRegistryDeregisters allNPCs from this registry.NPCRegistry.deregister(NPC)- Specified by:
deregisterAllin interfaceNPCRegistry
-
despawnNPCs
Description copied from interface:NPCRegistryDespawn all NPCs within the registry.- Specified by:
despawnNPCsin interfaceNPCRegistry
-
getById
Description copied from interface:NPCRegistryGets theNPCwith the given ID if it exists.- Specified by:
getByIdin interfaceNPCRegistry- Parameters:
id- ID of the NPC- Returns:
- NPC with the given ID (may or may not be spawned)
-
getByUniqueId
Description copied from interface:NPCRegistryGets theNPCwith the given unique ID if it exists.- Specified by:
getByUniqueIdin interfaceNPCRegistry- Parameters:
uuid- UUID of the NPC- Returns:
- NPC with the given ID (may or may not be spawned)
-
getByUniqueIdGlobal
Description copied from interface:NPCRegistryGets theNPCwith the given unique ID if it exists, otherwise null.- Specified by:
getByUniqueIdGlobalin interfaceNPCRegistry- Parameters:
uuid- ID of the NPC- Returns:
- NPC with the given UUID
-
getName
Description copied from interface:NPCRegistryGets the name of the registry. Not null.- Specified by:
getNamein interfaceNPCRegistry
-
getNPC
Description copied from interface:NPCRegistry- Specified by:
getNPCin 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:
isNPCin interfaceNPCRegistry- Parameters:
entity- Entity to check- Returns:
- Whether the given entity is an NPC
-
iterator
-
saveToStore
public void saveToStore()Description copied from interface:NPCRegistrySaves the NPCs to the internalNPCDataStore- Specified by:
saveToStorein interfaceNPCRegistry
-
sorted
Description copied from interface:NPCRegistryReturns a sorted view of this registry, sorted by NPC id.- Specified by:
sortedin interfaceNPCRegistry- Returns:
- A sorted view of the registry
-