Class PlayerQuery


  • public class PlayerQuery
    extends Query<KSPlayer,​PlayerQuery>
    A specialized query class for filtering and retrieving player entities in the game. Extends the generic Query class and integrates contextual game utilities.
    • 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.