public class CitizensNPC extends AbstractNPC
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
Constructor and Description |
---|
CitizensNPC(UUID uuid,
int id,
String name,
EntityController entityController,
NPCRegistry registry) |
Modifier and Type | Method and Description |
---|---|
boolean |
despawn(DespawnReason reason)
Despawns this NPC.
|
void |
destroy()
Permanently removes this NPC and all data about it from the registry it's attached to.
|
void |
faceLocation(org.bukkit.Location location)
Faces a given
Location if the NPC is spawned. |
BlockBreaker |
getBlockBreaker(org.bukkit.block.Block targetBlock,
BlockBreaker.BlockBreakerConfiguration config) |
org.bukkit.entity.Entity |
getEntity()
Gets the Bukkit entity associated with this NPC.
|
Navigator |
getNavigator() |
org.bukkit.Location |
getStoredLocation()
If the NPC is not spawned, then this method will return the last known location, or null if it has never been
spawned.
|
boolean |
isFlyable()
Returns whether this NPC is flyable or not.
|
boolean |
isSpawned()
Gets whether this NPC is currently spawned.
|
void |
load(DataKey root)
|
boolean |
requiresNameHologram() |
void |
save(DataKey root)
|
void |
setBukkitEntityType(org.bukkit.entity.EntityType type)
Sets the
EntityType of this NPC. |
void |
setEntityController(EntityController newController) |
void |
setFlyable(boolean flyable)
Sets whether this NPC is flyable or not.
|
void |
setName(String name)
Sets the name of this NPC.
|
boolean |
spawn(org.bukkit.Location at)
Attempts to spawn this NPC.
|
boolean |
spawn(org.bukkit.Location at,
SpawnReason reason)
Attempts to spawn this NPC.
|
void |
teleport(org.bukkit.Location location,
org.bukkit.event.player.PlayerTeleportEvent.TeleportCause reason)
An alternative to
npc.getEntity().getLocation() that teleports passengers as well. |
void |
update() |
addTrait, addTrait, clone, copy, data, despawn, destroy, equals, getDefaultGoalController, getDefaultSpeechController, getEntityType, getFullName, getId, getName, getOrAddTrait, getOwningRegistry, getTrait, getTraitFor, getTraitNullable, getTraits, getUniqueId, hashCode, hasTrait, isProtected, removeTrait, setAlwaysUseNameHologram, setProtected, setUseMinecraftAI, unloadEvents, useMinecraftAI
public CitizensNPC(UUID uuid, int id, String name, EntityController entityController, NPCRegistry registry)
public boolean despawn(DespawnReason reason)
NPC
reason
- The reason for despawning, for use in NPCDespawnEvent
public void destroy()
NPC
destroy
in interface NPC
destroy
in class AbstractNPC
public void faceLocation(org.bukkit.Location location)
NPC
Location
if the NPC is spawned.public BlockBreaker getBlockBreaker(org.bukkit.block.Block targetBlock, BlockBreaker.BlockBreakerConfiguration config)
public org.bukkit.entity.Entity getEntity()
NPC
null
if NPC.isSpawned()
is false.public org.bukkit.Location getStoredLocation()
NPC
npc.getBukkitEntity().getLocation()
.null
if none was found.public boolean isFlyable()
NPC
isFlyable
in interface NPC
isFlyable
in class AbstractNPC
public boolean isSpawned()
NPC
public void load(DataKey root)
NPC
NPC
from the given DataKey
. This reloads all traits, respawns the NPC and sets it up
for execution. Should not be called often.load
in interface NPC
load
in class AbstractNPC
root
- The root data keypublic boolean requiresNameHologram()
requiresNameHologram
in interface NPC
requiresNameHologram
in class AbstractNPC
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)
.save
in interface NPC
save
in class AbstractNPC
root
- The root data keypublic void setBukkitEntityType(org.bukkit.entity.EntityType type)
NPC
EntityType
of this NPC. Currently only accepts living entity types, with scope for
additional types in the future. The NPC will respawned if currently spawned, or will remain despawned otherwise.type
- The new mob typepublic void setEntityController(EntityController newController)
public void setFlyable(boolean flyable)
NPC
setFlyable
in interface NPC
setFlyable
in class AbstractNPC
public void setName(String name)
NPC
setName
in interface NPC
setName
in class AbstractNPC
name
- Name to give this NPCpublic boolean spawn(org.bukkit.Location at)
NPC
at
- Location to spawn this NPCpublic boolean spawn(org.bukkit.Location at, SpawnReason reason)
NPC
at
- Location to spawn this NPCreason
- Reason for spawningpublic void teleport(org.bukkit.Location location, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause reason)
NPC
npc.getEntity().getLocation()
that teleports passengers as well.teleport
in interface NPC
teleport
in class AbstractNPC
location
- The destination locationreason
- The cause for teleportingpublic void update()
update
in class AbstractNPC
Copyright © 2021. All rights reserved.