Allow protocols to handle client intention packet (#4112)

This commit is contained in:
EnZaXD 2024-08-21 19:58:32 +02:00 committed by GitHub
parent 10ee7e1930
commit c6381e7f4d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -128,6 +128,15 @@ public class InitialBaseProtocol extends AbstractProtocol<BaseClientboundPacket,
wrapper.set(Types.VAR_INT, 0, serverProtocol.getOriginalVersion()); wrapper.set(Types.VAR_INT, 0, serverProtocol.getOriginalVersion());
} }
// Send client intention into the pipeline in case protocols down the line need to transform it
try {
final List<Protocol> protocols = new ArrayList<>(pipeline.pipes());
protocols.remove(this);
wrapper.apply(Direction.SERVERBOUND, State.HANDSHAKE, protocols);
} catch (CancelException e) {
throw new RuntimeException("Cancelling the client intention packet is not allowed", e);
}
if (Via.getManager().isDebug()) { if (Via.getManager().isDebug()) {
Via.getPlatform().getLogger().info("User connected with protocol: " + info.protocolVersion() + " and serverProtocol: " + info.serverProtocolVersion()); Via.getPlatform().getLogger().info("User connected with protocol: " + info.protocolVersion() + " and serverProtocol: " + info.serverProtocolVersion());
Via.getPlatform().getLogger().info("Protocol pipeline: " + pipeline.pipes()); Via.getPlatform().getLogger().info("Protocol pipeline: " + pipeline.pipes());