Fix theoretical IOOBE race (#1799)

This commit is contained in:
Wouter Gritter
2026-05-22 16:50:48 +02:00
committed by GitHub
parent 9c0c9b0218
commit 38ff21afd7

View File

@@ -57,16 +57,16 @@ public class ServerListPingHandler {
List<ServerPing.SamplePlayer> samplePlayers;
if (configuration.getSamplePlayersInPing()) {
List<ServerPing.SamplePlayer> unshuffledPlayers = server.getAllPlayers().stream()
.map(p -> {
if (p.getPlayerSettings().isClientListingAllowed()) {
return new ServerPing.SamplePlayer(p.getUsername(), p.getUniqueId());
} else {
return ServerPing.SamplePlayer.ANONYMOUS;
}
})
.collect(Collectors.toList());
.map(p -> {
if (p.getPlayerSettings().isClientListingAllowed()) {
return new ServerPing.SamplePlayer(p.getUsername(), p.getUniqueId());
} else {
return ServerPing.SamplePlayer.ANONYMOUS;
}
})
.collect(Collectors.toList());
Collections.shuffle(unshuffledPlayers);
samplePlayers = unshuffledPlayers.subList(0, Math.min(12, server.getPlayerCount()));
samplePlayers = unshuffledPlayers.subList(0, Math.min(12, unshuffledPlayers.size()));
} else {
samplePlayers = ImmutableList.of();
}