Class Inventory

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

public class Inventory extends Trait
Represents an NPC's inventory.
  • Constructor Details

    • Inventory

      public Inventory()
  • Method Details

    • getContents

      public ItemStack[] getContents()
      Gets the contents of an NPC's inventory.
      Returns:
      ItemStack array of an NPC's inventory contents
    • getInventoryView

      public Inventory getInventoryView()
    • 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
    • onDespawn

      public void onDespawn()
      Description copied from class: Trait
      Called just before the attached NPC is despawned. NPC.getEntity() will be non-null.
      Overrides:
      onDespawn 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
    • openInventory

      public void openInventory(Player sender)
    • 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
    • setContents

      public void setContents(ItemStack[] contents)
      Sets the contents of an NPC's inventory.
      Parameters:
      contents - ItemStack array to set as the contents of an NPC's inventory
    • setItem

      public void setItem(int slot, ItemStack item)
    • toString

      public String toString()
      Overrides:
      toString in class Object