描述
GeyserSanitizer 是一款 Spigot/Paper 插件,旨在对发送给基岩版玩家的文本组件进行清理,防止因某些不受支持的文本特性而导致客户端崩溃或显示异常。它专门针对并修改聊天消息、系统消息以及团队相关文本(nametags、前缀、后缀),以确保通过 GeyserMC/Floodgate 连接的基岩版客户端兼容性。
功能
- 聊天消息清理:拦截并清理发出的聊天消息。
- 系统消息清理:拦截并清理发出的系统消息。
- 团队文本清理:清理作为团队更新一部分发送的 nametags、前缀和后缀。
- 基岩版玩家检测:利用 Floodgate API 仅对基岩版玩家应用清理操作。
- 图标/头部图标移除:移除包含 'atlas'、'sprite'、'hat' 或 'player' 键的 JSON 组件,这些组件已知会导致基岩版客户端出现问题。
依赖项
本插件正常运行需要以下依赖:
- PacketEvents:用于拦截和修改网络数据包。
- Floodgate:用于识别基岩版玩家。
工作原理
该插件使用 PacketEvents 注册了一个 PacketInterceptor 监听器。当服务器发送特定数据包(CHAT_MESSAGE、SYSTEM_CHAT_MESSAGE、TEAMS)时,拦截器会检查接收者是否为基岩版玩家(通过 Floodgate)。如果是,则在数据包发送到客户端之前,通过移除包含问题键(如 "atlas"、"sprite"、"hat"、"player")的 JSON 结构来清理 net.kyori.adventure.text.Component 消息。这可以防止不受支持的特性到达基岩版客户端并引发问题。
Description
GeyserSanitizer is a Spigot/Paper plugin designed to sanitize text components sent to Bedrock players, preventing client crashes or display issues that can arise from certain unsupported text features. It specifically targets and modifies chat messages, system messages, and team-related text (nametags, prefixes, suffixes) to ensure compatibility with Bedrock clients connected via GeyserMC/Floodgate.
Features
- Chat Message Sanitization: Intercepts and sanitizes outgoing chat messages.
- System Message Sanitization: Intercepts and sanitizes outgoing system messages.
- Team Text Sanitization: Cleans nametags, prefixes, and suffixes sent as part of team updates.
- Bedrock Player Detection: Utilizes Floodgate API to selectively apply sanitization only to Bedrock players.
- Icon/Head Icon Removal: Removes JSON components containing 'atlas', 'sprite', 'hat', or 'player' keys, which are known to cause issues on Bedrock clients.
Dependencies
This plugin requires the following to function correctly:
- PacketEvents: Used for intercepting and modifying network packets.
- Floodgate: Used to identify Bedrock players.
How It Works
The plugin registers a PacketInterceptor listener with PacketEvents. When a server sends certain packets (CHAT_MESSAGE, SYSTEM_CHAT_MESSAGE, TEAMS), the interceptor checks if the recipient is a Bedrock player (using Floodgate). If so, it sanitizes the net.kyori.adventure.text.Component messages by removing JSON structures that contain problematic keys (like "atlas", "sprite", "hat", "player") before the packet is sent to the client. This prevents unsupported features from reaching the Bedrock client and causing issues.
评论 0
登录后参与评分
还没有评论,来抢沙发吧