Class PlayerQuery

All Implemented Interfaces:
Predicate<IPlayer>

public class PlayerQuery extends ActorQuery<IPlayer,PlayerQuery>
Query class for finding and filtering players in the game world.

This class extends ActorQuery with player-specific filtering capabilities, primarily the ability to filter by player ID (pid). Players can be filtered by all criteria available in the parent classes including:

  • Player IDs (pids)
  • Combat levels, animations, targets (from ActorQuery)
  • IDs, names, actions, locations, distances (from SceneEntityQuery)

Example usage:


 // Find all players within 5 tiles who are not moving
 PlayerQuery query = new PlayerQuery(playerSupplier)
     .distance(localPlayer, 5)
     .moving(false);
 SceneEntityQueryResults<IPlayer> results = query.results();
 
  • Constructor Details

    • PlayerQuery

      public PlayerQuery(Supplier<List<IPlayer>> supplier)
      Constructs a new player query with the specified player supplier.
      Parameters:
      supplier - a supplier that provides the list of players to query
  • Method Details

    • playerIds

      public PlayerQuery playerIds(int... pids)
      Filters players by their player IDs.

      Only players with a player ID matching one of the specified values will be included. The player ID is a unique identifier for a player within the current game scene.

      Parameters:
      pids - the player IDs to filter by
      Returns:
      this query instance for method chaining
    • results

      protected SceneEntityQueryResults<IPlayer> results(List<IPlayer> list)
      Wraps the filtered list of players in a SceneEntityQueryResults container.
      Specified by:
      results in class Query<IPlayer,PlayerQuery,SceneEntityQueryResults<IPlayer>>
      Parameters:
      list - the list of players that passed all filters
      Returns:
      the results wrapped in a SceneEntityQueryResults container
    • test

      public boolean test(IPlayer player)
      Tests whether a player passes all accumulated filter criteria.

      This method checks the player against the player ID filter and all parent class filters.

      Specified by:
      test in interface Predicate<IPlayer>
      Overrides:
      test in class ActorQuery<IPlayer,PlayerQuery>
      Parameters:
      player - the player to test
      Returns:
      true if the player passes all filters, false otherwise