WidgetQuery
A query class to filter and find widgets in the game client.
ClassRLPlugins API
public class WidgetQuery extends AbstractQuery<Widget, WidgetQuery>Members
Constructors
- newWidgetQuery()
Initializes the query with all widgets from the client.
- newWidgetQuery(HashSet<Widget>)
Initializes the query with a provided set of widgets.
- newWidgetQuery(List<Widget>)
Initializes the query with a provided collection of widgets.
- newWidgetQuery(Widget...)
Creates a WidgetQuery.
- newWidgetQuery(int...)
Creates a WidgetQuery.
Methods
- WidgetQueryisHidden()
Filters widgets that are hidden.
- WidgetQueryisSelfHidden()
Filters widgets that are self-hidden.
- WidgetQueryisSelfVisible()
Filters widgets that are self-visible (not self-hidden).
- WidgetQueryisVisible()
Filters widgets that are visible (not hidden).
- WidgetQuerywithActions(String...)
Filters widgets by their actions, ignoring case.
- WidgetQuerywithChildren()
Filters widgets that have children.
- WidgetQuerywithId(int...)
Filters widgets by their IDs.
- WidgetQuerywithItemId(int...)
Filters widgets by their item IDs.
- WidgetQuerywithModelId(int...)
Filters widgets by their model IDs.
- WidgetQuerywithName(String)
With name.
- WidgetQuerywithNoChildren()
Filters widgets that do not have children.
- WidgetQuerywithParentId(int...)
Filters widgets by their parent IDs.
- WidgetQuerywithQuantity(int)
Filters widgets by their item quantities, keeping those with quantities equal to the specified value.
- WidgetQuerywithQuantityGreaterThan(int)
Filters widgets by their item quantities, keeping those with quantities greater than the specified value.
- WidgetQuerywithQuantityLessThan(int)
Filters widgets by their item quantities, keeping those with quantities less than the specified value.
- WidgetQuerywithText(String)
Filters widgets by their text, ignoring case.
- WidgetQuerywithTextContains(String...)
Filters widgets that contain any of the specified texts, ignoring case.
- WidgetQuerywithType(int...)
Filters widgets by their types.
- WidgetQuerywithWidget(Widget...)
Filters widgets by exact reference match.
Inherited from AbstractQuery
- Raggregate(Function<Stream<Widget>, R>)
Generic aggregation method for custom terminal operations Executes filters and allows custom stream processing.
- booleanall(Predicate<Widget>)
Check if all filtered results match the predicate.
- booleanany(Predicate<Widget>)
Check if any filtered result matches the predicate.
- List<Widget>collect()
Get the filtered/sorted list.
- Rcollect(Collector<Widget, ?, R>)
Execute filters and process with custom collector.
- intcount()
Get count of filtered results.
- WidgetQuerydistinct()
Ensure results are distinct.
- Widgetfirst()
Get the first element from the filtered/sorted list.
- voidfirstIfPresent(Consumer<Widget>)
First if present.
- voidfirstOrElse(Consumer<Widget>, Runnable)
Perform action on the first element, or else run elseAction if no results.
- voidforEach(Consumer<Widget>)
Executes filters and performs an action on each result.
- booleanisEmpty()
Check if there are no filtered results.
- WidgetQuerykeepIf(Predicate<Widget>)
Lazily filter by predicate (keeps matching items).
- Widgetlast()
Get the last element from the filtered/sorted list.
- voidlastOrElse(Consumer<Widget>, Runnable)
Perform action on the last element, or else run elseAction if no results.
- WidgetQuerylimit(int)
Limit the number of results.
- booleannone(Predicate<Widget>)
Check if no filtered results match the predicate.
- WidgetQuerypeek(Consumer<Widget>)
Peek at each element during processing.
- WidgetQuerypostProcess(Function<List<Widget>, List<Widget>>)
Apply a post-processing function after sorting.
- Widgetrandom()
Get a random element from the filtered/sorted list.
- WidgetQueryremoveIf(Predicate<Widget>)
Lazily filter by predicate (removes matching items).
- WidgetQueryskip(int)
Skip a number of results.
- WidgetQuerysort(Comparator<Widget>)
Lazily add sorting.
WidgetQuery()
public WidgetQuery()Initializes the query with all widgets from the client.
WidgetQuery(HashSet<Widget>)
public WidgetQuery(HashSet<Widget> cache)Initializes the query with a provided set of widgets.
Parameters
cache- A set of widgets to initialize the query with.
WidgetQuery(List<Widget>)
public WidgetQuery(List<Widget> cache)Initializes the query with a provided collection of widgets.
Parameters
cache- A collection of widgets to initialize the query with.
WidgetQuery(Widget...)
public WidgetQuery(Widget... roots)Creates a WidgetQuery.
Parameters
roots- Roots.
WidgetQuery(int...)
public WidgetQuery(int... roots)Creates a WidgetQuery.
Parameters
roots- Roots.
isHidden()
public WidgetQuery isHidden()Filters widgets that are hidden.
Returns
WidgetQuery.
isSelfHidden()
public WidgetQuery isSelfHidden()Filters widgets that are self-hidden.
Returns
WidgetQuery.
isSelfVisible()
public WidgetQuery isSelfVisible()Filters widgets that are self-visible (not self-hidden).
Returns
WidgetQuery.
isVisible()
public WidgetQuery isVisible()Filters widgets that are visible (not hidden).
Returns
WidgetQuery.
withActions(String...)
public WidgetQuery withActions(String... actions)Filters widgets by their actions, ignoring case.
Parameters
actions- One or more actions to filter by.
Returns
WidgetQuery.
withChildren()
public WidgetQuery withChildren()Filters widgets that have children.
Returns
WidgetQuery.
withId(int...)
public WidgetQuery withId(int... id)Filters widgets by their IDs.
Parameters
id- One or more widget IDs to filter by.
Returns
WidgetQuery.
withItemId(int...)
public WidgetQuery withItemId(int... itemId)Filters widgets by their item IDs.
Parameters
itemId- One or more item IDs to filter by.
Returns
WidgetQuery.
withModelId(int...)
public WidgetQuery withModelId(int... modelIds)Filters widgets by their model IDs.
Parameters
modelIds- One or more model IDs to filter by.
Returns
WidgetQuery.
withName(String)
public WidgetQuery withName(String name)With name.
Parameters
name- Name.
withNoChildren()
public WidgetQuery withNoChildren()Filters widgets that do not have children.
Returns
WidgetQuery.
withParentId(int...)
public WidgetQuery withParentId(int... itemId)Filters widgets by their parent IDs.
Parameters
itemId- One or more parent IDs to filter by.
Returns
WidgetQuery.
withQuantity(int)
public WidgetQuery withQuantity(int quantity)Filters widgets by their item quantities, keeping those with quantities equal to the specified value.
Parameters
quantity- The exact item quantity to filter by.
Returns
WidgetQuery.
withQuantityGreaterThan(int)
public WidgetQuery withQuantityGreaterThan(int quantity)Filters widgets by their item quantities, keeping those with quantities greater than the specified value.
Parameters
quantity- The minimum item quantity (exclusive).
Returns
WidgetQuery.
withQuantityLessThan(int)
public WidgetQuery withQuantityLessThan(int quantity)Filters widgets by their item quantities, keeping those with quantities less than the specified value.
Parameters
quantity- The maximum item quantity (exclusive).
Returns
WidgetQuery.
withText(String)
public WidgetQuery withText(String text)Filters widgets by their text, ignoring case.
Parameters
text- The text to filter by.
Returns
WidgetQuery.
withTextContains(String...)
public WidgetQuery withTextContains(String... texts)Filters widgets that contain any of the specified texts, ignoring case.
Parameters
texts- One or more texts to check for containment.
Returns
WidgetQuery.
withType(int...)
public WidgetQuery withType(int... types)Filters widgets by their types.
Parameters
types- One or more widget types to filter by.
Returns
WidgetQuery.
withWidget(Widget...)
public WidgetQuery withWidget(Widget... widgets)Filters widgets by exact reference match.
Parameters
widgets- One or more widget references to filter by.
Returns
WidgetQuery.
aggregate(Function<Stream<Widget>, R>)from AbstractQuery
public R aggregate(Function<Stream<Widget>, R> aggregator)Generic aggregation method for custom terminal operations Executes filters and allows custom stream processing.
Parameters
aggregator- Aggregator.
all(Predicate<Widget>)from AbstractQuery
public boolean all(Predicate<Widget> predicate)Check if all filtered results match the predicate.
Parameters
predicate- Predicate to test.
Returns
True if all match, false otherwise.
any(Predicate<Widget>)from AbstractQuery
public boolean any(Predicate<Widget> predicate)Check if any filtered result matches the predicate.
Parameters
predicate- Predicate to test.
Returns
True if any match, false otherwise.
collect()from AbstractQuery
public List<Widget> collect()Get the filtered/sorted list.
collect(Collector<Widget, ?, R>)from AbstractQuery
public R collect(Collector<Widget, ?, R> collector)Execute filters and process with custom collector.
Parameters
collector- Collector.
count()from AbstractQuery
public int count()Get count of filtered results.
distinct()from AbstractQuery
public WidgetQuery distinct()Ensure results are distinct.
Returns
The query instance.
first()from AbstractQuery
public Widget first()Get the first element from the filtered/sorted list.
firstIfPresent(Consumer<Widget>)from AbstractQuery
public void firstIfPresent(Consumer<Widget> action)First if present.
Parameters
action- Action.
firstOrElse(Consumer<Widget>, Runnable)from AbstractQuery
public void firstOrElse(Consumer<Widget> action, Runnable elseAction)Perform action on the first element, or else run elseAction if no results.
Parameters
action- Action to perform on the first element.
elseAction- Action to perform if no results.
forEach(Consumer<Widget>)from AbstractQuery
public void forEach(Consumer<Widget> action)Executes filters and performs an action on each result.
Parameters
action- Action.
isEmpty()from AbstractQuery
public boolean isEmpty()Check if there are no filtered results.
Returns
True if no results after filtering, false otherwise.
keepIf(Predicate<Widget>)from AbstractQuery
public WidgetQuery keepIf(Predicate<Widget> predicate)Lazily filter by predicate (keeps matching items).
Parameters
predicate- Predicate.
Returns
The query instance.
last()from AbstractQuery
public Widget last()Get the last element from the filtered/sorted list.
lastOrElse(Consumer<Widget>, Runnable)from AbstractQuery
public void lastOrElse(Consumer<Widget> action, Runnable elseAction)Perform action on the last element, or else run elseAction if no results.
Parameters
action- Action to perform on the last element.
elseAction- Action to perform if no results.
limit(int)from AbstractQuery
public WidgetQuery limit(int maxSize)Limit the number of results.
Parameters
maxSize- Max size.
Returns
The query instance.
none(Predicate<Widget>)from AbstractQuery
public boolean none(Predicate<Widget> predicate)Check if no filtered results match the predicate.
Parameters
predicate- Predicate to test.
Returns
True if none match, false otherwise.
peek(Consumer<Widget>)from AbstractQuery
public WidgetQuery peek(Consumer<Widget> action)Peek at each element during processing.
Parameters
action- Action to perform on each element.
Returns
The query instance.
postProcess(Function<List<Widget>, List<Widget>>)from AbstractQuery
public WidgetQuery postProcess(Function<List<Widget>, List<Widget>> processor)Apply a post-processing function after sorting.
Useful for reordering algorithms that can't be expressed as Comparators.
Parameters
processor- Function to transform the result list.
Returns
The query instance.
random()from AbstractQuery
public Widget random()Get a random element from the filtered/sorted list.
removeIf(Predicate<Widget>)from AbstractQuery
public WidgetQuery removeIf(Predicate<Widget> predicate)Lazily filter by predicate (removes matching items).
Parameters
predicate- Predicate.
Returns
The query instance.
skip(int)from AbstractQuery
public WidgetQuery skip(int count)Skip a number of results.
Parameters
count- Count.
Returns
The query instance.
sort(Comparator<Widget>)from AbstractQuery
public WidgetQuery sort(Comparator<Widget> comparator)Lazily add sorting.
Parameters
comparator- Comparator.
Returns
The query instance.
Also allowed
Every class has these, as in plain Java.
equals, toString