Class Equipment

java.lang.Object
net.citizensnpcs.api.trait.Trait
net.citizensnpcs.api.trait.trait.Equipment
All Implemented Interfaces:
Runnable, Listener

public class Equipment extends Trait
Represents an NPC's equipment.
  • Constructor Details

    • Equipment

      public Equipment()
  • Method Details

    • get

      See Also:
    • get

      public ItemStack get(int slot)
      Get an NPC's equipment from the given slot.
      Parameters:
      slot - Slot where the armor is located (0-5)
      Returns:
      ItemStack from the given armor slot
    • getEquipment

      public ItemStack[] getEquipment()
      Get all of an NPC's equipment.
      Returns:
      An array of an NPC's equipment
    • getEquipmentBySlot

      public Map<Equipment.EquipmentSlot,ItemStack> getEquipmentBySlot()
      Get all of the equipment as a Map.
      Returns:
      A mapping of slot to item
    • load

      public void load(DataKey key) throws NPCLoadException
      Description copied from class: Trait
      Loads a trait.
      Overrides:
      load in class Trait
      Parameters:
      key - DataKey to load from
      Throws:
      NPCLoadException - Thrown if this trait failed to load properly
    • onAttach

      public void onAttach()
      Description copied from class: Trait
      Called when the trait has been attached to an NPC. Trait.npc will be null until this is called.
      Overrides:
      onAttach in class Trait
    • onSpawn

      public void onSpawn()
      Description copied from class: Trait
      Called when an NPC is spawned. NPC.getEntity() will return null until this is called. This is also called onAttach when the NPC is already spawned.
      Overrides:
      onSpawn in class Trait
    • run

      public void run()
      Description copied from class: Trait
      Called every tick if overridden.
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Trait
    • save

      public void save(DataKey key)
      Description copied from class: Trait
      Saves a trait.
      Overrides:
      save in class Trait
      Parameters:
      key - DataKey to save to
    • set

      public void set(Equipment.EquipmentSlot slot, ItemStack item)
      See Also:
    • set

      public void set(int slot, ItemStack item)
      Set the armor from the given slot as the given item.
      Parameters:
      slot - Slot of the armor (must be between 0 and 5)
      item - Item to set the armor as
    • toString

      public String toString()
      Overrides:
      toString in class Object