use of org.spongepowered.api.scoreboard.TeamMember in project LanternServer by LanternPowered.
the class SelectorResolver method addTeamFilters.
private void addTeamFilters(List<Predicate<Entity>> filters) {
Selector sel = this.selector;
Optional<Invertible<String>> teamOpt = sel.getArgument(ArgumentTypes.TEAM);
if (teamOpt.isPresent()) {
Invertible<String> teamArg = teamOpt.get();
final boolean inverted = teamArg.isInverted();
final Collection<Team> teams = Sponge.getGame().getServer().getServerScoreboard().get().getTeams();
filters.add(new Predicate<Entity>() {
@Override
public boolean test(Entity input) {
if (input instanceof TeamMember) {
return inverted ^ collectMembers(teams).contains(((TeamMember) input).getTeamRepresentation());
}
return false;
}
private Collection<Text> collectMembers(Collection<Team> teams) {
ImmutableSet.Builder<Text> users = ImmutableSet.builder();
for (Team t : teams) {
users.addAll(t.getMembers());
}
return users.build();
}
});
}
}
use of org.spongepowered.api.scoreboard.TeamMember in project SpongeCommon by SpongePowered.
the class SelectorResolver method addTeamFilters.
private void addTeamFilters(List<Predicate<Entity>> filters) {
Selector sel = this.selector;
Optional<Invertible<String>> teamOpt = sel.getArgument(ArgumentTypes.TEAM);
if (teamOpt.isPresent()) {
Invertible<String> teamArg = teamOpt.get();
final boolean inverted = teamArg.isInverted();
final Collection<Team> teams = Sponge.getGame().getServer().getServerScoreboard().get().getTeams();
filters.add(new Predicate<Entity>() {
@Override
public boolean test(Entity input) {
if (input instanceof TeamMember) {
return inverted ^ collectMembers(teams).contains(((TeamMember) input).getTeamRepresentation());
}
return false;
}
private Collection<Text> collectMembers(Collection<Team> teams) {
ImmutableSet.Builder<Text> users = ImmutableSet.builder();
for (Team t : teams) {
users.addAll(t.getMembers());
}
return users.build();
}
});
}
}
Aggregations