Package net.citizensnpcs.npc
Class CitizensNPC
java.lang.Object
net.citizensnpcs.api.npc.AbstractNPC
net.citizensnpcs.npc.CitizensNPC
-
Field Summary
Fields inherited from class net.citizensnpcs.api.npc.AbstractNPC
traits
Fields inherited from interface net.citizensnpcs.api.npc.NPC
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, KEEP_CHUNK_LOADED_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, SNEAKING_METADATA, SWIMMING_METADATA, TARGETABLE_METADATA, USE_MINECRAFT_AI_METADATA, VILLAGER_BLOCK_TRADES
-
Constructor Summary
ConstructorsConstructorDescriptionCitizensNPC
(UUID uuid, int id, String name, EntityController entityController, NPCRegistry registry) -
Method Summary
Modifier and TypeMethodDescriptionboolean
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
(Location location) Faces a givenLocation
if the NPC is spawned.getBlockBreaker
(Block targetBlock, BlockBreaker.BlockBreakerConfiguration config) Gets the Bukkit entity associated with this NPC.If the NPC is not spawned, then this method will return the last known location, or null if it has never been spawned.boolean
Returns whether this NPC is flyable or not.boolean
Gets whether this NPC is currently spawned.void
boolean
void
void
Sets theEntityType
of this NPC.void
setEntityController
(EntityController newController) void
setFlyable
(boolean flyable) Sets whether this NPC is flyable or not.void
Sets the name of this NPC.boolean
Attempts to spawn this NPC.boolean
spawn
(Location at, SpawnReason reason) Attempts to spawn this NPC.void
teleport
(Location location, PlayerTeleportEvent.TeleportCause reason) An alternative tonpc.getEntity().getLocation()
that teleports passengers as well.void
update()
Methods inherited from class net.citizensnpcs.api.npc.AbstractNPC
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
-
Constructor Details
-
CitizensNPC
public CitizensNPC(UUID uuid, int id, String name, EntityController entityController, NPCRegistry registry)
-
-
Method Details
-
despawn
Description copied from interface:NPC
Despawns this NPC.- Parameters:
reason
- The reason for despawning, for use inNPCDespawnEvent
- Returns:
- Whether this NPC was able to despawn
-
destroy
public void destroy()Description copied from interface:NPC
Permanently removes this NPC and all data about it from the registry it's attached to.- Specified by:
destroy
in interfaceNPC
- Overrides:
destroy
in classAbstractNPC
-
faceLocation
Description copied from interface:NPC
Faces a givenLocation
if the NPC is spawned. -
getBlockBreaker
public BlockBreaker getBlockBreaker(Block targetBlock, BlockBreaker.BlockBreakerConfiguration config) -
getEntity
Description copied from interface:NPC
Gets the Bukkit entity associated with this NPC. This may benull
ifNPC.isSpawned()
is false.- Returns:
- Entity associated with this NPC
-
getStoredLocation
Description copied from interface:NPC
If the NPC is not spawned, then this method will return the last known location, or null if it has never been spawned. Otherwise, it is equivalent to callingnpc.getBukkitEntity().getLocation()
.- Returns:
- The stored location, or
null
if none was found.
-
isFlyable
public boolean isFlyable()Description copied from interface:NPC
Returns whether this NPC is flyable or not.- Specified by:
isFlyable
in interfaceNPC
- Overrides:
isFlyable
in classAbstractNPC
- Returns:
- Whether this NPC is flyable
-
isSpawned
public boolean isSpawned()Description copied from interface:NPC
Gets whether this NPC is currently spawned.- Returns:
- Whether this NPC is spawned
-
load
Description copied from interface:NPC
Loads theNPC
from the givenDataKey
. This reloads all traits, respawns the NPC and sets it up for execution. Should not be called often.- Specified by:
load
in interfaceNPC
- Overrides:
load
in classAbstractNPC
- Parameters:
root
- The root data key
-
requiresNameHologram
public boolean requiresNameHologram()- Specified by:
requiresNameHologram
in interfaceNPC
- Overrides:
requiresNameHologram
in classAbstractNPC
-
save
Description copied from interface:NPC
Saves theNPC
to the givenDataKey
. This includes all metadata, traits, and spawn information that will allow it to respawn at a later time viaNPC.load(DataKey)
.- Specified by:
save
in interfaceNPC
- Overrides:
save
in classAbstractNPC
- Parameters:
root
- The root data key
-
setBukkitEntityType
Description copied from interface:NPC
Sets theEntityType
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.- Parameters:
type
- The new mob type
-
setEntityController
-
setFlyable
public void setFlyable(boolean flyable) Description copied from interface:NPC
Sets whether this NPC is flyable or not. Note that this is intended for normally ground-based entities only - it will generally have no effect on mob types that were originally flyable.- Specified by:
setFlyable
in interfaceNPC
- Overrides:
setFlyable
in classAbstractNPC
-
setName
Description copied from interface:NPC
Sets the name of this NPC.- Specified by:
setName
in interfaceNPC
- Overrides:
setName
in classAbstractNPC
- Parameters:
name
- Name to give this NPC
-
spawn
Description copied from interface:NPC
Attempts to spawn this NPC.- Parameters:
at
- Location to spawn this NPC- Returns:
- Whether this NPC was able to spawn at the location
-
spawn
Description copied from interface:NPC
Attempts to spawn this NPC.- Parameters:
at
- Location to spawn this NPCreason
- Reason for spawning- Returns:
- Whether this NPC was able to spawn at the location
-
teleport
Description copied from interface:NPC
An alternative tonpc.getEntity().getLocation()
that teleports passengers as well.- Specified by:
teleport
in interfaceNPC
- Overrides:
teleport
in classAbstractNPC
- Parameters:
location
- The destination locationreason
- The cause for teleporting
-
update
public void update()- Overrides:
update
in classAbstractNPC
-