From 27288685ffa4480ca603073c657066270afe2d70 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Sun, 26 Aug 2018 14:39:31 -0400 Subject: [PATCH] Register 1.13+ channels on legacy clients too. Prior to this commit, Velocity registered 1.13 and "legacy" channels differently. This commit unifies both for legacy clients to make compatibility easier. It also fixes a related issue in the new LuckPerms port to Velocity. --- .../proxy/connection/client/ClientPlaySessionHandler.java | 4 ++-- .../proxy/messages/VelocityChannelRegistrar.java | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) 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() {