Skip to content

Fixed Listening to Handshake Packets & ServerPingRecord#2933

Merged
dmulloy2 merged 1 commit intodmulloy2:masterfrom
LOOHP:handshake-listener-fix
Jun 3, 2024
Merged

Fixed Listening to Handshake Packets & ServerPingRecord#2933
dmulloy2 merged 1 commit intodmulloy2:masterfrom
LOOHP:handshake-listener-fix

Conversation

@LOOHP
Copy link
Copy Markdown
Contributor

@LOOHP LOOHP commented May 15, 2024

On version 1.20.6, ChannelProtocolUtil is unable to get the Handshake Protocol PacketType due to Minecraft using a different handler during this phase.

ServerPingRecord is also unable to locate the server icon class on Mojang-mapped servers.

Fixes #2647

@LOOHP LOOHP changed the title Fixed Listening to Handshake Packets Fixed Listening to Handshake Packets & StatusPing May 15, 2024
@LOOHP LOOHP changed the title Fixed Listening to Handshake Packets & StatusPing Fixed Listening to Handshake Packets & ServerPingRecord May 15, 2024
.build());

BiFunction<Channel, PacketType.Sender, Object> baseResolver = null;
BiFunction<Channel, PacketType.Sender, PacketType.Protocol> baseResolver = null;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change the type here from Object to PacketType.Protocol? Doesn't this only introduce duplicate code since you copied the PacketType.Protocol::fromVanilla method to the resolver implementations?

Copy link
Copy Markdown
Contributor Author

@LOOHP LOOHP May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public PacketType.Protocol apply(Channel channel, PacketType.Sender sender) {
String key = this.getKeyForSender(sender);
Object codecHandler = channel.pipeline().get(key);
if (codecHandler == null) {
String unconfiguratedKey = this.getUnconfiguratedKeyForSender(sender);
if (channel.pipeline().get(unconfiguratedKey) != null) {
return PacketType.Protocol.HANDSHAKING;

It does create some duplication but as PacketType.Protocol::fromVanilla isn't used everywhere anymore after this change with some cases returning the the packet type directly, I felt like it made sense to make the function return the type directly.

@dmulloy2 dmulloy2 merged commit 720bb83 into dmulloy2:master Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Registering a Listener for SET_PROTOCOL Blocks Players From Logging In

3 participants