Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Listening to Handshake Packets & ServerPingRecord #2933

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

LOOHP
Copy link
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
@@ -31,7 +30,7 @@ final class ChannelProtocolUtil {
.declaringClassExactType(networkManagerClass)
.build());

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

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
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
2 of 3 checks passed
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