Class NPC

java.lang.Object
dev.foxikle.customnpcs.api.NPC

public class NPC extends Object
A class providing a 'Paper API friendly' NPC object requring no NMS to use within a project.
  • Constructor Summary

    Constructors
    Constructor
    Description
    NPC(dev.foxikle.customnpcs.internal.interfaces.InternalNpc npc)
    A constructor for creating an api friendly npc object using an internal npc object.
    NPC(@NotNull org.bukkit.World world)
    The intended way to create an NPC
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates the NPC.
    void
    Permanantly deletes an NPC.
    Gets the equipment object representing the NPC's armor and hand items
    Gets the object representing the NPC's settings
    void
    injectPlayer(org.bukkit.entity.Player player)
    Injects the npc into the player's connection.
    void
    lookAt(org.bukkit.entity.Entity e, boolean atHead)
    Points the NPC's head in the direction of an entity
    void
    lookAt(org.bukkit.Location location)
    Points the NPC's head at a location
    void
    moveTo(org.bukkit.Location location)
    Move the npc to the specified location.
    void
    Reloads the NPC's settings within the Settings and Equipment objects
    void
    Temporarily removes an NPC.
    Sets the NPC's actions to the specified Collection
    setBoots(org.bukkit.inventory.ItemStack item)
    Deprecated.
    in favour of
    invalid reference
    dev.foxikle.customnpcs.data.Equipment#setBoots(ItemStack)
    setChestplate(org.bukkit.inventory.ItemStack item)
    Deprecated.
    in favour of
    invalid reference
    dev.foxikle.customnpcs.data.Equipment#setChest(ItemStack)
    void
    Sets the npc's equipment
    setHandItem(org.bukkit.inventory.ItemStack item)
    Deprecated.
    in favour of
    invalid reference
    dev.foxikle.customnpcs.data.Equipment#setHand(ItemStack)
    setHeading(double heading)
    Deprecated.
    in favour of
    invalid reference
    Settings#setDirection(double)
    setHelmet(org.bukkit.inventory.ItemStack item)
    Deprecated.
    in favour of
    invalid reference
    dev.foxikle.customnpcs.data.Equipment#setHead(ItemStack)
    setInteractable(boolean interactable)
    Deprecated.
    in favour of
    invalid reference
    Settings#setInteractable(boolean)
    setLeggings(org.bukkit.inventory.ItemStack item)
    Deprecated.
    in favour of
    invalid reference
    dev.foxikle.customnpcs.data.Equipment#setLegs(ItemStack)
    setName(@NotNull String name)
    Deprecated.
    setName(@NotNull net.kyori.adventure.text.Component name)
    Deprecated.
    setOffhandItem(org.bukkit.inventory.ItemStack item)
    Deprecated.
    in favour of
    invalid reference
    dev.foxikle.customnpcs.data.Equipment#setOffhand(ItemStack)
    setPostion(@NotNull org.bukkit.Location loc)
    Sets the location of the NPC
    setResilient(boolean resilient)
    Deprecated.
    in favour of
    invalid reference
    Settings#setResilient(boolean)
    void
    Sets the npc's settings
    setSkin(@NotNull String skinName, @NotNull String signature, @NotNull String value)
    Sets the leggings the NPC is wearing
    setTunnelVision(boolean tunnelVision)
    Deprecated.
    in favour of
    invalid reference
    Settings#setTunnelvision(boolean)
    void
    Swings the NPC's arm

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • NPC

      public NPC(@NotNull @NotNull org.bukkit.World world)
      The intended way to create an NPC

      By default, this npc has no actions

      By default, this npc has no skin

      By default, this npc has no name

      By default, this npc is not interactable

      By default, this npc is not resilient

      By default, this npc has a yaw of 0

      By default, this npc has tunnelvision

      Parameters:
      world - The world for the NPC to be created in
      Throws:
      NullPointerException - if the world is null
      IllegalStateException - if the API is not initilized
      Since:
      1.5-pre5
    • NPC

      public NPC(dev.foxikle.customnpcs.internal.interfaces.InternalNpc npc)
      A constructor for creating an api friendly npc object using an internal npc object.
      Parameters:
      npc - the internal npc to wrap for the api
  • Method Details

    • setName

      @Deprecated @ScheduledForRemoval(inVersion="1.7") public NPC setName(@NotNull @NotNull String name)
      Deprecated.

      Sets the display name of the NPC This supports SERIALIZED MiniMessage.

      Parameters:
      name - the new name
      Returns:
      the NPC with the modified name
      Since:
      1.5.2-pre3
    • setName

      @Deprecated @ScheduledForRemoval(inVersion="1.7") public NPC setName(@NotNull @NotNull net.kyori.adventure.text.Component name)
      Deprecated.

      Sets the display name of the NPC

      Parameters:
      name - of the NPC as an Adventure Component
      Returns:
      the NPC with the modified name
      Since:
      1.5.2-pre3
    • setPostion

      public NPC setPostion(@NotNull @NotNull org.bukkit.Location loc)

      Sets the location of the NPC

      Parameters:
      loc - the new location for the NPC
      Returns:
      the NPC with the modified location
      Since:
      1.5.2-pre3
    • setTunnelVision

      @Deprecated @ScheduledForRemoval(inVersion="1.7") public NPC setTunnelVision(boolean tunnelVision)
      Deprecated.
      in favour of
      invalid reference
      Settings#setTunnelvision(boolean)
      Sets the tunnelvision of the npc
      Parameters:
      tunnelVision - if the npc should have TunnelVision (Not looking at players)
      Returns:
      the npc with the modified TunnelVision
    • setSkin

      public NPC setSkin(@NotNull @NotNull String skinName, @NotNull @NotNull String signature, @NotNull @NotNull String value)

      Sets the leggings the NPC is wearing

      Parameters:
      skinName - the name to reference the skin by.
      signature - the encoded signature of the skin.
      value - the encoded value of the skin
      Returns:
      the NPC with the modified skin
      Throws:
      NullPointerException - if any argument is null
      Since:
      1.5.2-pre3
      See Also:
    • setHelmet

      @Deprecated @ScheduledForRemoval(inVersion="1.7") public NPC setHelmet(org.bukkit.inventory.ItemStack item)
      Deprecated.
      in favour of
      invalid reference
      dev.foxikle.customnpcs.data.Equipment#setHead(ItemStack)

      Sets the helmet the NPC is wearing

      Parameters:
      item - the item to be used
      Returns:
      the NPC with the modified helmet
      Since:
      1.5.2-pre3
    • setChestplate

      @Deprecated @ScheduledForRemoval(inVersion="1.7") public NPC setChestplate(org.bukkit.inventory.ItemStack item)
      Deprecated.
      in favour of
      invalid reference
      dev.foxikle.customnpcs.data.Equipment#setChest(ItemStack)

      Sets the chestplate the NPC is wearing

      Parameters:
      item - the item to be used
      Returns:
      the NPC with the modified chestplate
      Since:
      1.5.2-pre3
    • setLeggings

      @Deprecated @ScheduledForRemoval(inVersion="1.7") public NPC setLeggings(org.bukkit.inventory.ItemStack item)
      Deprecated.
      in favour of
      invalid reference
      dev.foxikle.customnpcs.data.Equipment#setLegs(ItemStack)

      Sets the leggings the NPC is wearing

      Parameters:
      item - the item to be used
      Returns:
      the NPC with the modified pair leggings
      Since:
      1.5.2-pre3
    • setBoots

      @Deprecated @ScheduledForRemoval(inVersion="1.7") public NPC setBoots(org.bukkit.inventory.ItemStack item)
      Deprecated.
      in favour of
      invalid reference
      dev.foxikle.customnpcs.data.Equipment#setBoots(ItemStack)

      Sets the boots the NPC is wearing

      Parameters:
      item - the item to be used
      Returns:
      the NPC with the modified pair of boots
      Since:
      1.5.2-pre3
    • setHandItem

      @Deprecated @ScheduledForRemoval(inVersion="1.7") public NPC setHandItem(org.bukkit.inventory.ItemStack item)
      Deprecated.
      in favour of
      invalid reference
      dev.foxikle.customnpcs.data.Equipment#setHand(ItemStack)

      Sets the item in the NPC's hand

      Parameters:
      item - the item to be used
      Returns:
      the NPC with the modified hand item
      Since:
      1.5.2-pre3
    • setOffhandItem

      @Deprecated @ScheduledForRemoval(inVersion="1.7") public NPC setOffhandItem(org.bukkit.inventory.ItemStack item)
      Deprecated.
      in favour of
      invalid reference
      dev.foxikle.customnpcs.data.Equipment#setOffhand(ItemStack)

      Sets the item in the NPC's offhand

      Parameters:
      item - the item to be used
      Returns:
      the NPC with the modified offhand item
      Since:
      1.5.2-pre3
    • setInteractable

      @Deprecated @ScheduledForRemoval(inVersion="1.7") public NPC setInteractable(boolean interactable)
      Deprecated.
      in favour of
      invalid reference
      Settings#setInteractable(boolean)

      Sets the NPC's interactability

      Parameters:
      interactable - should the NPC be interactable?
      Returns:
      the NPC with the modified interacability
      Since:
      1.5.2-pre3
    • setResilient

      @Deprecated @ScheduledForRemoval(inVersion="1.7") public NPC setResilient(boolean resilient)
      Deprecated.
      in favour of
      invalid reference
      Settings#setResilient(boolean)

      Sets the NPC's persistence (staying on server restart/reload).

      Parameters:
      resilient - should the NPC persist on reloads/server restarts?
      Returns:
      the NPC with the modified resiliency
      Since:
      1.5.2-pre3
    • setHeading

      @Deprecated @ScheduledForRemoval(inVersion="1.7") public NPC setHeading(double heading)
      Deprecated.
      in favour of
      invalid reference
      Settings#setDirection(double)

      Sets the NPC's facing direction

      Parameters:
      heading - the heading the NPC should face.
      Returns:
      the NPC with the modified heading
      Since:
      1.5.2-pre3
    • setActions

      public NPC setActions(Collection<Action> actions)

      Sets the NPC's actions to the specified Collection

      Parameters:
      actions - the colection of actions
      Returns:
      the NPC with the modified set of actions
      Since:
      1.5.2-pre3
      See Also:
    • moveTo

      public void moveTo(org.bukkit.Location location)
      Move the npc to the specified location. Takes into account pitch and yaw
      Parameters:
      location - the location to move to
    • swingArm

      public void swingArm()
      Swings the NPC's arm
      Since:
      1.5.2-pre3
    • injectPlayer

      public void injectPlayer(org.bukkit.entity.Player player)
      Injects the npc into the player's connection. This should be handled by the plugin, but this is here for more control.
      Parameters:
      player - the player to inject
      Since:
      1.5.2-pre3
      See Also:
      • Player
    • lookAt

      public void lookAt(org.bukkit.entity.Entity e, boolean atHead)
      Points the NPC's head in the direction of an entity
      Parameters:
      e - The entity to look at
      atHead - If the npc should look head (true), or feet (false)
    • lookAt

      public void lookAt(org.bukkit.Location location)
      Points the NPC's head at a location
      Parameters:
      location - the location to look at
    • create

      public UUID create()

      Creates the NPC.

      Returns:
      UUID the NPC's uuid for later reference
      Since:
      1.5.2-pre3
    • delete

      public void delete()

      Permanantly deletes an NPC. They will NOT reappear on the next reload or server restart. The NPC will NOT be despawned. Only applicable if the NPC is resilient.

      Throws:
      IllegalStateException - if the NPC is not resilient
      Since:
      1.5.2-pre3
    • remove

      public void remove()

      Temporarily removes an NPC. They will reappear on the next reload or server restart IF it is resilient.

      Since:
      1.5.2-pre3
    • getSettings

      public Settings getSettings()
      Gets the object representing the NPC's settings
      Returns:
      the object containing the resilience, tunnelvision, and interactablility
    • getEquipment

      public Equipment getEquipment()
      Gets the equipment object representing the NPC's armor and hand items
      Returns:
      the equipment object holding the NPC's items
    • reloadSettings

      public void reloadSettings()
      Reloads the NPC's settings within the Settings and Equipment objects
      See Also:
    • setSettings

      public void setSettings(Settings settings)
      Sets the npc's settings
      Parameters:
      settings - the settings to set
      See Also:
    • setEquipment

      public void setEquipment(Equipment equipment)
      Sets the npc's equipment
      Parameters:
      equipment - the equipment to set
      See Also: