mirror of
https://github.com/PaperMC/Velocity.git
synced 2026-06-21 17:57:47 +02:00
Fix theoretical IOOBE race (#1799)
This commit is contained in:
@@ -57,16 +57,16 @@ public class ServerListPingHandler {
|
|||||||
List<ServerPing.SamplePlayer> samplePlayers;
|
List<ServerPing.SamplePlayer> samplePlayers;
|
||||||
if (configuration.getSamplePlayersInPing()) {
|
if (configuration.getSamplePlayersInPing()) {
|
||||||
List<ServerPing.SamplePlayer> unshuffledPlayers = server.getAllPlayers().stream()
|
List<ServerPing.SamplePlayer> unshuffledPlayers = server.getAllPlayers().stream()
|
||||||
.map(p -> {
|
.map(p -> {
|
||||||
if (p.getPlayerSettings().isClientListingAllowed()) {
|
if (p.getPlayerSettings().isClientListingAllowed()) {
|
||||||
return new ServerPing.SamplePlayer(p.getUsername(), p.getUniqueId());
|
return new ServerPing.SamplePlayer(p.getUsername(), p.getUniqueId());
|
||||||
} else {
|
} else {
|
||||||
return ServerPing.SamplePlayer.ANONYMOUS;
|
return ServerPing.SamplePlayer.ANONYMOUS;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
Collections.shuffle(unshuffledPlayers);
|
Collections.shuffle(unshuffledPlayers);
|
||||||
samplePlayers = unshuffledPlayers.subList(0, Math.min(12, server.getPlayerCount()));
|
samplePlayers = unshuffledPlayers.subList(0, Math.min(12, unshuffledPlayers.size()));
|
||||||
} else {
|
} else {
|
||||||
samplePlayers = ImmutableList.of();
|
samplePlayers = ImmutableList.of();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user