Skip to content

Commit

Permalink
Always map command to signed command in 1.20.5->1.20.3
Browse files Browse the repository at this point in the history
Sending any message, any non-message command, and again any message would kick the client with a chat validation error. Let's see if this is better
  • Loading branch information
kennytv committed Aug 15, 2024
1 parent 9ca5236 commit eb4d30a
Showing 1 changed file with 2 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,8 @@ protected void registerPackets() {
wrapper.write(Types.BOOLEAN, wrapper.user().get(SecureChatStorage.class).enforcesSecureChat());
});

registerServerbound(ServerboundPackets1_20_3.CHAT_COMMAND, ServerboundPackets1_20_5.CHAT_COMMAND_SIGNED, wrapper -> {
final String command = wrapper.passthrough(Types.STRING); // Command
wrapper.passthrough(Types.LONG); // Timestamp
wrapper.passthrough(Types.LONG); // Salt
final int signatures = wrapper.passthrough(Types.VAR_INT); // Signatures
if (signatures == 0) {
wrapper.cancel();

final PacketWrapper chatCommand = wrapper.create(ServerboundPackets1_20_5.CHAT_COMMAND);
chatCommand.write(Types.STRING, command);
chatCommand.sendToServer(Protocol1_20_5To1_20_3.class);
}
});
// Always write as signed, even if there is 0 signatures attached, else the validation chain gets broken
registerServerbound(ServerboundPackets1_20_3.CHAT_COMMAND, ServerboundPackets1_20_5.CHAT_COMMAND_SIGNED);

registerClientbound(State.LOGIN, ClientboundLoginPackets.COOKIE_REQUEST.getId(), -1, wrapper -> handleCookieRequest(wrapper, ServerboundLoginPackets.COOKIE_RESPONSE));
cancelClientbound(ClientboundConfigurationPackets1_20_5.RESET_CHAT); // Old clients already reset chat when entering the configuration phase
Expand Down

0 comments on commit eb4d30a

Please sign in to comment.