Modifier and Type | Field and Description |
---|---|
protected Map<Class<? extends Trait>,Trait> |
traits |
AMBIENT_SOUND_METADATA, COLLIDABLE_METADATA, DAMAGE_OTHERS_METADATA, DEATH_SOUND_METADATA, DEFAULT_PROTECTED_METADATA, DROPS_ITEMS_METADATA, FLYABLE_METADATA, GLOWING_COLOR_METADATA, GLOWING_METADATA, HURT_SOUND_METADATA, ITEM_DATA_METADATA, ITEM_ID_METADATA, LEASH_PROTECTED_METADATA, MINECART_ITEM_DATA_METADATA, MINECART_ITEM_METADATA, MINECART_OFFSET_METADATA, NAMEPLATE_VISIBLE_METADATA, PATHFINDER_OPEN_DOORS_METADATA, PLAYER_SKIN_TEXTURE_PROPERTIES_METADATA, PLAYER_SKIN_TEXTURE_PROPERTIES_SIGN_METADATA, PLAYER_SKIN_USE_LATEST, PLAYER_SKIN_UUID_METADATA, RESPAWN_DELAY_METADATA, SCOREBOARD_FAKE_TEAM_NAME_METADATA, SHOULD_SAVE_METADATA, SILENT_METADATA, SWIMMING_METADATA, TARGETABLE_METADATA
Modifier | Constructor and Description |
---|---|
protected |
AbstractNPC(UUID uuid,
int id,
String name,
NPCRegistry registry) |
Modifier and Type | Method and Description |
---|---|
void |
addTrait(Class<? extends Trait> clazz)
Adds a trait to this NPC.
|
void |
addTrait(Trait trait)
Adds a trait to this NPC.
|
NPC |
clone() |
MetadataStore |
data() |
boolean |
despawn()
Despawns this NPC.
|
void |
destroy()
Permanently removes this NPC and all data about it from the registry it's attached to.
|
boolean |
equals(Object obj) |
GoalController |
getDefaultGoalController()
Gets the default
GoalController of this NPC. |
SpeechController |
getDefaultSpeechController()
Gets the default
SpeechController of this NPC. |
String |
getFullName()
Gets the full name of this NPC.
|
int |
getId()
Gets the unique ID of this NPC.
|
String |
getName()
Gets the name of this NPC with color codes stripped.
|
NPCRegistry |
getOwningRegistry() |
<T extends Trait> |
getTrait(Class<T> clazz)
Gets a trait from the given class.
|
protected Trait |
getTraitFor(Class<? extends Trait> clazz) |
Iterable<Trait> |
getTraits()
Returns the currently attached
Trait s |
UUID |
getUniqueId()
Gets the unique id of this NPC.
|
int |
hashCode() |
boolean |
hasTrait(Class<? extends Trait> trait)
Checks if this NPC has the given trait.
|
boolean |
isFlyable()
Returns whether this NPC is flyable or not.
|
boolean |
isProtected()
Gets whether this NPC is protected from damage, movement and other events that players and mobs use to change the
entity state of the NPC.
|
void |
load(DataKey root)
|
void |
removeTrait(Class<? extends Trait> traitClass)
Removes a trait from this NPC.
|
void |
save(DataKey root)
|
void |
setFlyable(boolean flyable)
Sets whether this NPC is flyable or not.
|
void |
setName(String name)
Sets the name of this NPC.
|
void |
setProtected(boolean isProtected)
A helper method for using
NPC.DEFAULT_PROTECTED_METADATA to set the NPC as protected or not protected from
damage/entity target events. |
void |
teleport(Location location,
PlayerTeleportEvent.TeleportCause cause)
An alternative to
npc.getEntity().getLocation() that teleports passengers as well. |
protected void |
unloadEvents() |
void |
update() |
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
despawn, faceLocation, getBlockBreaker, getEntity, getNavigator, getStoredLocation, isSpawned, setBukkitEntityType, spawn, spawn
protected AbstractNPC(UUID uuid, int id, String name, NPCRegistry registry)
public void addTrait(Class<? extends Trait> clazz)
NPC
TraitFactory
defined for this NPC to construct and attach a
trait using NPC.addTrait(Trait)
.public void addTrait(Trait trait)
NPC
public NPC clone()
public MetadataStore data()
public boolean despawn()
NPC
NPC.despawn(DespawnReason)
with
DespawnReason.PLUGIN
.public void destroy()
NPC
public GoalController getDefaultGoalController()
NPC
GoalController
of this NPC.getDefaultGoalController
in interface NPC
public SpeechController getDefaultSpeechController()
NPC
SpeechController
of this NPC.getDefaultSpeechController
in interface NPC
public String getFullName()
NPC
getFullName
in interface NPC
public int getId()
NPC
public String getName()
NPC
public NPCRegistry getOwningRegistry()
getOwningRegistry
in interface NPC
NPCRegistry
that created this NPC.public <T extends Trait> T getTrait(Class<T> clazz)
NPC
NPC.addTrait(Class)
.public Iterable<Trait> getTraits()
NPC
Trait
spublic UUID getUniqueId()
NPC
getUniqueId
in interface NPC
public boolean hasTrait(Class<? extends Trait> trait)
NPC
public boolean isFlyable()
NPC
public boolean isProtected()
NPC
isProtected
in interface NPC
public void removeTrait(Class<? extends Trait> traitClass)
NPC
removeTrait
in interface NPC
traitClass
- Trait to removepublic void save(DataKey root)
NPC
NPC
to the given DataKey
. This includes all metadata, traits, and spawn information
that will allow it to respawn at a later time via NPC.load(DataKey)
.public void setFlyable(boolean flyable)
NPC
setFlyable
in interface NPC
public void setName(String name)
NPC
public void setProtected(boolean isProtected)
NPC
NPC.DEFAULT_PROTECTED_METADATA
to set the NPC as protected or not protected from
damage/entity target events. Equivalent to
npc.data().set(NPC.DEFAULT_PROTECTED_METADATA, isProtected);
setProtected
in interface NPC
isProtected
- Whether the NPC should be protectedpublic void teleport(Location location, PlayerTeleportEvent.TeleportCause cause)
NPC
npc.getEntity().getLocation()
that teleports passengers as well.protected void unloadEvents()
public void update()
Copyright © 2019. All rights reserved.