Class InventoryQuery

    • Constructor Detail

      • InventoryQuery

        public InventoryQuery​(Context ctx)
    • Method Detail

      • hasItem

        public boolean hasItem​(int id)
        Returns true when the inventory contains a specific item, found by its item id.
        Parameters:
        id - The id of the item to search for
        Returns:
        True if the inventory has the item and false otherwise
      • hasItem

        public boolean hasItem​(java.lang.String name)
        Returns true when the inventory contains a specific item, found by its name. This is case-insensitive but does require the entire item name.
        Parameters:
        name - The name of the item to search for
        Returns:
        True if the inventory has the item and false otherwise
      • hasItems

        public boolean hasItems​(int... ids)
        Returns true ONLY if the inventory contains ALL of the specified item IDs.
        Parameters:
        ids - Variable argument of item IDs to search for.
        Returns:
        True if every single ID in the arguments exists in the inventory.
      • hasItems

        public boolean hasItems​(java.util.List<java.lang.Integer> ids)
        Determines whether the inventory contains all items specified by the given list of IDs.

        If the provided list of IDs is null or empty, the method returns true. Otherwise, it internally converts the list to an array and delegates the check to the hasItems(int... ids) method.

        Parameters:
        ids - A List of Integer IDs representing the items to search for. Each ID corresponds to a specific inventory item.
        • If the list is null or empty, the method will return true.
        • All IDs in the list must exist in the inventory for the method to return true.
        Returns:
        true if the inventory contains all items specified in the list, or if the list is null or empty. Otherwise, false is returned.
      • hasItems

        public boolean hasItems​(java.lang.String... names)
        Returns true ONLY if the inventory contains ALL of the specified item names. This is case-insensitive.
        Parameters:
        names - Variable argument of item names to search for.
        Returns:
        True if every single name in the arguments exists in the inventory.
      • orderBy

        public InventoryQuery orderBy​(InventoryOrder order)
        Sorts the inventory query results based on the specified InventoryOrder.

        This method applies the given InventoryOrder's comparator to sort inventory items based on the desired order or pattern.

        Parameters:
        order - The InventoryOrder specifying the sorting strategy.
        • @TOP_LEFT_BOTTOM_RIGHT - Standard reading order: Row 1 (Left->Right), Row 2 (Left->Right), etc.
        • @BOTTOM_RIGHT_TOP_LEFT - Reverse reading order: Last Item -> First Item.
        • @ZIG_ZAG - Snake/Zig-Zag pattern: Row 1 (Left->Right), Row 2 (Right->Left), Row 3 (Left->Right), etc.
        • @ZIG_ZAG_REVERSE - Reverse Snake/Zig-Zag pattern starting from the bottom right.
        • @TOP_DOWN_LEFT_RIGHT - Vertical columns: Column 1 (Top->Bottom), Column 2 (Top->Bottom), etc.
        Returns:
        An InventoryQuery object containing the inventory items sorted based on the given order.
      • withAction

        public InventoryQuery withAction​(java.lang.String action)
        Filters for inventory items with a specific action like: "Drop", "Eat", or "Examine".
        Parameters:
        action - The action to filter for
        Returns:
        InventoryQuery
      • isEmpty

        public boolean isEmpty()
        Returns true if the inventory is empty and false otherwise.
        Returns:
        true if the inventory is empty and false otherwise.
      • isFull

        public boolean isFull()
        Returns true if the inventory is full and false otherwise.
        Returns:
        True if the inventory is full and false otherwise.
      • freeSpace

        public int freeSpace()
        Returns the free space in a users inventory.
        Returns:
        The amount of free space available in the players inventory
      • food

        public InventoryQuery food()
        Returns a list of Inventory Items which can be consumed for health.
        Returns:
        List of Inventory items which are food.
      • hasFood

        public boolean hasFood()
        Returns true when the player has edible hard food in their inventory and false otherwise.
        Returns:
        boolean
      • noted

        public InventoryQuery noted()
        Filters for items that are noted (cert).
        Returns:
        InventoryQuery
      • unnoted

        public InventoryQuery unnoted()
        Filters for un-noted items.
        Returns:
        InventoryQuery
      • stackable

        public InventoryQuery stackable()
        Filters for items that stack (runes, arrows, noted items).
        Returns:
        InventoryQuery
      • quantityGreaterThan

        public InventoryQuery quantityGreaterThan​(int amount)
        Filters by item quantity. This filter is strictly greater than i.e ctx.inventory().nameContains("karambwanji").quantityGreaterThan(500); will only return a ContainerItem when 501 Karambwanji's are present.
        Parameters:
        amount - The amount of the stack to filter for.
        Returns:
        InventoryQuery