Skip to content

Conversation

@astei
Copy link
Contributor

@astei astei commented Oct 19, 2025

This is a really large PR, so review carefully.

This PR refactors Velocity's internal networking to use immutable(-ish) packets and splits encoding/decoding into separate codecs. This refactor isn't fully complete but there's enough to start doing more work on this.

Comment on lines 68 to 74
public UUID getUuid() {
return uuid;
}

public int getAction() {
return action;
}
Copy link

Choose a reason for hiding this comment

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

Why keeping both getter types is necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the AI (Claude) wanted to make sure the code compiled and it sometimes chose to amend the existing code and sometimes add in getters. I didn't steer it in that direction.

Again, while it's redundant, it's a nit that someone else can fix.

import org.checkerframework.checker.nullness.qual.Nullable;

public class DisconnectPacket implements MinecraftPacket {
public final class DisconnectPacket implements MinecraftPacket {
Copy link

Choose a reason for hiding this comment

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

Why some classes like this one aren't records? It has public constructor, all final fields and record style getters, so I can't think of a reason

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it's worth converting every class to a record, it just wastes time. This feels like a very unimportant nit.

@astei astei force-pushed the astei/packet-immutable branch from f572af1 to f390682 Compare October 19, 2025 22:30
int expectedMinLen = packet.decodeExpectedMinLength(buf, direction, registry.version);
int expectedMaxLen = packet.decodeExpectedMaxLength(buf, direction, registry.version);
private void doLengthSanityChecks(ByteBuf buf,
com.velocitypowered.proxy.protocol.PacketCodec<? extends MinecraftPacket> codec)
Copy link

Choose a reason for hiding this comment

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

Why is the full name listed here?

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.

4 participants