Properly register client channels.

This commit is contained in:
Andrew Steinborn
2018-11-10 23:20:33 -05:00
parent 8a7ba25097
commit c94794a845
2 changed files with 9 additions and 1 deletions

View File

@@ -65,7 +65,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
@Override
public void activated() {
PluginMessage register = PluginMessageUtil.constructChannelsPacket(player.getProtocolVersion(),
server.getChannelRegistrar().getModernChannelIds());
server.getChannelRegistrar().getChannelsForProtocol(player.getProtocolVersion()));
player.getConnection().write(register);
}

View File

@@ -6,6 +6,7 @@ import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
import com.velocitypowered.api.proxy.messages.ChannelRegistrar;
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
import com.velocitypowered.proxy.protocol.ProtocolConstants;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
@@ -68,4 +69,11 @@ public class VelocityChannelRegistrar implements ChannelRegistrar {
public @Nullable ChannelIdentifier getFromId(String id) {
return identifierMap.get(id);
}
public Collection<String> getChannelsForProtocol(int protocolVersion) {
if (protocolVersion >= ProtocolConstants.MINECRAFT_1_13) {
return getModernChannelIds();
}
return getIdsForLegacyConnections();
}
}