PlayerKickEvent.leaveMessage(Component leaveMessage) doesn't work with null.

未关闭
#14,455 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
58/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
java
领域
backend

调研方向

The reporter traces the bug to the kick handling in paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch, where a null leave message falls back to the default. Read the PlayerList#remove overloads and how PlayerQuitEvent supplies the final message, then reproduce with a plugin that calls leaveMessage(null) on PlayerKickEvent. Done means a null leave message suppresses the broadcast without breaking the quit event.

由索引模型根据 Issue 内容生成。

描述

status: needs triage version: 26.3
Expected behavior

If I call PlayerKickEvent.leaveMessage(null), the leave message is set to null and so not sent, like it says in the description of the method.

Observed/Actual behavior

The leave message is still sent.

Steps/models to reproduce
@EventHandler
private void onPlayerKick(PlayerKickEvent event) {
    event.leaveMessage(null);
}
  1. Log in with 2 accounts
  2. Kick one of them
  3. Observe leave message still being present
Plugin and Datapack List

Replicated with only my plugin.

Paper version

This server is running Paper version 26.3-237-main@7e88a0d (2026-11-01T19:08:12Z) (Implementing API version 26.3.build.237-stable)
You are running the latest version
Previous version: 26.3-236-f119026 (MC: 26.3)

Other

During my own analysis with the debugger and browing through source in intellij I came to the conclusion that it is caused by this line, which if the leave message is null, PlayerList#remove(net.minecraft.server.level.ServerPlayer) instead uses the default leave message. Then in PlayerList#remove(net.minecraft.server.level.ServerPlayer, net.kyori.adventure.text.Component) it calls PlayerQuitEvent with the supplied leave message, and uses the leave message out of that event, so using that event still works, but it's called later and doesn't have all the context.

主要语言
Java
星标
12.8k
派生
3.6k
平均合并
2 天 21 小时
30 天内合并 PR
33

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

PaperMC/Paper 的其他 Issue

查看 PaperMC/Paper 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。