public class CitizensNPCRegistry extends Object implements NPCRegistry
Constructor and Description |
---|
CitizensNPCRegistry(NPCDataStore store) |
CitizensNPCRegistry(NPCDataStore store,
String registryName) |
Modifier and Type | Method and Description |
---|---|
NPC |
createNPC(org.bukkit.entity.EntityType type,
String name)
Creates an despawned
NPC . |
NPC |
createNPC(org.bukkit.entity.EntityType type,
UUID uuid,
int id,
String name)
Creates an
NPC with the given id. |
void |
deregister(NPC npc)
Deregisters the
NPC and removes all data about it from the data store. |
void |
deregisterAll()
Deregisters all
NPC s from this registry. |
void |
despawnNPCs(DespawnReason reason)
Despawn all NPCs within the registry.
|
NPC |
getById(int id)
Gets the
NPC with the given ID if it exists. |
NPC |
getByUniqueId(UUID uuid)
Gets the
NPC with the given unique ID if it exists. |
NPC |
getByUniqueIdGlobal(UUID uuid)
Gets the
NPC with the given unique ID if it exists, otherwise null. |
String |
getName()
Gets the name of the registry.
|
NPC |
getNPC(org.bukkit.entity.Entity entity)
Tries to convert the given
Entity to a spawned NPC . |
boolean |
isNPC(org.bukkit.entity.Entity entity)
Checks whether the given
Entity is convertable to an NPC . |
Iterator<NPC> |
iterator() |
void |
saveToStore()
Saves the NPCs to the internal
NPCDataStore |
Iterable<NPC> |
sorted()
Returns a sorted view of this registry, sorted by NPC id.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public CitizensNPCRegistry(NPCDataStore store)
public CitizensNPCRegistry(NPCDataStore store, String registryName)
public NPC createNPC(org.bukkit.entity.EntityType type, String name)
NPCRegistry
NPC
.createNPC
in interface NPCRegistry
type
- EntityType
to assign to the NPCname
- Name to give the NPCpublic NPC createNPC(org.bukkit.entity.EntityType type, UUID uuid, int id, String name)
NPCRegistry
NPC
with the given id. WARNING: may overwrite any existing NPC in the registry with the same
ID.createNPC
in interface NPCRegistry
type
- The EntityType
of the NPC.id
- The NPC IDname
- The NPC namepublic void deregister(NPC npc)
NPCRegistry
NPC
and removes all data about it from the data store.deregister
in interface NPCRegistry
npc
- The NPC to deregisterpublic void deregisterAll()
NPCRegistry
NPC
s from this registry. NPCRegistry.deregister(NPC)
deregisterAll
in interface NPCRegistry
public void despawnNPCs(DespawnReason reason)
NPCRegistry
despawnNPCs
in interface NPCRegistry
public NPC getById(int id)
NPCRegistry
NPC
with the given ID if it exists.getById
in interface NPCRegistry
id
- ID of the NPCpublic NPC getByUniqueId(UUID uuid)
NPCRegistry
NPC
with the given unique ID if it exists.getByUniqueId
in interface NPCRegistry
uuid
- UUID of the NPCpublic NPC getByUniqueIdGlobal(UUID uuid)
NPCRegistry
NPC
with the given unique ID if it exists, otherwise null.getByUniqueIdGlobal
in interface NPCRegistry
uuid
- ID of the NPCpublic String getName()
NPCRegistry
getName
in interface NPCRegistry
public NPC getNPC(org.bukkit.entity.Entity entity)
NPCRegistry
Entity
to a spawned NPC
.getNPC
in interface NPCRegistry
entity
- Entity to get the NPC frompublic boolean isNPC(org.bukkit.entity.Entity entity)
NPCRegistry
Entity
is convertable to an NPC
.isNPC
in interface NPCRegistry
entity
- Entity to checkpublic void saveToStore()
NPCRegistry
NPCDataStore
saveToStore
in interface NPCRegistry
public Iterable<NPC> sorted()
NPCRegistry
sorted
in interface NPCRegistry
Copyright © 2021. All rights reserved.