Package rs.kreme.ksbot.api.queries
Class PlayerQuery
- java.lang.Object
-
- rs.kreme.ksbot.api.queries.Query<KSPlayer,PlayerQuery>
-
- rs.kreme.ksbot.api.queries.PlayerQuery
-
public class PlayerQuery extends Query<KSPlayer,PlayerQuery>
A specialized query class for filtering and retrieving player entities in the game. Extends the genericQuery
class and integrates contextual game utilities.
-
-
Constructor Summary
Constructors Constructor Description PlayerQuery(java.util.Collection<KSPlayer> players)
Constructs a new PlayerQuery instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PlayerQuery
alive()
Filters players who are alive (not dead).KSPlayer
closest()
Retrieves the player closest to the local player.PlayerQuery
interactingWith(net.runelite.api.Actor actor)
Filters players who are interacting with a specific actor.PlayerQuery
interactingWithLocal()
Filters players who are interacting with the local player.PlayerQuery
notLocalPlayer()
Excludes the local player from the query results.PlayerQuery
sortByDistance(boolean closest)
Sorts players by their distance from the local player.PlayerQuery
withinDistance(int distance)
Filters players within a specific distance from the local player.PlayerQuery
withinLevel(int low, int high)
Filters players whose combat level is within a specified range (inclusive).-
Methods inherited from class rs.kreme.ksbot.api.queries.Query
count, empty, exists, filter, first, first, last, list, list, max, min, omit, omit, omit, random, shuffledList, shuffledList, sorted, stream, unique, withId, withName, withNameOrId, withOption, withoutId, withoutName, withoutNameOrId, withoutOption
-
-
-
-
Constructor Detail
-
PlayerQuery
public PlayerQuery(java.util.Collection<KSPlayer> players)
Constructs a new PlayerQuery instance.- Parameters:
players
- the collection of players to query.
-
-
Method Detail
-
alive
public PlayerQuery alive()
Filters players who are alive (not dead).- Returns:
- the current PlayerQuery instance with only alive players.
-
interactingWithLocal
public PlayerQuery interactingWithLocal()
Filters players who are interacting with the local player.- Returns:
- the current PlayerQuery instance with players interacting with the local player.
-
interactingWith
public PlayerQuery interactingWith(net.runelite.api.Actor actor)
Filters players who are interacting with a specific actor.- Parameters:
actor
- the actor to check for interactions.- Returns:
- the current PlayerQuery instance with filtered players.
-
notLocalPlayer
public PlayerQuery notLocalPlayer()
Excludes the local player from the query results.- Returns:
- the current PlayerQuery instance excluding the local player.
-
withinLevel
public PlayerQuery withinLevel(int low, int high)
Filters players whose combat level is within a specified range (inclusive).- Parameters:
low
- the minimum combat level.high
- the maximum combat level.- Returns:
- the current PlayerQuery instance with players within the combat level range.
-
withinDistance
public PlayerQuery withinDistance(int distance)
Filters players within a specific distance from the local player.- Parameters:
distance
- the maximum distance to include players.- Returns:
- the current PlayerQuery instance with players within the specified distance.
-
sortByDistance
public PlayerQuery sortByDistance(boolean closest)
Sorts players by their distance from the local player.- Parameters:
closest
- true to sort by closest players, false for farthest players first.- Returns:
- the current PlayerQuery instance with sorted players.
-
closest
public KSPlayer closest()
Retrieves the player closest to the local player.- Returns:
- the closest KSPlayer, or null if no players are found.
-
-