Package net.citizensnpcs.api.npc
Class AbstractNPC
java.lang.Object
net.citizensnpcs.api.npc.AbstractNPC
- Direct Known Subclasses:
- CitizensNPC
- 
Nested Class SummaryNested classes/interfaces inherited from interface net.citizensnpcs.api.npc.NPCNPC.Metadata, NPC.NPCUpdate
- 
Field SummaryFields
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedAbstractNPC(UUID uuid, int id, String name, NPCRegistry registry) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddRunnable(Runnable runnable) Adds aRunnablethat will run every tick.voidAdds a trait to this NPC.voidAdds a trait to this NPC.clone()copy()data()voiddestroy()Permanently removes this NPC and all data about it from the registry it's attached to.booleanGets the defaultGoalControllerof this NPC.Gets the defaultSpeechControllerof this NPC.protected EntityTypeGets the full name of this NPC.intgetId()Gets the unique ID of this NPC.For certain mob types (currently, Players) it is beneficial to change the UUID slightly to signal to the client that the mob is an NPC not a real mob.getName()Gets the name of this NPC with color codes stripped.<T extends Trait>
 TgetOrAddTrait(Class<T> clazz) Gets a trait from the given class.<T extends Trait>
 TGets a trait from the given class.protected TraitgetTraitFor(Class<? extends Trait> clazz) <T extends Trait>
 TgetTraitNullable(Class<T> clazz) Gets the trait instance with the given class.Returns the currently attachedTraitsGets the unique id of this NPC.inthashCode()booleanChecks if this NPC has the given trait.voidvoidremoveTrait(Class<? extends Trait> traitClass) Removes a trait from this NPC.booleanvoidvoidsetItemProvider(Supplier<ItemStack> provider) voidSets the name of this NPC.protected voidsetNameInternal(String name) voidteleport(Location location, PlayerTeleportEvent.TeleportCause cause) An alternative tonpc.getEntity().getLocation()that teleports passengers as well.voidupdate()Methods inherited from class java.lang.Objectfinalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.citizensnpcs.api.npc.NPCdespawn, despawn, destroy, faceLocation, getBlockBreaker, getEntity, getNavigator, getStoredLocation, getTraitOptional, isFlyable, isHiddenFrom, isProtected, isPushableByFluids, isSpawned, isUpdating, scheduleUpdate, setAlwaysUseNameHologram, setBukkitEntityType, setFlyable, setMoveDestination, setProtected, setSneaking, setUseMinecraftAI, shouldRemoveFromPlayerList, shouldRemoveFromTabList, spawn, spawn, spawn, useMinecraftAI
- 
Field Details- 
coloredNameComponentCache
- 
coloredNameStringCache
- 
traits
 
- 
- 
Constructor Details- 
AbstractNPC
 
- 
- 
Method Details- 
addRunnableDescription copied from interface:NPCAdds aRunnablethat will run every tick. Note that removal is not yet supported.- Specified by:
- addRunnablein interface- NPC
- Parameters:
- runnable- Runnable to be added
 
- 
addTraitDescription copied from interface:NPCAdds a trait to this NPC. This will use theTraitFactorydefined for this NPC to construct and attach a trait usingNPC.addTrait(Trait).
- 
addTraitDescription copied from interface:NPCAdds a trait to this NPC.
- 
clone
- 
copy
- 
data
- 
destroypublic void destroy()Description copied from interface:NPCPermanently removes this NPC and all data about it from the registry it's attached to.
- 
equals
- 
getDefaultGoalControllerDescription copied from interface:NPCGets the defaultGoalControllerof this NPC.- Specified by:
- getDefaultGoalControllerin interface- NPC
- Returns:
- Default goal controller
 
- 
getDefaultSpeechControllerDescription copied from interface:NPCGets the defaultSpeechControllerof this NPC.- Specified by:
- getDefaultSpeechControllerin interface- NPC
- Returns:
- Default speech controller
 
- 
getEntityType
- 
getFullNameDescription copied from interface:NPCGets the full name of this NPC.- Specified by:
- getFullNamein interface- NPC
- Returns:
- Full name of this NPC
 
- 
getIdpublic int getId()Description copied from interface:NPCGets the unique ID of this NPC. This is not guaranteed to be globally unique across server sessions.
- 
getItemProvider- Specified by:
- getItemProviderin interface- NPC
- See Also:
 
- 
getMinecraftUniqueIdDescription copied from interface:NPCFor certain mob types (currently, Players) it is beneficial to change the UUID slightly to signal to the client that the mob is an NPC not a real mob. This will returnNPC.getUniqueId()with the necessary changes for the current mob type.- Specified by:
- getMinecraftUniqueIdin interface- NPC
- Returns:
- The client unique ID.
 
- 
getNameDescription copied from interface:NPCGets the name of this NPC with color codes stripped.
- 
getOrAddTraitDescription copied from interface:NPCGets a trait from the given class. If the NPC does not currently have the trait then it will be created and attached usingNPC.addTrait(Class).- Specified by:
- getOrAddTraitin interface- NPC
- Parameters:
- clazz- Trait to get
- Returns:
- Trait with the given name
 
- 
getOwningRegistry- Specified by:
- getOwningRegistryin interface- NPC
- Returns:
- The NPCRegistrythat created this NPC.
 
- 
getRawName- Specified by:
- getRawNamein interface- NPC
 
- 
getTraitDescription copied from interface:NPCGets a trait from the given class. If the NPC does not currently have the trait then it will be created and attached usingNPC.addTrait(Class).
- 
getTraitFor
- 
getTraitNullableDescription copied from interface:NPCGets the trait instance with the given class. If the NPC does not currently have the trait,nullwill be returned.- Specified by:
- getTraitNullablein interface- NPC
- Parameters:
- clazz- Trait class
- Returns:
- Trait with the given class
 
- 
getTraitsDescription copied from interface:NPCReturns the currently attachedTraits
- 
getUniqueIdDescription copied from interface:NPCGets the unique id of this NPC. This is guaranteed to be unique for all NPCs.- Specified by:
- getUniqueIdin interface- NPC
- Returns:
- The unique id
 
- 
hashCodepublic int hashCode()
- 
hasTraitDescription copied from interface:NPCChecks if this NPC has the given trait.
- 
loadDescription copied from interface:NPC
- 
removeTraitDescription copied from interface:NPCRemoves a trait from this NPC.- Specified by:
- removeTraitin interface- NPC
- Parameters:
- traitClass- Trait to remove
 
- 
requiresNameHologrampublic boolean requiresNameHologram()- Specified by:
- requiresNameHologramin interface- NPC
 
- 
saveDescription copied from interface:NPCSaves theNPCto the givenDataKey. This includes all metadata, traits, and spawn information that will allow it to respawn at a later time viaNPC.load(DataKey).
- 
setItemProviderDescription copied from interface:NPC- Specified by:
- setItemProviderin interface- NPC
- Parameters:
- provider- The supplier
 
- 
setNameDescription copied from interface:NPCSets the name of this NPC.
- 
setNameInternal
- 
teleportDescription copied from interface:NPCAn alternative tonpc.getEntity().getLocation()that teleports passengers as well.
- 
updatepublic void update()
 
-