Package net.citizensnpcs.api.npc
Class AbstractNPC
java.lang.Object
net.citizensnpcs.api.npc.AbstractNPC
- Direct Known Subclasses:
CitizensNPC
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.citizensnpcs.api.npc.NPC
NPC.Metadata, NPC.NPCUpdate -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractNPC(UUID uuid, int id, String name, NPCRegistry registry) -
Method Summary
Modifier 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.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.citizensnpcs.api.npc.NPC
despawn, 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
-
addRunnable
Description copied from interface:NPCAdds aRunnablethat will run every tick. Note that removal is not yet supported.- Specified by:
addRunnablein interfaceNPC- Parameters:
runnable- Runnable to be added
-
addTrait
Description 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). -
addTrait
Description copied from interface:NPCAdds a trait to this NPC. -
clone
-
copy
-
data
-
destroy
public void destroy()Description copied from interface:NPCPermanently removes this NPC and all data about it from the registry it's attached to. -
equals
-
getDefaultGoalController
Description copied from interface:NPCGets the defaultGoalControllerof this NPC.- Specified by:
getDefaultGoalControllerin interfaceNPC- Returns:
- Default goal controller
-
getDefaultSpeechController
Description copied from interface:NPCGets the defaultSpeechControllerof this NPC.- Specified by:
getDefaultSpeechControllerin interfaceNPC- Returns:
- Default speech controller
-
getEntityType
-
getFullName
Description copied from interface:NPCGets the full name of this NPC.- Specified by:
getFullNamein interfaceNPC- Returns:
- Full name of this NPC
-
getId
public 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 interfaceNPC- See Also:
-
getMinecraftUniqueId
Description 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 interfaceNPC- Returns:
- The client unique ID.
-
getName
Description copied from interface:NPCGets the name of this NPC with color codes stripped. -
getOrAddTrait
Description 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 interfaceNPC- Parameters:
clazz- Trait to get- Returns:
- Trait with the given name
-
getOwningRegistry
- Specified by:
getOwningRegistryin interfaceNPC- Returns:
- The
NPCRegistrythat created this NPC.
-
getRawName
- Specified by:
getRawNamein interfaceNPC
-
getTrait
Description 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
-
getTraitNullable
Description 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 interfaceNPC- Parameters:
clazz- Trait class- Returns:
- Trait with the given class
-
getTraits
Description copied from interface:NPCReturns the currently attachedTraits -
getUniqueId
Description copied from interface:NPCGets the unique id of this NPC. This is guaranteed to be unique for all NPCs.- Specified by:
getUniqueIdin interfaceNPC- Returns:
- The unique id
-
hashCode
public int hashCode() -
hasTrait
Description copied from interface:NPCChecks if this NPC has the given trait. -
load
Description copied from interface:NPC -
removeTrait
Description copied from interface:NPCRemoves a trait from this NPC.- Specified by:
removeTraitin interfaceNPC- Parameters:
traitClass- Trait to remove
-
requiresNameHologram
public boolean requiresNameHologram()- Specified by:
requiresNameHologramin interfaceNPC
-
save
Description 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). -
setItemProvider
Description copied from interface:NPC- Specified by:
setItemProviderin interfaceNPC- Parameters:
provider- The supplier
-
setName
Description copied from interface:NPCSets the name of this NPC. -
setNameInternal
-
teleport
Description copied from interface:NPCAn alternative tonpc.getEntity().getLocation()that teleports passengers as well. -
update
public void update()
-