Class GroundItemQuery

java.lang.Object
privbot.query.GroundItemQuery

public final class GroundItemQuery extends Object
Fluent filter chain over ground item stacks, built by ctx.groundItems.query().

Each PrivGroundItem is a snapshot taken when the query was built (id, quantity, tile); use PrivGroundItem.exists() to check that a stack is still there. Filters narrow the query in place, so a query is single-use.

  • Constructor Details

    • GroundItemQuery

      public GroundItemQuery(List<PrivGroundItem> raw, net.runelite.api.Client client)
      Wraps a copy of raw; plugins normally get a query from ctx.groundItems.query().
  • Method Details

    • withName

      public GroundItemQuery withName(String... names)
      Keeps stacks whose item name contains any of names (case-insensitive substring). A stack whose name cannot be resolved reads as "item:<id>" and matches nothing.
    • withId

      public GroundItemQuery withId(int... ids)
      Keeps stacks whose item id is one of ids; no ids leaves the query unchanged.
    • withinTiles

      public GroundItemQuery withinTiles(int maxTiles)
      Chebyshev distance on the current plane (OSRS tile steps).
    • filter

      public GroundItemQuery filter(Predicate<PrivGroundItem> pred)
      Narrows this query in place and returns it. Queries are mutable and single-use; the predicate runs on the calling thread.
    • where

    • closest

      public PrivGroundItem closest()
      The stack nearest the local player in tile steps; stacks on another plane rank last. When the player's position cannot be read this returns the first entry; null when empty.
    • closest

      public PrivGroundItem closest(Predicate<PrivGroundItem> pred)
      Filter then nearest to the player (Scar / DreamBot GroundItems.closest(pred) style).
    • nearest

      public PrivGroundItem nearest()
      Alias of closest().
    • nearest

      public PrivGroundItem nearest(Predicate<PrivGroundItem> pred)
    • first

      public PrivGroundItem first()
      The first remaining entry in snapshot order, or null when the query is empty.
    • list

      public List<PrivGroundItem> list()
      An unmodifiable view of the remaining entries.
    • empty

      public boolean empty()
      True when no entry is left.
    • size

      public int size()
      The number of entries left.