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)
      Description copied from interface: NPC
      Creates a BlockBreaker that allows you to break blocks using the Minecraft breaking algorithm.
    • 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
    • getEntityController

      public EntityController getEntityController()
    • 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
    • isUpdating

      public boolean isUpdating(NPC.NPCUpdate update)
    • 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
    • scheduleUpdate

      public void scheduleUpdate(NPC.NPCUpdate update)
    • setBukkitEntityType

      public void setBukkitEntityType(EntityType type)
      Description copied from interface: NPC
      Sets the EntityType of this NPC. 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
      Parameters:
      flyable -
    • setMoveDestination

      public void setMoveDestination(Location destination)
      Description copied from interface: NPC
      Set the target movement destination location to walk towards using Minecraft movement. Should be set every tick.
      Parameters:
      destination - The destination Location
    • setNameInternal

      protected void setNameInternal(String name)
      Overrides:
      setNameInternal in class AbstractNPC
    • setSneaking

      public void setSneaking(boolean sneaking)
    • shouldRemoveFromPlayerList

      public boolean shouldRemoveFromPlayerList()
    • shouldRemoveFromTabList

      public boolean shouldRemoveFromTabList()
      Returns:
      Whether to remove the NPC from the tablist. Only applicable for Player-type NPCs.
    • 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
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • update

      public void update()
      Overrides:
      update in class AbstractNPC