AutoBroadcaster
AutoBroadcaster 是一款轻量且功能丰富的 PaperMC 插件,用于自动化服务器公告。它允许你按特定间隔或精确的服务器时间调度广播,并支持高级的目标筛选选项。
功能
- 间隔消息:按设定的间隔(例如每 5 分钟)顺序或随机地依次广播消息。
- 定时消息:在精确的服务器时间(例如每天 14:00 或 20:30)广播特定消息,并设有 2 分钟的检测窗口以优雅地处理延迟。
- 按世界筛选:仅向特定世界中的玩家发送广播。
- 按权限筛选:限制仅拥有特定权限的玩家接收广播。
- 游戏内管理:直接从游戏中添加、删除、列出和重载消息及配置,无需手动编辑文件。
- 现代格式支持:开箱即用完全支持 Paper 的 MiniMessage 格式(例如
<red>Hello</red>),同时若偏好也可无缝回退到传统颜色代码(例如 &cHello)。
- 性能优化:预计算的消息和零分配过滤确保在两次广播之间占用极少的 CPU/内存资源。
- 可靠调度:定时消息使用 2 分钟的检测窗口和按天跟踪机制,以防止重复触发或漏发。
- bStats 集成:通过 bStats(服务 ID: 32227)收集匿名使用统计数据。服务器所有者可通过
plugins/bStats/config.yml 选择退出。
命令与用法
主命令为 /autobroadcaster(别名:/abroadcaster, /ab)。
所有命令均需 autobroadcaster.admin 权限。
| 命令 |
描述 |
示例 |
/ab reload |
从磁盘重载配置并重启计时器。 |
/ab reload |
/ab list |
显示当前所有活跃的间隔消息和定时消息及其 ID/索引。 |
/ab list |
/ab add interval <message> |
向轮换列表中添加新的间隔消息。 |
/ab add interval <green>Join our Discord!</green> |
/ab add <HH:mm> <message> |
在指定时间添加新的定时消息。 |
/ab add 14:30 <gold>Daily event starting!</gold> |
/ab remove interval <index> |
通过索引移除一条间隔消息(使用 /ab list 查找索引)。 |
/ab remove interval 1 |
/ab remove time <HH:mm> |
移除该特定时间的定时消息。 |
/ab remove time 14:30 |
权限
autobroadcaster.admin - 授予对插件所有命令的完全访问权限。默认为服务器管理员 (op)。
配置 (config.yml)
你可以通过位于 plugins/AutoBroadcaster/config.yml 的 config.yml 文件直接配置插件。
基础配置
# AutoBroadcaster Configuration
# 所有插件消息的前缀
prefix: "<gray>[<gradient:#ff0000:#ff7f00>AutoBroadcaster</gradient>] <reset>"
# 按特定间隔广播的消息。
# interval_seconds: 消息广播的频率(秒),最小值为 10。
# random_order: 如果为 true,则随机选择消息。如果为 false,则按顺序播放。
# target_worlds: 要广播到的世界列表。留空表示所有世界。
# required_permission: 如果设置,则只有拥有此权限的玩家才会看到消息。留空表示所有人。
interval_messages:
enabled: true
interval_seconds: 300
random_order: false
target_worlds: []
required_permission: ""
messages:
- "<green>Welcome to our server!</green> Remember to read the rules."
- "Join our discord at <aqua><click:open_url:'https://discord.gg/example'>discord.gg/example</click></aqua>"
# 在特定服务器时间 (HH:MM) 广播的消息。
# 请确保时间与服务器时区匹配。
# target_worlds 和 required_permissions 是按时间键映射的。
scheduled_messages:
enabled: true
messages:
"12:00": "<gold>It is noon! Don't forget to grab your daily rewards!</gold>"
"20:00": "<light_purple>Evening event is starting now!</light_purple>"
target_worlds:
"12:00": []
"20:00": []
required_permissions:
"12:00": ""
"20:00": ""
高级筛选示例
按世界筛选广播:
interval_messages:
target_worlds: ["world", "world_nether"] # 仅向这些世界中的玩家广播
基于权限的广播:
interval_messages:
required_permission: "server.vip" # 仅拥有此权限的玩家看到消息
按定时消息时间单独筛选:
scheduled_messages:
messages:
"12:00": "<gold>Noon event in spawn!</gold>"
"20:00": "<light_purple>Evening event!</light_purple>"
target_worlds:
"12:00": ["world"] # 中午消息仅在主世界播放
"20:00": [] # 晚间消息在所有世界播放
required_permissions:
"12:00": "" # 中午消息面向所有人
"20:00": "server.vip" # 晚间消息仅限 VIP 玩家
性能
AutoBroadcaster 旨在实现最低的资源占用:
- 广播间零 CPU 占用:在等待下一次广播期间,插件几乎不消耗 CPU
- 预计算消息:所有消息组件在配置加载时构建一次,而不是在每次广播tick时构建
- 零分配过滤:世界和权限检查使用简单的循环,无对象分配
- 缓存的时间解析:定时消息的时间仅解析一次并缓存
- 最小间隔保护:低于 10 秒的间隔会自动限制,以防止性能问题
可靠性
- 防止定时消息重复:每个定时消息每天只能触发一次,即使重载也不会例外
- 容忍延迟的调度:使用 2 分钟的检测窗口而非精确时间匹配
- 错误处理:所有任务和广播都包裹在 try-catch 块中,以防止静默失败
编译 / 构建
本插件基于 PaperMC 26.2.build.22-alpha,需要 Java 25 才能进行编译和运行。
自行构建步骤如下:
- 克隆仓库。
- 确保已安装 Java 25 JDK。
- 运行
./gradlew build。
.jar 文件将生成在 build/libs/ 目录下。
AutoBroadcaster
AutoBroadcaster is a lightweight and feature-rich PaperMC plugin that automates server announcements. It allows you to schedule broadcasts at specific intervals or at exact server times, with advanced targeting options.
Features
- Interval Messages: Broadcast messages sequentially or randomly at a set interval (e.g., every 5 minutes).
- Scheduled Messages: Broadcast specific messages at exact server times (e.g., daily at 14:00 or 20:30) with a 2-minute window to handle lag gracefully.
- Per-World Targeting: Send broadcasts only to players in specific worlds.
- Per-Permission Targeting: Restrict broadcasts to players with specific permissions.
- In-Game Management: Add, remove, list, and reload messages and configurations directly from the game without needing to edit files manually.
- Modern Formatting: Fully supports Paper's MiniMessage formatting out of the box (e.g.,
<red>Hello</red>), while seamlessly falling back to legacy color codes (e.g., &cHello) if preferred.
- Performance Optimized: Pre-computed messages and zero-allocation filtering ensure minimal CPU/memory usage between broadcasts.
- Reliable Scheduling: Scheduled messages use a 2-minute detection window and per-day tracking to prevent duplicates and missed broadcasts.
- bStats Integration: Anonymous usage statistics via bStats (service ID: 32227). Server owners can opt-out via
plugins/bStats/config.yml.
Commands & Usage
The main command is /autobroadcaster (aliases: /abroadcaster, /ab).
All commands require the autobroadcaster.admin permission.
| Command |
Description |
Example |
/ab reload |
Reloads the configuration from disk and restarts the timers. |
/ab reload |
/ab list |
Displays all currently active interval and scheduled messages along with their IDs/Indices. |
/ab list |
/ab add interval <message> |
Adds a new interval message to the rotation. |
/ab add interval <green>Join our Discord!</green> |
/ab add <HH:mm> <message> |
Adds a new scheduled message at the specified time. |
/ab add 14:30 <gold>Daily event starting!</gold> |
/ab remove interval <index> |
Removes an interval message by its index (use /ab list to find the index). |
/ab remove interval 1 |
/ab remove time <HH:mm> |
Removes a scheduled message for that specific time. |
/ab remove time 14:30 |
Permissions
autobroadcaster.admin - Grants full access to all plugin commands. Defaults to server Operators (op).
Configuration (config.yml)
You can configure the plugin directly via the config.yml file located in plugins/AutoBroadcaster/config.yml.
Basic Configuration
# AutoBroadcaster Configuration
# The prefix for all plugin messages
prefix: "<gray>[<gradient:#ff0000:#ff7f00>AutoBroadcaster</gradient>] <reset>"
# Messages that are broadcasted at a specific interval.
# interval_seconds: How often in seconds the messages should be broadcasted (minimum 10).
# random_order: If true, picks a random message. If false, goes in order.
# target_worlds: List of worlds to broadcast to. Leave empty for all worlds.
# required_permission: If set, only players with this permission will see the message. Leave empty for everyone.
interval_messages:
enabled: true
interval_seconds: 300
random_order: false
target_worlds: []
required_permission: ""
messages:
- "<green>Welcome to our server!</green> Remember to read the rules."
- "Join our discord at <aqua><click:open_url:'https://discord.gg/example'>discord.gg/example</click></aqua>"
# Messages that are broadcasted at specific server times (HH:MM).
# Make sure the time matches the server's time zone.
# target_worlds and required_permissions are per-time-key maps.
scheduled_messages:
enabled: true
messages:
"12:00": "<gold>It is noon! Don't forget to grab your daily rewards!</gold>"
"20:00": "<light_purple>Evening event is starting now!</light_purple>"
target_worlds:
"12:00": []
"20:00": []
required_permissions:
"12:00": ""
"20:00": ""
Advanced Targeting Examples
World-Specific Broadcasts:
interval_messages:
target_worlds: ["world", "world_nether"] # Only broadcast to players in these worlds
Permission-Based Broadcasts:
interval_messages:
required_permission: "server.vip" # Only players with this permission see the message
Per-Scheduled-Time Targeting:
scheduled_messages:
messages:
"12:00": "<gold>Noon event in spawn!</gold>"
"20:00": "<light_purple>Evening event!</light_purple>"
target_worlds:
"12:00": ["world"] # Noon message only in overworld
"20:00": [] # Evening message in all worlds
required_permissions:
"12:00": "" # Noon message for everyone
"20:00": "server.vip" # Evening message for VIPs only
Performance
AutoBroadcaster is designed for minimal resource usage:
- Zero CPU between broadcasts: The plugin uses virtually no CPU while waiting for the next broadcast
- Pre-computed messages: All message components are built once at config load, not on every broadcast tick
- Zero-allocation filtering: World and permission checks use simple loops with no object allocation
- Cached time parsing: Scheduled message times are parsed once and cached
- Minimum interval safeguard: Intervals below 10 seconds are automatically clamped to prevent performance issues
Reliability
- Scheduled message duplicates prevented: Each scheduled message can only fire once per day, even after reloads
- Lag-tolerant scheduling: Uses a 2-minute detection window instead of exact time matching
- Error handling: All tasks and broadcasts are wrapped in try-catch blocks to prevent silent failures
Compilation / Building
This plugin targets PaperMC 26.2.build.22-alpha and requires Java 25 to compile and run.
To build it yourself:
- Clone the repository.
- Ensure you have a Java 25 JDK installed.
- Run
./gradlew build.
- The
.jar will be generated in build/libs/.
评论 0
登录后参与评分
还没有评论,来抢沙发吧