Package net.storm.api.query.entities
Class PlayerQuery
java.lang.Object
net.storm.api.query.Query<IPlayer,PlayerQuery,SceneEntityQueryResults<IPlayer>>
net.storm.api.query.entities.SceneEntityQuery<IPlayer,PlayerQuery>
net.storm.api.query.entities.ActorQuery<IPlayer,PlayerQuery>
net.storm.api.query.entities.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();
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionPlayerQuery(Supplier<List<IPlayer>> supplier) Constructs a new player query with the specified player supplier. -
Method Summary
Modifier and TypeMethodDescriptionplayerIds(int... pids) Filters players by their player IDs.protected SceneEntityQueryResults<IPlayer> Wraps the filtered list of players in a SceneEntityQueryResults container.booleanTests whether a player passes all accumulated filter criteria.Methods inherited from class net.storm.api.query.entities.ActorQuery
animations, dead, levels, moving, targeting, targetlessMethods inherited from class net.storm.api.query.entities.SceneEntityQuery
actionContains, actions, distance, distance, distance, ids, localLocations, locations, nameContains, names, within, worldView
-
Constructor Details
-
PlayerQuery
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
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
Wraps the filtered list of players in a SceneEntityQueryResults container.- Specified by:
resultsin classQuery<IPlayer,PlayerQuery, SceneEntityQueryResults<IPlayer>> - Parameters:
list- the list of players that passed all filters- Returns:
- the results wrapped in a SceneEntityQueryResults container
-
test
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:
testin interfacePredicate<IPlayer>- Overrides:
testin classActorQuery<IPlayer,PlayerQuery> - Parameters:
player- the player to test- Returns:
trueif the player passes all filters,falseotherwise
-