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 for advanced player filtering.
-
-
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 based on tile distance.KSPlayer
furthest()
Retrieves the player furthest to the local player based on tile distance.PlayerQuery
hasOverheadPrayer()
Filters players who have an overhead prayer active (e.g., Protect from Melee).PlayerQuery
interactingWith(net.runelite.api.Actor actor)
Filters players who are interacting with a specified actor.PlayerQuery
interactingWithLocal()
Filters players who are interacting with the local player.PlayerQuery
isSkulled()
Filters players that currently have a skull icon (indicating PvP engagement).PlayerQuery
notLocalPlayer()
Excludes the local player from the query results.PlayerQuery
onTeam(int teamId)
Filters players based on team ID.PlayerQuery
sortByDistance(boolean closest)
Sorts players by their distance from the local player.PlayerQuery
wearingAll(int... itemIds)
Filters players wearing all the specified item IDs.PlayerQuery
wearingAll(java.lang.String... names)
Filters players wearing all specified item names (case-insensitive, exact match).PlayerQuery
wearingAny(int... itemIds)
Filters players wearing at least one item from the specified IDs.PlayerQuery
wearingAny(java.lang.String... names)
Filters players wearing at least one item from the given names (case-insensitive, exact match).PlayerQuery
wearingItem(int itemId)
Filters players wearing a specific item by its ID.PlayerQuery
wearingItem(java.lang.String partialName)
Filters players wearing any item whose name contains the given text (case-insensitive).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, reverse, 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 specified actor.- Parameters:
actor
- the actor to match interactions with.- Returns:
- the current PlayerQuery instance containing only players interacting with the specified actor.
-
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 allowed distance.- Returns:
- the current PlayerQuery instance with only nearby players.
-
sortByDistance
public PlayerQuery sortByDistance(boolean closest)
Sorts players by their distance from the local player.- Parameters:
closest
- if true, sorts from closest to farthest; if false, sorts from farthest to closest.- Returns:
- the current PlayerQuery instance with sorted players.
-
isSkulled
public PlayerQuery isSkulled()
Filters players that currently have a skull icon (indicating PvP engagement).- Returns:
- PlayerQuery with only skulled players.
-
hasOverheadPrayer
public PlayerQuery hasOverheadPrayer()
Filters players who have an overhead prayer active (e.g., Protect from Melee).- Returns:
- PlayerQuery with players using prayers.
-
onTeam
public PlayerQuery onTeam(int teamId)
Filters players based on team ID. Useful in minigames like Castle Wars.- Parameters:
teamId
- the team ID to match.- Returns:
- PlayerQuery with players on the specified team.
-
closest
public KSPlayer closest()
Retrieves the player closest to the local player based on tile distance.- Returns:
- the closest KSPlayer instance or null if no players are found.
-
furthest
public KSPlayer furthest()
Retrieves the player furthest to the local player based on tile distance.- Returns:
- the furthest KSPlayer instance or null if no players are found.
-
wearingItem
public PlayerQuery wearingItem(java.lang.String partialName)
Filters players wearing any item whose name contains the given text (case-insensitive).- Parameters:
partialName
- Partial name to search for in equipment- Returns:
- PlayerQuery with players wearing at least one matching item
-
wearingItem
public PlayerQuery wearingItem(int itemId)
Filters players wearing a specific item by its ID.- Parameters:
itemId
- ID of the item (not +512)- Returns:
- PlayerQuery with players wearing the item
-
wearingAll
public PlayerQuery wearingAll(int... itemIds)
Filters players wearing all the specified item IDs.- Parameters:
itemIds
- Required item IDs (not +512)- Returns:
- PlayerQuery with players wearing all specified items
-
wearingAll
public PlayerQuery wearingAll(java.lang.String... names)
Filters players wearing all specified item names (case-insensitive, exact match).- Parameters:
names
- Names of required items- Returns:
- PlayerQuery with players wearing all specified item names
-
wearingAny
public PlayerQuery wearingAny(int... itemIds)
Filters players wearing at least one item from the specified IDs.- Parameters:
itemIds
- Array of possible item IDs (not +512)- Returns:
- PlayerQuery with players wearing at least one matching item
-
wearingAny
public PlayerQuery wearingAny(java.lang.String... names)
Filters players wearing at least one item from the given names (case-insensitive, exact match).- Parameters:
names
- Item names to check for- Returns:
- PlayerQuery with players wearing any one of the specified item names
-
-