Class Inventory


  • public class Inventory
    extends Items
    The Inventory class provides methods to interact with the player's inventory, including dropping items, using items on each other, and querying items by their name or ID. It extends the Items class and is responsible for managing inventory interactions in the game.
    • Constructor Summary

      Constructors 
      Constructor Description
      Inventory​(KSContext ctx)
      Constructor for Inventory, initializing with the InventoryID and widget info for handling inventory items.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void drop​(java.lang.String... items)
      Drops the first occurrence of the specified items by name from the inventory.
      void dropAll​(int... items)
      Drops all occurrences of the specified items by ID from the inventory.
      void dropAll​(java.lang.String... items)
      Drops all occurrences of the specified items by name from the inventory.
      void dropAllExcept​(int... items)
      Drops all occurrences of the without specified items by ID from the inventory.
      void dropAllExcept​(java.lang.String... items)
      Drops all occurrences of the without specified items by name from the inventory.
      void itemOnItem​(KSItem primary, KSItem secondary)
      Uses one item on another item in the inventory.
      boolean itemOnNpc​(KSItem item, KSNPC npc)  
      boolean itemOnObject​(KSItem item, KSObject object)  
      void wear​(int... items)
      Equips all occurrences of the specified items by ID from the inventory.
      void wear​(java.lang.String... items)
      Equips all occurrences of the specified items by name from the inventory.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Inventory

        public Inventory​(KSContext ctx)
        Constructor for Inventory, initializing with the InventoryID and widget info for handling inventory items.
    • Method Detail

      • drop

        public void drop​(java.lang.String... items)
        Drops the first occurrence of the specified items by name from the inventory.
        Parameters:
        items - The names of the items to drop.
      • dropAll

        public void dropAll​(java.lang.String... items)
        Drops all occurrences of the specified items by name from the inventory.
        Parameters:
        items - The names of the items to drop.
      • dropAll

        public void dropAll​(int... items)
        Drops all occurrences of the specified items by ID from the inventory.
        Parameters:
        items - The IDs of the items to drop.
      • dropAllExcept

        public void dropAllExcept​(int... items)
        Drops all occurrences of the without specified items by ID from the inventory.
        Parameters:
        items - The IDs of the items not to drop.
      • dropAllExcept

        public void dropAllExcept​(java.lang.String... items)
        Drops all occurrences of the without specified items by name from the inventory.
        Parameters:
        items - The name of the items not to drop.
      • wear

        public void wear​(int... items)
        Equips all occurrences of the specified items by ID from the inventory.
        Parameters:
        items - The IDs of the items to equip.
      • wear

        public void wear​(java.lang.String... items)
        Equips all occurrences of the specified items by name from the inventory.
        Parameters:
        items - The name of the items to equip.
      • itemOnItem

        public void itemOnItem​(KSItem primary,
                               KSItem secondary)
        Uses one item on another item in the inventory. This simulates the action of interacting with two inventory items, such as combining them or using them together.
        Parameters:
        primary - The primary item to use.
        secondary - The secondary item to use the primary item on.
      • itemOnObject

        public boolean itemOnObject​(KSItem item,
                                    KSObject object)
      • itemOnNpc

        public boolean itemOnNpc​(KSItem item,
                                 KSNPC npc)