Modifier and Type | Field and Description |
---|---|
protected Map<Class<? extends Trait>,Trait> |
traits |
ALWAYS_USE_NAME_HOLOGRAM_METADATA, AMBIENT_SOUND_METADATA, COLLIDABLE_METADATA, DAMAGE_OTHERS_METADATA, DEATH_SOUND_METADATA, DEFAULT_PROTECTED_METADATA, DISABLE_DEFAULT_STUCK_ACTION_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, USE_MINECRAFT_AI_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() |
NPC |
copy() |
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.
|
void |
destroy(org.bukkit.command.CommandSender source)
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. |
protected org.bukkit.entity.EntityType |
getEntityType() |
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.
|
<T extends Trait> |
getOrAddTrait(Class<T> clazz)
Gets a trait from the given class.
|
NPCRegistry |
getOwningRegistry() |
<T extends Trait> |
getTrait(Class<T> clazz)
Deprecated.
|
protected Trait |
getTraitFor(Class<? extends Trait> clazz) |
<T extends Trait> |
getTraitNullable(Class<T> clazz)
Gets a trait from the given class.
|
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.
|
boolean |
requiresNameHologram() |
void |
save(DataKey root)
|
void |
setAlwaysUseNameHologram(boolean use)
Sets whether to always use a name hologram instead of the in-built Minecraft name.
|
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 |
setUseMinecraftAI(boolean use)
Set the NPC to use Minecraft AI where possible.
|
void |
teleport(org.bukkit.Location location,
org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause)
An alternative to
npc.getEntity().getLocation() that teleports passengers as well. |
protected void |
unloadEvents() |
void |
update() |
boolean |
useMinecraftAI()
Whether the NPC is currently set to use Minecraft AI.
|
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 NPC copy()
public MetadataStore data()
public boolean despawn()
NPC
NPC.despawn(DespawnReason)
with
DespawnReason.PLUGIN
.public void destroy()
NPC
public void destroy(org.bukkit.command.CommandSender source)
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
protected org.bukkit.entity.EntityType getEntityType()
public String getFullName()
NPC
getFullName
in interface NPC
public int getId()
NPC
public String getName()
NPC
public <T extends Trait> T getOrAddTrait(Class<T> clazz)
NPC
NPC.addTrait(Class)
.getOrAddTrait
in interface NPC
clazz
- Trait to getpublic NPCRegistry getOwningRegistry()
getOwningRegistry
in interface NPC
NPCRegistry
that created this NPC.@Deprecated public <T extends Trait> T getTrait(Class<T> clazz)
NPC
NPC.addTrait(Class)
.public <T extends Trait> T getTraitNullable(Class<T> clazz)
NPC
null
will be
returned.getTraitNullable
in interface NPC
clazz
- Trait to getpublic 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 boolean requiresNameHologram()
requiresNameHologram
in interface NPC
public 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 setAlwaysUseNameHologram(boolean use)
NPC
setAlwaysUseNameHologram
in interface NPC
use
- Whether to use a hologrampublic 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 setUseMinecraftAI(boolean use)
NPC
setUseMinecraftAI
in interface NPC
public void teleport(org.bukkit.Location location, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause)
NPC
npc.getEntity().getLocation()
that teleports passengers as well.protected void unloadEvents()
public void update()
public boolean useMinecraftAI()
NPC
useMinecraftAI
in interface NPC
Copyright © 2021. All rights reserved.