Package net.citizensnpcs.trait
Class FollowTrait
java.lang.Object
net.citizensnpcs.api.trait.Trait
net.citizensnpcs.trait.FollowTrait
Persists a
Player
to follow while spawned. Optionally allows protecting of the player as well.-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
isActive()
Returns whether the trait is actively following aPlayer
.boolean
void
Called just before the attachedNPC
is despawned.void
onSpawn()
Called when anNPC
is spawned.void
run()
Called every tick if overridden.boolean
toggle
(OfflinePlayer player, boolean protect) Toggles and/or sets theOfflinePlayer
to follow and whether to protect them (similar to wolves in Minecraft, attack whoever attacks the player).
-
Constructor Details
-
FollowTrait
public FollowTrait()
-
-
Method Details
-
getFollowingPlayer
-
isActive
public boolean isActive()Returns whether the trait is actively following aPlayer
. -
isEnabled
public boolean isEnabled() -
onDespawn
public void onDespawn()Description copied from class:Trait
Called just before the attachedNPC
is despawned.NPC.getEntity()
will be non-null. -
onSpawn
public void onSpawn()Description copied from class:Trait
Called when anNPC
is spawned.NPC.getEntity()
will return null until this is called. This is also called onAttach when the NPC is already spawned. -
run
public void run()Description copied from class:Trait
Called every tick if overridden. -
toggle
Toggles and/or sets theOfflinePlayer
to follow and whether to protect them (similar to wolves in Minecraft, attack whoever attacks the player). Will toggle if theOfflinePlayer
is the player currently being followed.- Parameters:
player
- the player to followprotect
- whether to protect the player- Returns:
- whether the trait is enabled
-