Class Inventory


  • public class Inventory
    extends java.lang.Object
    Created with IntelliJ IDEA.
    Since:
    : 2/1/2015 Time : 2:33 PM
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int SLOT_HEIGHT  
      static int SLOT_WIDTH  
    • Constructor Summary

      Constructors 
      Constructor Description
      Inventory()
      Deprecated.
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static void add​(int index, Item t)  
      static boolean add​(Item t)  
      static java.util.List<Item> all()
      Gets the items in your inventory
      static java.util.List<Item> all​(Filter<Item> filter)
      A list of all the items.
      static int capacity()  
      static boolean contains​(int id)
      Contains boolean.
      static boolean contains​(java.lang.Integer... ids)
      Checks if your collection contains one item which meets one of the specified ids.
      static boolean contains​(java.lang.Object o)  
      static boolean contains​(java.lang.String string)
      Determines if collection contains item with specified name.
      static boolean contains​(java.lang.String... names)
      Checks if your collection contains one item which meets one of the specified names.
      static boolean contains​(Filter<Item> filter)
      Checks if your collection contains one item which meets the specified filter.
      static boolean containsAll​(int... ids)
      Checks if your Inventory contains all of the items with specified IDs
      static boolean containsAll​(java.lang.String... names)
      Checks if your Inventory contains all of the items with names specified
      static boolean containsAll​(java.util.Collection<?> collection)
      Checks if your collection contains all of the items in the collections
      static int count​(int id)
      Count of all the items that match the search.
      static int count​(java.lang.String name)
      Count of all the items that match the search.
      static int count​(Filter<Item> filter)
      Count of all the items that match the search.
      static boolean deselect()
      Deselects any item if it is selected
      static boolean drop​(int id)
      Drops the item with specified ID from inventory
      static boolean drop​(java.lang.String name)
      Drops the item with specified name from Inventory
      static boolean drop​(Filter<Item> filter)
      Drops the item matching specified Filter from Inventory
      static boolean dropAll()
      Drops all items in your inventory.
      static boolean dropAll​(int id)
      Drops all items in your inventory matching specified ID
      static boolean dropAll​(java.lang.Integer... ids)
      Drops all items in your inventory matching specified id's
      static boolean dropAll​(java.lang.String name)
      Drops all items in your inventory matching specified name
      static boolean dropAll​(java.lang.String... names)
      Drops all items in your inventory matching specified names.
      static boolean dropAll​(Filter<Item> filter)
      Drops all items in your inventory matching the specified filter
      static boolean dropAllExcept​(java.lang.Integer... ids)
      Drops all items that don't match the given ID's
      static boolean dropAllExcept​(java.lang.String... names)
      Drops all items that don't match the given names
      static boolean dropAllExcept​(Filter<Item> filter)
      Drops all items that are not filtered.
      static int emptySlotCount()
      Empty slot count.
      static java.util.List<Item> except​(Filter<Item> filter)
      Get all items which do not fit the given criteria.
      static int fullSlotCount()
      Full slot count.
      static Item get​(int id)  
      static Item get​(java.lang.Integer... ids)  
      static Item get​(java.lang.String name)
      Get item for specified name.
      static Item get​(java.lang.String... names)  
      static Item get​(Filter<Item> filter)  
      static DropPattern getDropPattern()  
      static int getEmptySlots()  
      static int getFirstEmptySlot()
      Gets the first empty slot in your inventory.
      static int getFirstFullSlot()
      Gets the next full slot in your inventory
      static int getIdForSlot​(int slot)
      Gets the Id of the Item in the slot.
      static Inventory getInventory()
      Deprecated.
      static Item getItemInSlot​(int index)
      Gets item in specified slot.
      static java.lang.String getNameForSlot​(int slot)
      Gets the Name for the Item in the slot.
      static Item getRandom​(int... itemIDs)
      Gets a random item that matches the item id(s) in your inventory
      static Item getRandom​(java.lang.String... itemNames)
      Gets a random item that matches the item name(s) in your inventory
      static Item getRandom​(Filter<Item> itemFilter)
      Gets a random item that matches the item filter in your inventory
      static int getSelectedItemIndex()
      Gets the index of the currently selected item.
      static java.lang.String getSelectedItemName()
      Gets the currently selected item name
      static boolean interact​(int id, java.lang.String action)
      Interact with an Item with specified ID in inventory
      static boolean interact​(java.lang.String name, java.lang.String action)
      Interact with the Item with specified name in Inventory
      static boolean interact​(Filter<Item> filter, java.lang.String action)
      Interact with an Item with specified ID in inventory
      static boolean isEmpty()  
      static boolean isForceNoShift()  
      static boolean isFull()
      Determines if container full.
      static boolean isItemSelected()
      Checks whether an item is currently selected in your inventory
      static boolean isSlotEmpty​(int slot)  
      static boolean isSlotFull​(int slot)
      Checks if the slot has an Item in it
      static java.awt.Rectangle itemBounds​(Item item)
      Gets the slot bounds of an item.
      static boolean onlyContains​(java.lang.Integer... id)
      Checks if your Inventory only contains items with specified ID
      static boolean onlyContains​(java.lang.String... names)
      Checks if your Inventory only contains items with specified name
      static boolean onlyContains​(Filter<Item> f)
      Checks if your Inventory only contains items that match the Filter
      static Item set​(int index, Item element)  
      static void setDropPattern​(DropPattern dropPattern)  
      static void setForceNoShift​(boolean forceNoShift)  
      static boolean shouldShift()  
      static int size()  
      static int slot​(int id)
      Gets the slot for the item with specified ID.
      static int slot​(java.lang.String name)
      Gets the slot for the item with specified name.
      static int slot​(Filter<Item> filter)
      Gets the slot for the item with specified name.
      static java.awt.Rectangle slotBounds​(int slot)
      Gets the bounds of a slot
      static boolean slotContains​(int slot, java.lang.Integer... ids)
      Checks if the slot contains items that matches the given ids.
      static boolean slotContains​(int slot, java.lang.String... names)
      Checks if the slot contains items that matches the given names.
      static boolean slotContains​(int slot, Filter<Item> filter)
      Checks if the slot contains items that matches the filter.
      static boolean slotContains​(int slot, Item t)
      Checks if the slot contains items that matches the given ids.
      static boolean slotInteract​(int slot, java.lang.String action)
      Interacts with specified slot in inventory
      static boolean slotNameContains​(int slot, java.lang.String sub)
      Checks if the slot contains items that matches the given ids.
      static java.lang.Object[] toArray()  
      static int widgetChildId()  
      static int widgetParentId()  
      • Methods inherited from class java.lang.Object

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

      • Inventory

        @Deprecated
        public Inventory()
        Deprecated.
    • Method Detail

      • getInventory

        @Deprecated
        public static Inventory getInventory()
        Deprecated.
        Returns the active Inventory instance
        Returns:
        inventory instance
      • getDropPattern

        public static DropPattern getDropPattern()
      • setDropPattern

        public static void setDropPattern​(DropPattern dropPattern)
      • widgetParentId

        public static int widgetParentId()
      • widgetChildId

        public static int widgetChildId()
      • capacity

        public static int capacity()
      • all

        public static java.util.List<Item> all()
        Gets the items in your inventory
        Returns:
        list of all items in your inventory.
      • slotInteract

        public static boolean slotInteract​(int slot,
                                           java.lang.String action)
        Interacts with specified slot in inventory
        Parameters:
        slot - Slot to interact with
        action - Action to use in interacting
        Returns:
        True if interaction was successful, else False
      • deselect

        public static boolean deselect()
        Deselects any item if it is selected
        Returns:
        True if succeeded
      • interact

        public static boolean interact​(int id,
                                       java.lang.String action)
        Interact with an Item with specified ID in inventory
        Parameters:
        id - Item ID to interact with
        action - Action to use in interacting
        Returns:
        True if interaction was successful, else False
      • interact

        public static boolean interact​(Filter<Item> filter,
                                       java.lang.String action)
        Interact with an Item with specified ID in inventory
        Parameters:
        filter - Item ID to interact with
        action - Action to use in interacting
        Returns:
        True if interaction was successful, else False
      • interact

        public static boolean interact​(java.lang.String name,
                                       java.lang.String action)
        Interact with the Item with specified name in Inventory
        Parameters:
        name - Name of item to interact with
        action - Action to use in interacting
        Returns:
        True if interaction was successful, else False
      • drop

        public static boolean drop​(int id)
        Drops the item with specified ID from inventory
        Parameters:
        id - ID of item to drop
        Returns:
        True if interaction was successful, else False
      • drop

        public static boolean drop​(java.lang.String name)
        Drops the item with specified name from Inventory
        Parameters:
        name - Name of item to drop
        Returns:
        True if interaction was successful, else False
      • drop

        public static boolean drop​(Filter<Item> filter)
        Drops the item matching specified Filter from Inventory
        Parameters:
        filter -
        Returns:
      • dropAll

        public static boolean dropAll()
        Drops all items in your inventory.
        Returns:
        true if all items were dropped
      • dropAll

        public static boolean dropAll​(int id)
        Drops all items in your inventory matching specified ID
        Parameters:
        id - Id of item to drop all of
        Returns:
        true if all items matching the id were dropped
      • dropAll

        public static boolean dropAll​(java.lang.String name)
        Drops all items in your inventory matching specified name
        Parameters:
        name - name of item to drop all of.
        Returns:
        is all of item matching description was dropped.
      • dropAll

        public static boolean dropAll​(java.lang.Integer... ids)
        Drops all items in your inventory matching specified id's
        Parameters:
        ids - id's of items you want to drop all of.
        Returns:
        returns contains(ids);
      • dropAll

        public static boolean dropAll​(java.lang.String... names)
        Drops all items in your inventory matching specified names.
        Parameters:
        names - names of items you want to drop all of
        Returns:
        returns contains(names)
      • dropAll

        public static boolean dropAll​(Filter<Item> filter)
        Drops all items in your inventory matching the specified filter
        Parameters:
        filter - Filter to match any items you want to drop all of
        Returns:
        returns contains(filter)
      • dropAllExcept

        public static boolean dropAllExcept​(java.lang.String... names)
        Drops all items that don't match the given names
        Parameters:
        names - Names of items to not drop
      • dropAllExcept

        public static boolean dropAllExcept​(java.lang.Integer... ids)
        Drops all items that don't match the given ID's
        Parameters:
        ids - IDs to not drop
      • dropAllExcept

        public static boolean dropAllExcept​(Filter<Item> filter)
        Drops all items that are not filtered.
        Parameters:
        filter - the filter which excludes items from dropping.
      • itemBounds

        public static java.awt.Rectangle itemBounds​(Item item)
        Gets the slot bounds of an item.
        Parameters:
        item - Item to get bounds of.
        Returns:
        Rectangle of Item slot.
      • slotBounds

        public static java.awt.Rectangle slotBounds​(int slot)
        Gets the bounds of a slot
        Parameters:
        slot - Slot to get bounds of
        Returns:
        Rectangle of the slot
      • isItemSelected

        public static boolean isItemSelected()
        Checks whether an item is currently selected in your inventory
        Returns:
        True if an item is selected, else false
      • getSelectedItemName

        public static java.lang.String getSelectedItemName()
        Gets the currently selected item name
        Returns:
        currently selected item name if no item name selected then null
      • getSelectedItemIndex

        public static int getSelectedItemIndex()
        Gets the index of the currently selected item.
        Returns:
        Integer value of currently selected item index, or if no item selected -1
      • getEmptySlots

        public static int getEmptySlots()
      • getRandom

        public static Item getRandom​(java.lang.String... itemNames)
        Gets a random item that matches the item name(s) in your inventory
        Parameters:
        itemNames - Name(s) of the item(s)
        Returns:
        Random Item that matches
      • getRandom

        public static Item getRandom​(int... itemIDs)
        Gets a random item that matches the item id(s) in your inventory
        Parameters:
        itemIDs - ID(s) of the item(s)
        Returns:
        Random Item that matches
      • getRandom

        public static Item getRandom​(Filter<Item> itemFilter)
        Gets a random item that matches the item filter in your inventory
        Parameters:
        itemFilter - Filter for the item you want to get
        Returns:
        Random item that matches the filter
      • isForceNoShift

        public static boolean isForceNoShift()
      • setForceNoShift

        public static void setForceNoShift​(boolean forceNoShift)
      • shouldShift

        public static boolean shouldShift()
      • fullSlotCount

        public static int fullSlotCount()
        Full slot count.
        Returns:
        the count of full slots as a int.
      • emptySlotCount

        public static int emptySlotCount()
        Empty slot count.
        Returns:
        the count of empty slots as a int.
      • isSlotEmpty

        public static boolean isSlotEmpty​(int slot)
      • isSlotFull

        public static boolean isSlotFull​(int slot)
        Checks if the slot has an Item in it
        Parameters:
        slot - slot to check
        Returns:
        True if there's an item there, else False
      • onlyContains

        public static boolean onlyContains​(java.lang.String... names)
        Checks if your Inventory only contains items with specified name
        Parameters:
        names - Names of items to look for
        Returns:
        True if Inventory only contains items with that name, else False
      • onlyContains

        public static boolean onlyContains​(java.lang.Integer... id)
        Checks if your Inventory only contains items with specified ID
        Parameters:
        id - IDs of items to check for
        Returns:
        True if Inventory only contains items with specified ID, else False
      • onlyContains

        public static boolean onlyContains​(Filter<Item> f)
        Checks if your Inventory only contains items that match the Filter
        Parameters:
        f - Filter to pass items through
        Returns:
        True if Inventory only contains items matching Filter, else False
      • slotContains

        public static boolean slotContains​(int slot,
                                           java.lang.String... names)
        Checks if the slot contains items that matches the given names.
        Parameters:
        names - names of the items to check
        Returns:
        true if Inventory only contains items matching Filter, else false
      • slotNameContains

        public static boolean slotNameContains​(int slot,
                                               java.lang.String sub)
        Checks if the slot contains items that matches the given ids.
        Parameters:
        sub - the substring which will be used to search.
        Returns:
        True if Inventory only contains items matching Filter, else false.
      • slotContains

        public static boolean slotContains​(int slot,
                                           java.lang.Integer... ids)
        Checks if the slot contains items that matches the given ids.
        Parameters:
        ids - ids of the items to check.
        Returns:
        True if Inventory only contains items matching Filter, else false.
      • slotContains

        public static boolean slotContains​(int slot,
                                           Item t)
        Checks if the slot contains items that matches the given ids.
        Parameters:
        t - The object to check.
        Returns:
        True if Inventory only contains items matching Filter, else false.
      • slotContains

        public static boolean slotContains​(int slot,
                                           Filter<Item> filter)
        Checks if the slot contains items that matches the filter.
        Parameters:
        filter - Filter to pass items through.
        Returns:
        True if Inventory only contains items matching Filter, else false.
      • getFirstEmptySlot

        public static int getFirstEmptySlot()
        Gets the first empty slot in your inventory.
        Returns:
        slot number, if inventory is full -1.
      • getFirstFullSlot

        public static int getFirstFullSlot()
        Gets the next full slot in your inventory
        Returns:
        slot number, if inventory is empty -1
      • getIdForSlot

        public static int getIdForSlot​(int slot)
        Gets the Id of the Item in the slot.
        Parameters:
        slot - Slot to get item id of.
        Returns:
        Item ID or -1 if no item.
      • getNameForSlot

        public static java.lang.String getNameForSlot​(int slot)
        Gets the Name for the Item in the slot.
        Parameters:
        slot - Slot to get item name of.
        Returns:
        Item name or "" if item is null.
      • slot

        public static int slot​(int id)
        Gets the slot for the item with specified ID.
        Parameters:
        id - ID of item to get slot of.
        Returns:
        Item slot or -1 if Item is null.
      • slot

        public static int slot​(java.lang.String name)
        Gets the slot for the item with specified name.
        Parameters:
        name - Name of item to get slot of.
        Returns:
        Item slot or -1 if Item is null.
      • slot

        public static int slot​(Filter<Item> filter)
        Gets the slot for the item with specified name.
        Parameters:
        filter - filter of of item to get slot of.
        Returns:
        Item slot or -1 if Item is null.
      • add

        public static boolean add​(Item t)
      • toArray

        public static java.lang.Object[] toArray()
      • add

        public static void add​(int index,
                               Item t)
      • all

        public static java.util.List<Item> all​(Filter<Item> filter)
        A list of all the items.
        Parameters:
        filter - the filter to search with.
        Returns:
        the list of all filtered items.
      • getItemInSlot

        public static Item getItemInSlot​(int index)
        Gets item in specified slot.
        Parameters:
        index - the index.
        Returns:
        the item in slot.
      • get

        public static Item get​(int id)
      • get

        public static Item get​(java.lang.Integer... ids)
      • get

        public static Item get​(java.lang.String name)
        Get item for specified name.
        Parameters:
        name - the name of the item.
        Returns:
        the item if list contains it, otherwise null.
      • get

        public static Item get​(java.lang.String... names)
      • except

        public static java.util.List<Item> except​(Filter<Item> filter)
        Get all items which do not fit the given criteria.
        Parameters:
        filter - The filter of the items to ignore.
        Returns:
        The list of items found which do not match the given criteria.
      • size

        public static int size()
      • isEmpty

        public static boolean isEmpty()
      • contains

        public static boolean contains​(int id)
        Contains boolean.
        Parameters:
        id - the id
        Returns:
        the boolean
      • contains

        public static boolean contains​(java.lang.String string)
        Determines if collection contains item with specified name.
        Parameters:
        string - the name of the item.
        Returns:
        true if collection contains item, otherwise false.
      • containsAll

        public static boolean containsAll​(java.lang.String... names)
        Checks if your Inventory contains all of the items with names specified
        Parameters:
        names - Names of items to check for
        Returns:
        True if Inventory contains all names, else False
      • containsAll

        public static boolean containsAll​(int... ids)
        Checks if your Inventory contains all of the items with specified IDs
        Parameters:
        ids - IDs of items to check for
        Returns:
        True if Inventory contains all IDs, else false.
      • containsAll

        public static boolean containsAll​(java.util.Collection<?> collection)
        Checks if your collection contains all of the items in the collections
        Parameters:
        collection - The collection of items to compare against
        Returns:
        True if inventory contains all of the items, else false.
      • contains

        public static boolean contains​(java.lang.Integer... ids)
        Checks if your collection contains one item which meets one of the specified ids.
        Parameters:
        ids - Item IDs to check for
        Returns:
        True if contains one of, else false
      • contains

        public static boolean contains​(java.lang.String... names)
        Checks if your collection contains one item which meets one of the specified names.
        Parameters:
        names - names to check for
        Returns:
        true if contains one of, else false.
      • contains

        public static boolean contains​(Filter<Item> filter)
        Checks if your collection contains one item which meets the specified filter.
        Parameters:
        filter - the filter to search with.
        Returns:
        true if contains one of, else false.
      • contains

        public static boolean contains​(java.lang.Object o)
      • isFull

        public static boolean isFull()
        Determines if container full.
        Returns:
        the boolean
      • count

        public static int count​(java.lang.String name)
        Count of all the items that match the search.
        Parameters:
        name - the name of the item.
        Returns:
        the total count of matching items.
      • count

        public static int count​(int id)
        Count of all the items that match the search.
        Parameters:
        id - the id of them item.
        Returns:
        the total count of matching items.
      • count

        public static int count​(Filter<Item> filter)
        Count of all the items that match the search.
        Parameters:
        filter - the filter to count with
        Returns:
        the total count of matching items.
      • set

        public static Item set​(int index,
                               Item element)