diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java index 95dc18b00..9a60be7a4 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java @@ -45,7 +45,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler { if (player.getProtocolVersion() >= ProtocolConstants.MINECRAFT_1_13) { message = PluginMessageUtil.constructChannelsPacket("minecraft:register", VelocityServer.getServer().getChannelRegistrar().getModernChannelIds()); } else { - message = PluginMessageUtil.constructChannelsPacket("REGISTER", VelocityServer.getServer().getChannelRegistrar().getLegacyChannelIds()); + message = PluginMessageUtil.constructChannelsPacket("REGISTER", VelocityServer.getServer().getChannelRegistrar().getIdsForLegacyConnections()); } player.getConnection().write(message); } @@ -188,7 +188,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler { if (player.getProtocolVersion() >= ProtocolConstants.MINECRAFT_1_13) { toRegister.addAll(VelocityServer.getServer().getChannelRegistrar().getModernChannelIds()); } else { - toRegister.addAll(VelocityServer.getServer().getChannelRegistrar().getLegacyChannelIds()); + toRegister.addAll(VelocityServer.getServer().getChannelRegistrar().getIdsForLegacyConnections()); } if (!toRegister.isEmpty()) { String channel = player.getConnection().getProtocolVersion() >= ProtocolConstants.MINECRAFT_1_13 ? diff --git a/proxy/src/main/java/com/velocitypowered/proxy/messages/VelocityChannelRegistrar.java b/proxy/src/main/java/com/velocitypowered/proxy/messages/VelocityChannelRegistrar.java index dff2f5d3e..1fb47cce1 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/messages/VelocityChannelRegistrar.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/messages/VelocityChannelRegistrar.java @@ -1,6 +1,7 @@ package com.velocitypowered.proxy.messages; import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; import com.velocitypowered.api.proxy.messages.*; import com.velocitypowered.proxy.protocol.packet.PluginMessage; import org.apache.logging.log4j.LogManager; @@ -58,11 +59,8 @@ public class VelocityChannelRegistrar implements ChannelRegistrar { } } - public Collection getLegacyChannelIds() { - return identifierMap.values().stream() - .filter(i -> i instanceof LegacyChannelIdentifier) - .map(ChannelIdentifier::getId) - .collect(Collectors.toList()); + public Collection getIdsForLegacyConnections() { + return ImmutableList.copyOf(identifierMap.keySet()); } public Collection getModernChannelIds() {