From 38ff21afd746d9b06f41f6786e25fa8cd4243dda Mon Sep 17 00:00:00 2001 From: Wouter Gritter Date: Fri, 22 May 2026 16:50:48 +0200 Subject: [PATCH] Fix theoretical IOOBE race (#1799) --- .../connection/util/ServerListPingHandler.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ServerListPingHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ServerListPingHandler.java index 12c6be2b3..5ccb2b110 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ServerListPingHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ServerListPingHandler.java @@ -57,16 +57,16 @@ public class ServerListPingHandler { List samplePlayers; if (configuration.getSamplePlayersInPing()) { List 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(); }