Class ComponentQuery
java.lang.Object
com.botwithus.bot.api.component.ComponentQuery
Fluent, RPC-backed query over an interface subtree. Modeled on
WorldMapElements.Query: the first terminal materializes the subtree
in a single get_interface_tree round-trip, then all filters run
client-side over the flattened node list. The fetched tree is cached, so
chaining several terminals on one query costs one RPC.
ComponentNode coins = api.components().in(Interfaces.BACKPACK)
.withType(ComponentType.MODEL)
.withItemId(995)
.first();
-
Method Summary
Modifier and TypeMethodDescriptionall()All matching nodes, in breadth-first tree order.containingText(String needle) Filter by label substring (case-insensitive).intcount()booleanexists()filter(Predicate<ComponentNode> predicate) Adds a predicate; multiple calls AND together.First matching node as anOptional.first()First matching node in tree order, ornull.hidden()Keep only components the producer reported hidden.limit(int max) Cap the number of results.ofType(ComponentType... types) Filter to any of the given categories.results()Alias forall().root()Root of the materialized subtree, ornullwhen it didn't resolve.stream()Stream over the materialized result list (filter + limit already applied).textMatching(String regex) Filter by label regex (full match against the label).tree()The materialized subtree (one fetch, cached for this query).visible()Keep only visible components (treats unsupported-hidden as visible).withGameval(String... gamevals) Filter by gameval symbolic name, e.g.withId(int componentId) Filter by component id within the interface.withItemId(int itemId) Filter by displayed item id (ModelComponent).withSpriteId(int spriteId) Filter by primary sprite id.Filter by exact label text (case-insensitive).withType(ComponentType type) Filter to a single semantic category.
-
Method Details
-
filter
Adds a predicate; multiple calls AND together. -
withId
Filter by component id within the interface. -
withGameval
Filter by gameval symbolic name, e.g."BANK__BANK_INV_BUTTON". Pass several to match any of them.Matches on the whole
(interfaceId, componentId)pair a gameval encodes, not just the component half — a materialized tree is cross-mount aware and can carry nodes from more than one interface, so matching the component id alone would collide across mounts.Names are resolved once when the filter is added. A name that does not resolve narrows the query to nothing and logs a warning — a stale name must not silently widen the result set.
ComponentNode inv = api.components().in("BANK") .withGameval("BANK__BANK_INV_BUTTON") .visible() .first(); -
withType
Filter to a single semantic category. -
ofType
Filter to any of the given categories. -
withText
Filter by exact label text (case-insensitive). -
containingText
Filter by label substring (case-insensitive). -
textMatching
Filter by label regex (full match against the label). -
withSpriteId
Filter by primary sprite id. -
withItemId
Filter by displayed item id (ModelComponent). -
visible
Keep only visible components (treats unsupported-hidden as visible). -
limit
Cap the number of results. -
all
All matching nodes, in breadth-first tree order. -
results
Alias forall(). -
first
First matching node in tree order, ornull. -
findFirst
First matching node as anOptional. -
count
public int count() -
exists
public boolean exists() -
stream
Stream over the materialized result list (filter + limit already applied). -
tree
The materialized subtree (one fetch, cached for this query). -
root
Root of the materialized subtree, ornullwhen it didn't resolve.
-