Class CitizensNPC

java.lang.Object
net.citizensnpcs.api.npc.AbstractNPC
net.citizensnpcs.npc.CitizensNPC
All Implemented Interfaces:
Cloneable, Agent, NPC

public class CitizensNPC extends AbstractNPC
  • Constructor Details

  • Method Details

    • despawn

      public boolean despawn(DespawnReason reason)
      Description copied from interface: NPC
      Despawns this NPC.
      Parameters:
      reason - The reason for despawning, for use in NPCDespawnEvent
      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 interface NPC
      Overrides:
      destroy in class AbstractNPC
    • faceLocation

      public void faceLocation(Location location)
      Description copied from interface: NPC
      Faces a given Location if the NPC is spawned.
    • getBlockBreaker

      public BlockBreaker getBlockBreaker(Block targetBlock, BlockBreaker.BlockBreakerConfiguration config)
    • getEntity

      public Entity getEntity()
      Description copied from interface: NPC
      Gets the Bukkit entity associated with this NPC. This may be null if NPC.isSpawned() is false.
      Returns:
      Entity associated with this NPC
    • getNavigator

      public Navigator getNavigator()
      Returns:
      The Navigator of this NPC.
    • getStoredLocation

      public Location 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 calling npc.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 interface NPC
      Overrides:
      isFlyable in class AbstractNPC
      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

      public void load(DataKey root)
      Description copied from interface: NPC
      Loads the NPC from the given DataKey. This reloads all traits, respawns the NPC and sets it up for execution. Should not be called often.
      Specified by:
      load in interface NPC
      Overrides:
      load in class AbstractNPC
      Parameters:
      root - The root data key
    • requiresNameHologram

      public boolean requiresNameHologram()
      Specified by:
      requiresNameHologram in interface NPC
      Overrides:
      requiresNameHologram in class AbstractNPC
    • save

      public void save(DataKey root)
      Description copied from interface: NPC
      Saves the 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).
      Specified by:
      save in interface NPC
      Overrides:
      save in class AbstractNPC
      Parameters:
      root - The root data key
    • setBukkitEntityType

      public void setBukkitEntityType(EntityType type)
      Description copied from interface: NPC
      Sets the 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.
      Parameters:
      type - The new mob type
    • setEntityController

      public void setEntityController(EntityController newController)
    • 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 interface NPC
      Overrides:
      setFlyable in class AbstractNPC
    • setName

      public void setName(String name)
      Description copied from interface: NPC
      Sets the name of this NPC.
      Specified by:
      setName in interface NPC
      Overrides:
      setName in class AbstractNPC
      Parameters:
      name - Name to give this NPC
    • spawn

      public boolean spawn(Location at)
      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

      public boolean spawn(Location at, SpawnReason reason)
      Description copied from interface: NPC
      Attempts to spawn this NPC.
      Parameters:
      at - Location to spawn this NPC
      reason - Reason for spawning
      Returns:
      Whether this NPC was able to spawn at the location
    • teleport

      public void teleport(Location location, PlayerTeleportEvent.TeleportCause reason)
      Description copied from interface: NPC
      An alternative to npc.getEntity().getLocation() that teleports passengers as well.
      Specified by:
      teleport in interface NPC
      Overrides:
      teleport in class AbstractNPC
      Parameters:
      location - The destination location
      reason - The cause for teleporting
    • update

      public void update()
      Overrides:
      update in class AbstractNPC