Package net.citizensnpcs.api.trait
Class Trait
java.lang.Object
net.citizensnpcs.api.trait.Trait
- Direct Known Subclasses:
- Age,- AllayTrait,- Anchors,- AreaEffectCloudTrait,- ArmadilloTrait,- ArmorStandTrait,- AttributeTrait,- AxolotlTrait,- BatTrait,- BeeTrait,- BoatTrait,- BossBarTrait,- BoundingBoxTrait,- CamelTrait,- CatTrait,- ChickenTrait,- ClickRedirectTrait,- CommandTrait,- Controllable,- CowTrait,- CurrentLocation,- DisplayTrait,- DropsTrait,- EnderCrystalTrait,- EnderDragonTrait,- EndermanTrait,- EntityPoseTrait,- Equipment,- FollowTrait,- ForcefieldTrait,- FoxTrait,- FrogTrait,- GameModeTrait,- GoatTrait,- Gravity,- HologramTrait,- HomeTrait,- HorseModifiers,- Inventory,- ItemFrameTrait,- LlamaTrait,- LookClose,- MirrorTrait,- MobType,- MountTrait,- MushroomCowTrait,- OcelotModifiers,- Owner,- PacketNPC,- PaintingTrait,- PandaTrait,- ParrotTrait,- PausePathfindingTrait,- PhantomTrait,- PiglinTrait,- PigTrait,- PlayerFilter,- PolarBearTrait,- Poses,- PotionEffectsTrait,- Powered,- PufferFishTrait,- RabbitType,- RotationTrait,- Saddle,- ScaledMaxHealthTrait,- ScoreboardTrait,- SheepTrait,- ShopTrait,- ShulkerTrait,- SitTrait,- SkinLayers,- SkinTrait,- SleepTrait,- SlimeSize,- SneakTrait,- SnifferTrait,- SnowmanTrait,- Spawned,- SpellcasterTrait,- TargetableTrait,- Text,- TextDisplayTrait,- TropicalFishTrait,- VexTrait,- VillagerProfession,- VillagerTrait,- WardenTrait,- Waypoints,- WitherTrait,- WolfModifiers,- WoolColor
Represents a Trait linked to an 
NPC that can be loaded and saved. This will be kept persisted inside a
 NPC across server restarts. Traits must be registered in Citizens' TraitFactory.
 All traits should have a default constructor with no arguments for persistence purposes.- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionfinal StringgetName()Gets the name of this trait.final NPCgetNPC()booleanvoidvoidLoads a trait.voidonAttach()Called when the trait has been attached to anNPC.voidonCopy()Called when the trait has been newly copied to anNPC.voidCalled just before the attachedNPCis despawned.voidonDespawn(DespawnReason reason) Called just before the attachedNPCis despawned.voidCalled just before theNPCis spawned.voidonRemove()Called when a trait is removed from the attachedNPC.voidonRemove(RemoveReason reason) Called when a trait is removed from the attachedNPC.voidonSpawn()Called when anNPCis spawned.voidrun()Called every tick if overridden.voidSaves a trait.
- 
Field Details- 
npc
 
- 
- 
Constructor Details- 
Trait
 
- 
- 
Method Details- 
getNameGets the name of this trait.- Returns:
- Name of this trait
 
- 
getNPC- Returns:
- The NPCthis trait is attached to. May be null.
 
- 
isRunImplementedpublic boolean isRunImplemented()
- 
linkToNPC
- 
loadLoads a trait.- Parameters:
- key- DataKey to load from
- Throws:
- NPCLoadException- Thrown if this trait failed to load properly
 
- 
onAttachpublic void onAttach()
- 
onCopypublic void onCopy()Called when the trait has been newly copied to anNPC.
- 
onDespawnpublic void onDespawn()Called just before the attachedNPCis despawned.NPC.getEntity()will be non-null.
- 
onDespawnCalled just before the attachedNPCis despawned.NPC.getEntity()will be non-null.
- 
onPreSpawnpublic void onPreSpawn()Called just before theNPCis spawned.NPC.getEntity()will return an unspawned entity.
- 
onRemovepublic void onRemove()Called when a trait is removed from the attachedNPC.
- 
onRemoveCalled when a trait is removed from the attachedNPC.
- 
onSpawnpublic void onSpawn()Called when anNPCis spawned.NPC.getEntity()will return null until this is called. This is also called onAttach when the NPC is already spawned.
- 
runpublic void run()Called every tick if overridden.
- 
saveSaves a trait.- Parameters:
- key- DataKey to save to
 
 
-