DefaultChat: 面向 Paper 的现代聊天管理插件
DefaultChat 是一款轻量级且结构清晰的聊天插件,专为现代 Paper 服务器设计。它完全用原生 MiniMessage 支持取代了旧式的颜色代码,提供了一个灵活且安全的沟通环境。该插件无需任何依赖,不使用 NMS(非官方 Minecraft 代码),并且仅以单个 JAR 文件的形式运行。
目的与设计
许多现有的聊天插件是为较旧的 Spigot 版本设计的,并依赖于过时的颜色代码。DefaultChat 基于现代 Paper API 构建,专注于以下三个核心方面:
- 现代格式化: 完整的 MiniMessage 支持允许使用渐变、彩虹色、阴影和物品图标。这种格式化一致地应用于聊天格式、错误消息和命令输出中。
- 无侵入式交互: 玩家提及通过可配置的声音提示处理,而不是使用侵入性的操作栏消息或屏幕标题。
- 性能与灵活性: 配置完全基于 MiniMessage,消息处理针对多线程环境进行了优化,包括对 Folia 的完整支持。
主要功能
聊天频道
- 本地聊天: 只有处于可配置区块半径内的玩家才能看到消息。每个世界的半径可以单独设置。
- 全球聊天: 通过可配置的前缀(默认为
!)或 /globalchat 命令激活。
- 频道记忆: 玩家可以使用
/chat local、/chat global 或 /chat toggle 在频道之间切换。
- 隐身支持: 隐身的玩家不会收到来自本地聊天的消息。
提及系统
- 无论字母大小写如何,消息中的玩家名称都会被高亮显示并被识别。
- 被提及的玩家会收到可配置的声音提示。音量、音调和冷却时间都可以调整。
- 玩家可以使用
/chat ping 自行切换声音提示。
- 只有当玩家实际上处于消息的听觉范围内时,才会发送声音提示。
格式化与 MiniMessage
- 所有文本元素,包括聊天格式、悬停文本和错误消息,都使用 MiniMessage 模板进行配置。
- 拥有
defaultchat.format 权限的玩家可以使用一套安全的标签子集,包括颜色、装饰、渐变和彩虹色。危险的标签(如点击事件、悬停事件、字体、分数板和 NBT)将被阻止。
- 玩家名称是可点击的,并建议执行
/msg 命令。
- 格式化错误会被优雅地处理。如果消息包含无效语法,它将作为纯文本显示,而不会导致聊天崩溃。
审核与反垃圾保护
- 冷却时间与限制: 包括消息冷却时间、重复消息预防和滑动窗口消息限制。
- 大写防护: 阻止或忽略包含过多大写字母的消息。
- 过滤器: 单词过滤支持掩码(
****)或完全阻止。链接过滤可以阻止 URL,并提供白名单特定域名的选项。
- 绕过权限: 工作人员可以使用
defaultchat.bypass.spam 和 defaultchat.bypass.filter 权限绕过反垃圾和过滤器检查。
历史与日志
/chat history [n]: 显示内存中最后 N 条消息,用于审核目的。
- 异步日志记录: 所有消息都会写入单独的虚拟线程上的
chat.log 文件中,防止磁盘 I/O 延迟聊天传递。
开发者 API
- 该插件会触发一个
DefaultChatMessageEvent,允许其他插件查看、修改、取消或重定向消息。
- 该事件在全局区域线程中触发,支持组件修改,并且是可以取消的。
性能与兼容性
- 单个 JAR: 针对最旧的受支持 API(1.21.11)编译,以确保与 Paper 1.21.11、26.1、26.1.2、26.2 和 26.3+ 兼容。
- Folia 就绪: 完全兼容 Folia(
folia-supported: true)。
- 最小 TPS 影响: 聊天处理发生在全局区域线程中。配置只加载一次并存储在不可变记录中,适合高负载服务器。
要求与安装
要求:
- 平台: Paper 或其分支,包括 Folia。不支持 Spigot 和 CraftBukkit。
- Minecraft: 1.21.11, 26.1, 26.1.2, 26.2, 26.3 及更新版本。
- Java: 25+
- 依赖项: 无。
安装:
- 下载
DefaultChat-1.0.0.jar 文件。
- 将文件放入服务器的
plugins/ 目录中。
- 启动服务器。
config.yml 和语言文件将自动生成。
- 根据需要配置插件,并使用
/chat reload 应用更改。
许可证
本项目根据 MIT 许可证分发。作者:Slavyanin。
DefaultChat: Modern Chat Management for Paper
DefaultChat is a lightweight and well-structured chat plugin designed specifically for modern Paper servers. It completely replaces legacy color codes with native MiniMessage support, providing a flexible and secure communication environment. The plugin requires no dependencies, utilizes no NMS, and operates as a single JAR file.
Purpose and Design
Many existing chat plugins were designed for older Spigot versions and rely on outdated color codes. DefaultChat is built for the modern Paper API and focuses on three core aspects:
- Modern Formatting: Full MiniMessage support allows for gradients, rainbows, shadows, and item sprites. This formatting applies consistently across chat formats, error messages, and command outputs.
- Unobtrusive Interactions: Player mentions are handled via configurable sound pings rather than intrusive action bar messages or screen titles.
- Performance and Flexibility: The configuration is entirely based on MiniMessage, and message processing is optimized for multi-threaded environments, including full support for Folia.
Key Features
Chat Channels
- Local Chat: Messages are only visible to players within a configurable block radius. The radius can be set individually for each world.
- Global Chat: Activated by a configurable prefix (default
!) or the /globalchat command.
- Channel Memory: Players can switch between channels using
/chat local, /chat global, or /chat toggle.
- Vanish Support: Vanished players do not receive messages from local chat.
Mentions System
- Player names in messages are highlighted and recognized regardless of letter case.
- Mentioned players receive a configurable sound ping. The volume, pitch, and cooldown can be adjusted.
- Players can toggle pings for themselves using
/chat ping.
- Pings are only sent if the player is actually within the hearing radius of the message.
Formatting and MiniMessage
- All text elements, including chat formats, hover text, and error messages, are configured using MiniMessage templates.
- Players with the
defaultchat.format permission can use a safe subset of tags, including colors, decorations, gradients, and rainbows. Dangerous tags such as click events, hover events, fonts, score, and NBT are blocked.
- Player names are clickable and suggest the
/msg command.
- Formatting errors are handled gracefully. If a message contains invalid syntax, it is displayed as plain text rather than breaking the chat.
Moderation and Spam Protection
- Cooldowns and Limits: Includes message cooldowns, duplicate message prevention, and a sliding window message limit.
- Caps Guard: Blocks or ignores messages with excessive uppercase letters.
- Filters: Word filtering supports masking (
****) or complete blocking. Link filtering can block URLs with an option to whitelist specific domains.
- Bypass Permissions: Staff members can bypass spam and filter checks with
defaultchat.bypass.spam and defaultchat.bypass.filter.
History and Logging
/chat history [n]: Displays the last N messages from memory for moderation purposes.
- Asynchronous Logging: All messages are written to
chat.log on a separate virtual thread, preventing disk I/O from delaying chat delivery.
Developer API
- The plugin fires a
DefaultChatMessageEvent, allowing other plugins to view, modify, cancel, or redirect messages.
- The event is fired in the global region thread, supports component modification, and is cancellable.
Performance and Compatibility
- Single JAR: Compiled against the oldest supported API (1.21.11) to ensure compatibility with Paper 1.21.11, 26.1, 26.1.2, 26.2, and 26.3+.
- Folia-Ready: Fully compatible with Folia (
folia-supported: true).
- Minimal TPS Impact: Chat processing occurs in the global region thread. The configuration is loaded once and stored in immutable records, making it suitable for high-load servers.
Requirements and Installation
Requirements:
- Platform: Paper or its forks, including Folia. Spigot and CraftBukkit are not supported.
- Minecraft: 1.21.11, 26.1, 26.1.2, 26.2, 26.3 and newer.
- Java: 25+
- Dependencies: None.
Installation:
- Download the
DefaultChat-1.0.0.jar file.
- Place the file into the
plugins/ directory of your server.
- Start the server. The
config.yml and language files will be generated automatically.
- Configure the plugin as needed and apply changes using
/chat reload.
License
This project is distributed under the MIT License. Author: Slavyanin.
评论 0
登录后参与评分
还没有评论,来抢沙发吧