AbstractActorQuery
Distance filters and the nearest match, for searches over NPCs.
Abstract classRLPlugins API
public abstract class AbstractActorQuery<T extends ActorEx<?>, Q extends AbstractActorQuery<T, Q>> extends AbstractQuery<T, Q>Extended by NpcQuery, PlayerQuery
You use these through NpcQuery. T is the result type, NpcEx for an NPC search, and Q is the query type.
Members
Constructors
- newAbstractActorQuery(List<T>)
Creates a AbstractActorQuery.
Methods
- QatLocation(WorldPoint)
Filter by exact location.
- QcanAttack()
Filter to npcs the player can attack.
- Tfarthest()
Get the farthest Actor from the filtered list Terminal operation - executes the query.
- Tfarthest(WorldPoint)
Get the farthest Actor from a specific point Terminal operation - executes the query.
- Qfree()
Filter actors that are already interacting.
- QhasLos()
Filter actors that the player has line of sight to.
- QinteractingWith(ActorEx<?>)
Filter actors that are currently interacting with a specific target actor.
- QisReachable()
Filter reachable actors.
- TlongestPath()
Get the Actor with the furthest path from the filtered list Terminal operation - executes the query.
- Tnearest()
The match closest to you.
- Tnearest(WorldPoint)
The match closest to a point.
- TshortestPath()
Get the Actor with the shortest path from the filtered list Terminal operation - executes the query.
- QsortFurthest()
Sort by furthest from the player.
- QsortFurthest(WorldPoint)
Sort by furthest from a specific point.
- QsortLongestPath()
Sort by furthest path from the player.
- QsortLongestPath(WorldPoint)
Sort by furthest path from a specific point.
- QsortNearest()
Sort by nearest to the player.
- QsortNearest(WorldPoint)
Sort by nearest to a specific point.
- QsortShortestPath()
Sort by shortest path from the player.
- QsortShortestPath(WorldPoint)
Sort by shortest path from a specific point.
- Qwithin(int)
Keeps matches within this many tiles of you.
- Qwithin(WorldPoint, int)
Keeps matches within this many tiles of a point.
- QwithName(String)
Filter by name.
- QwithNameContains(String)
Filter by name.
Inherited from AbstractQuery
- Raggregate(Function<Stream<T>, R>)
Generic aggregation method for custom terminal operations Executes filters and allows custom stream processing.
- booleanall(Predicate<T>)
Check if all filtered results match the predicate.
- booleanany(Predicate<T>)
Check if any filtered result matches the predicate.
- List<T>collect()
Get the filtered/sorted list.
- Rcollect(Collector<T, ?, R>)
Execute filters and process with custom collector.
- intcount()
How many results match.
- Qdistinct()
Ensure results are distinct.
- Tfirst()
The first match.
- voidfirstIfPresent(Consumer<T>)
First if present.
- voidfirstOrElse(Consumer<T>, Runnable)
Perform action on the first element, or else run elseAction if no results.
- voidforEach(Consumer<T>)
Executes filters and performs an action on each result.
- booleanisEmpty()
Whether nothing matches.
- QkeepIf(Predicate<T>)
Lazily filter by predicate (keeps matching items).
- Tlast()
Get the last element from the filtered/sorted list.
- voidlastOrElse(Consumer<T>, Runnable)
Perform action on the last element, or else run elseAction if no results.
- Qlimit(int)
Limit the number of results.
- booleannone(Predicate<T>)
Check if no filtered results match the predicate.
- Qpeek(Consumer<T>)
Peek at each element during processing.
- QpostProcess(Function<List<T>, List<T>>)
Apply a post-processing function after sorting.
- Trandom()
Get a random element from the filtered/sorted list.
- QremoveIf(Predicate<T>)
Lazily filter by predicate (removes matching items).
- Qskip(int)
Skip a number of results.
- Qsort(Comparator<T>)
Lazily add sorting.
AbstractActorQuery(List<T>)
public AbstractActorQuery(List<T> cache)Creates a AbstractActorQuery.
Parameters
cache- Cache.
atLocation(WorldPoint)
public Q atLocation(WorldPoint location)Filter by exact location.
Parameters
location- Location.
Returns
ActorQuery.
canAttack()
public Q canAttack()Filter to npcs the player can attack.
Returns
ActorQuery.
farthest()
public T farthest()Get the farthest Actor from the filtered list Terminal operation - executes the query.
farthest(WorldPoint)
public T farthest(WorldPoint center)Get the farthest Actor from a specific point Terminal operation - executes the query.
Parameters
center- Center.
free()
public Q free()Filter actors that are already interacting.
Returns
ActorQuery.
hasLos()
public Q hasLos()Filter actors that the player has line of sight to.
Returns
ActorQuery.
interactingWith(ActorEx<?>)
public Q interactingWith(ActorEx<?> target)Filter actors that are currently interacting with a specific target actor.
Parameters
target- Actor.
Returns
ActorQuery.
isReachable()
public Q isReachable()Filter reachable actors.
Returns
ActorQuery.
longestPath()
public T longestPath()Get the Actor with the furthest path from the filtered list Terminal operation - executes the query.
nearest()
public T nearest()The match closest to you.
Measures the straight line on the map, ignoring planes.
Returns
The nearest match, or null when nothing matches.
- Call it while you are logged in.
nearest(WorldPoint)
public T nearest(WorldPoint center)The match closest to a point.
Measures the straight line on the map, ignoring planes.
Parameters
center- The point to measure from.
Returns
The nearest match, or null when nothing matches.
shortestPath()
public T shortestPath()Get the Actor with the shortest path from the filtered list Terminal operation - executes the query.
sortFurthest()
public Q sortFurthest()Sort by furthest from the player.
Returns
ActorQuery.
sortFurthest(WorldPoint)
public Q sortFurthest(WorldPoint center)Sort by furthest from a specific point.
Parameters
center- Center point.
Returns
ActorQuery.
sortLongestPath()
public Q sortLongestPath()Sort by furthest path from the player.
Returns
ActorQuery.
sortLongestPath(WorldPoint)
public Q sortLongestPath(WorldPoint center)Sort by furthest path from a specific point.
Parameters
center- Center point.
Returns
ActorQuery.
sortNearest()
public Q sortNearest()Sort by nearest to the player.
Returns
ActorQuery.
sortNearest(WorldPoint)
public Q sortNearest(WorldPoint center)Sort by nearest to a specific point.
Parameters
center- Center point.
Returns
ActorQuery.
sortShortestPath()
public Q sortShortestPath()Sort by shortest path from the player.
Returns
ActorQuery.
sortShortestPath(WorldPoint)
public Q sortShortestPath(WorldPoint center)Sort by shortest path from a specific point.
Parameters
center- Center point.
Returns
ActorQuery.
within(int)
public Q within(int distance)Keeps matches within this many tiles of you.
Counts tiles in a square around you, so a diagonal step is one tile.
Parameters
distance- The largest distance in tiles.
Returns
This query.
- Call it while you are logged in.
within(WorldPoint, int)
public Q within(WorldPoint center, int distance)Keeps matches within this many tiles of a point.
Counts tiles in a square around the point, so a diagonal step is one tile.
Parameters
center- The point to measure from.
distance- The largest distance in tiles.
Returns
This query.
withName(String)
public Q withName(String name)Filter by name.
Parameters
name- Actor name.
Returns
ActorQuery.
withNameContains(String)
public Q withNameContains(String name)Filter by name.
Parameters
name- Actor name.
Returns
ActorQuery.
aggregate(Function<Stream<T>, R>)from AbstractQuery
public R aggregate(Function<Stream<T>, R> aggregator)Generic aggregation method for custom terminal operations Executes filters and allows custom stream processing.
Parameters
aggregator- Aggregator.
all(Predicate<T>)from AbstractQuery
public boolean all(Predicate<T> predicate)Check if all filtered results match the predicate.
Parameters
predicate- Predicate to test.
Returns
True if all match, false otherwise.
any(Predicate<T>)from AbstractQuery
public boolean any(Predicate<T> 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<T> collect()Get the filtered/sorted list.
collect(Collector<T, ?, R>)from AbstractQuery
public R collect(Collector<T, ?, R> collector)Execute filters and process with custom collector.
Parameters
collector- Collector.
count()from AbstractQuery
public int count()How many results match.
Returns
The number of matches.
distinct()from AbstractQuery
public Q distinct()Ensure results are distinct.
Returns
The query instance.
first()from AbstractQuery
public T first()The first match.
The order is the game's own. Use AbstractActorQuery.nearest() for the closest one.
Returns
The first match, or null when nothing matches.
firstIfPresent(Consumer<T>)from AbstractQuery
public void firstIfPresent(Consumer<T> action)First if present.
Parameters
action- Action.
firstOrElse(Consumer<T>, Runnable)from AbstractQuery
public void firstOrElse(Consumer<T> 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<T>)from AbstractQuery
public void forEach(Consumer<T> action)Executes filters and performs an action on each result.
Parameters
action- Action.
isEmpty()from AbstractQuery
public boolean isEmpty()Whether nothing matches.
Returns
true when there are no matches.
keepIf(Predicate<T>)from AbstractQuery
public Q keepIf(Predicate<T> predicate)Lazily filter by predicate (keeps matching items).
Parameters
predicate- Predicate.
Returns
The query instance.
last()from AbstractQuery
public T last()Get the last element from the filtered/sorted list.
lastOrElse(Consumer<T>, Runnable)from AbstractQuery
public void lastOrElse(Consumer<T> 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 Q limit(int maxSize)Limit the number of results.
Parameters
maxSize- Max size.
Returns
The query instance.
none(Predicate<T>)from AbstractQuery
public boolean none(Predicate<T> predicate)Check if no filtered results match the predicate.
Parameters
predicate- Predicate to test.
Returns
True if none match, false otherwise.
peek(Consumer<T>)from AbstractQuery
public Q peek(Consumer<T> action)Peek at each element during processing.
Parameters
action- Action to perform on each element.
Returns
The query instance.
postProcess(Function<List<T>, List<T>>)from AbstractQuery
public Q postProcess(Function<List<T>, List<T>> 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 T random()Get a random element from the filtered/sorted list.
removeIf(Predicate<T>)from AbstractQuery
public Q removeIf(Predicate<T> predicate)Lazily filter by predicate (removes matching items).
Parameters
predicate- Predicate.
Returns
The query instance.
skip(int)from AbstractQuery
public Q skip(int count)Skip a number of results.
Parameters
count- Count.
Returns
The query instance.
sort(Comparator<T>)from AbstractQuery
public Q sort(Comparator<T> comparator)Lazily add sorting.
Parameters
comparator- Comparator.
Returns
The query instance.
Also allowed
Every class has these, as in plain Java.
equals, toString