fix: handle empty kick status message properly in Status protocol state

This commit is contained in:
adman
2026-04-29 18:48:10 +02:00
parent 3d34ad59e9
commit 159437c1ca
+3 -2
View File
@@ -26,14 +26,15 @@ func Kick(c *proto.Conn, reason *text.Component, status string) (err error) {
case proto_base.Handshaking: case proto_base.Handshaking:
err = CantKickInStateErr err = CantKickInStateErr
case proto_base.Status: case proto_base.Status:
var b = []byte(status)
if status == "" { if status == "" {
var b []byte
b, err = reason.MarshalJSON() b, err = reason.MarshalJSON()
if err != nil { if err != nil {
return return
} }
status = fmt.Sprintf("{\"description\":%s}", string(b))
} }
err = c.Send(&v1_21_8.StatusToClientPacketServerInfo{Response: fmt.Sprintf("{\"description\":%s}", string(b))}) err = c.Send(&v1_21_8.StatusToClientPacketServerInfo{Response: status})
case proto_base.Login: case proto_base.Login:
var b []byte var b []byte
b, err = reason.MarshalJSON() b, err = reason.MarshalJSON()