From f76d21d030c7b0999cf9c91d45733f69d606396e Mon Sep 17 00:00:00 2001 From: Wouter Gritter Date: Thu, 21 May 2026 22:57:19 +0200 Subject: [PATCH] Fix theoretical IOOBE race --- .../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 12c6be2b34..5ccb2b1105 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 @@ private ServerPing constructLocalPing(ProtocolVersion version) { 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(); }