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
traitsFields 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 TypeMethodDescriptionbooleandespawn(DespawnReason reason) Despawns this NPC.voiddestroy()Permanently removes this NPC and all data about it from the registry it's attached to.voidfaceLocation(Location location) Faces a givenLocationif 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.booleanReturns whether this NPC is flyable or not.booleanGets whether this NPC is currently spawned.voidbooleanvoidvoidSets theEntityTypeof this NPC.voidsetEntityController(EntityController newController) voidsetFlyable(boolean flyable) Sets whether this NPC is flyable or not.voidSets the name of this NPC.booleanAttempts to spawn this NPC.booleanspawn(Location at, SpawnReason reason) Attempts to spawn this NPC.voidteleport(Location location, PlayerTeleportEvent.TeleportCause reason) An alternative tonpc.getEntity().getLocation()that teleports passengers as well.voidupdate()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:NPCDespawns 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:NPCPermanently removes this NPC and all data about it from the registry it's attached to.- Specified by:
destroyin interfaceNPC- Overrides:
destroyin classAbstractNPC
-
faceLocation
Description copied from interface:NPCFaces a givenLocationif the NPC is spawned. -
getBlockBreaker
public BlockBreaker getBlockBreaker(Block targetBlock, BlockBreaker.BlockBreakerConfiguration config) -
getEntity
Description copied from interface:NPCGets the Bukkit entity associated with this NPC. This may benullifNPC.isSpawned()is false.- Returns:
- Entity associated with this NPC
-
getStoredLocation
Description copied from interface:NPCIf 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
nullif none was found.
-
isFlyable
public boolean isFlyable()Description copied from interface:NPCReturns whether this NPC is flyable or not.- Specified by:
isFlyablein interfaceNPC- Overrides:
isFlyablein classAbstractNPC- Returns:
- Whether this NPC is flyable
-
isSpawned
public boolean isSpawned()Description copied from interface:NPCGets whether this NPC is currently spawned.- Returns:
- Whether this NPC is spawned
-
load
Description copied from interface:NPCLoads theNPCfrom the givenDataKey. This reloads all traits, respawns the NPC and sets it up for execution. Should not be called often.- Specified by:
loadin interfaceNPC- Overrides:
loadin classAbstractNPC- Parameters:
root- The root data key
-
requiresNameHologram
public boolean requiresNameHologram()- Specified by:
requiresNameHologramin interfaceNPC- Overrides:
requiresNameHologramin classAbstractNPC
-
save
Description copied from interface:NPCSaves theNPCto 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:
savein interfaceNPC- Overrides:
savein classAbstractNPC- Parameters:
root- The root data key
-
setBukkitEntityType
Description copied from interface:NPCSets theEntityTypeof 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:NPCSets 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:
setFlyablein interfaceNPC- Overrides:
setFlyablein classAbstractNPC
-
setName
Description copied from interface:NPCSets the name of this NPC.- Specified by:
setNamein interfaceNPC- Overrides:
setNamein classAbstractNPC- Parameters:
name- Name to give this NPC
-
spawn
Description copied from interface:NPCAttempts 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:NPCAttempts 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:NPCAn alternative tonpc.getEntity().getLocation()that teleports passengers as well.- Specified by:
teleportin interfaceNPC- Overrides:
teleportin classAbstractNPC- Parameters:
location- The destination locationreason- The cause for teleporting
-
update
public void update()- Overrides:
updatein classAbstractNPC
-