Skip to content

Commit 38ff21a

Browse files
Fix theoretical IOOBE race (#1799)
1 parent 9c0c9b0 commit 38ff21a

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

proxy/src/main/java/com/velocitypowered/proxy/connection/util/ServerListPingHandler.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,16 @@ private ServerPing constructLocalPing(ProtocolVersion version) {
5757
List<ServerPing.SamplePlayer> samplePlayers;
5858
if (configuration.getSamplePlayersInPing()) {
5959
List<ServerPing.SamplePlayer> unshuffledPlayers = server.getAllPlayers().stream()
60-
.map(p -> {
61-
if (p.getPlayerSettings().isClientListingAllowed()) {
62-
return new ServerPing.SamplePlayer(p.getUsername(), p.getUniqueId());
63-
} else {
64-
return ServerPing.SamplePlayer.ANONYMOUS;
65-
}
66-
})
67-
.collect(Collectors.toList());
60+
.map(p -> {
61+
if (p.getPlayerSettings().isClientListingAllowed()) {
62+
return new ServerPing.SamplePlayer(p.getUsername(), p.getUniqueId());
63+
} else {
64+
return ServerPing.SamplePlayer.ANONYMOUS;
65+
}
66+
})
67+
.collect(Collectors.toList());
6868
Collections.shuffle(unshuffledPlayers);
69-
samplePlayers = unshuffledPlayers.subList(0, Math.min(12, server.getPlayerCount()));
69+
samplePlayers = unshuffledPlayers.subList(0, Math.min(12, unshuffledPlayers.size()));
7070
} else {
7171
samplePlayers = ImmutableList.of();
7272
}

0 commit comments

Comments
 (0)