diff --git a/server/conn.go b/server/conn.go index 9cdc512..9b297ee 100644 --- a/server/conn.go +++ b/server/conn.go @@ -64,7 +64,7 @@ type Conn struct { // It is used for reading and writing packets to the underlying connection. func NewConn(conn io.ReadWriteCloser, addr net.Addr, logger *slog.Logger, token string, clientData login.ClientData, identityData login.IdentityData, pool packet.Pool) *Conn { c := &Conn{ - conn: conn, + conn: conn, reader: proto.NewReader(conn), writer: proto.NewWriter(conn), logger: logger, @@ -206,6 +206,14 @@ func (c *Conn) SpawnContext(ctx context.Context) error { } } +// Conn returns the underlying connection. +// Direct access to the underlying connection through this method is +// strongly discouraged due to the potential for unpredictable behavior. +// Use this method only when absolutely necessary. +func (c *Conn) Conn() io.ReadWriteCloser { + return c.conn +} + // GameData returns the game data set for the connection by the StartGame packet. func (c *Conn) GameData() minecraft.GameData { return c.gameData diff --git a/server/packet/connection_request.go b/server/packet/connection_request.go index 22b9164..00d643c 100644 --- a/server/packet/connection_request.go +++ b/server/packet/connection_request.go @@ -24,7 +24,6 @@ func (pk *ConnectionRequest) ID() uint32 { func (pk *ConnectionRequest) Marshal(io protocol.IO) { io.String(&pk.Addr) io.String(&pk.Token) - io.ByteSlice(&pk.ClientData) io.ByteSlice(&pk.IdentityData) }