BetterLANBroadcaster
一个 Spigot 插件,通过 UDP 多播在局域网中广播 Minecraft 服务器,允许客户端无需手动输入地址即可发现服务器。
功能
- 遵循 Minecraft LAN 发现协议,将服务器信息发送至
224.0.2.60:4445
- MOTD 支持
{online}(当前在线玩家)和 {max}(最大玩家数)变量,并实时自动替换
- 通过命令动态开启/关闭广播
- 在线修改广播的 MOTD 和广播间隔
- 查看当前广播状态
- 自定义广播端口(手动设置或自动检测)
- 调试模式,用于实时广播数据包日志
- 多语言支持(英文、中文)
- 热重载所有配置
命令
| 命令 |
描述 |
/blb |
显示插件版本信息 |
/blb start |
开始广播 |
/blb stop |
停止广播 |
/blb status |
查看广播状态 |
/blb setmotd <MOTD> |
设置广播 MOTD(每日公告) |
/blb setdelay <milliseconds> |
设置广播延迟 |
/blb setport <port|auto> |
设置广播端口(使用 auto 自动检测) |
/blb debug <on|off> |
启用/禁用调试模式 |
/blb reload |
重新加载配置文件 |
/blb help |
显示所有子命令的帮助信息 |
/blb version |
显示插件版本信息 |
提示:/betterlanbroadcaster 是完整命令,/blb 是其别名;两者等效。
所有命令都需要 betterlanbroadcaster.admin 权限,默认情况下 OP 拥有此权限。
配置
plugins/BetterLANBroadcaster/config.yml
# 语言设置:en 或 zh
language: en
局域网服务器 MOTD(欢迎信息)显示
可用变量:
{online} - 当前在线玩家数量
{max} - 最大玩家数量
motd: "A Minecraft Server"
广播延迟(毫秒)
默认值:1500 毫秒 = 1.5 秒
broadcast-delay-ms: 1500
调试模式:当设置为 true 时,每个广播数据包将记录到控制台
debug: false
广播端口:设置为 0 以自动检测服务器端口,或指定一个端口号
broadcast-port: 0
## 多语言
语言文件位于 `plugins/BetterLANBroadcaster/lang/` 目录:
- `messages_en.yml` - 英文语言文件
- `messages_zh.yml` - 中文语言文件
在 `config.yml` 中将 `language` 设置为 `en` 或 `zh` 即可切换语言。
## 颜色代码
MOTD 支持使用 `&` 符号后跟颜色字符的 Minecraft 颜色代码来为服务器名称着色。
常用颜色代码:
| 代码 | 颜色 |
|------|-------|
| `&0` | 黑色 |
| `&1` | 深蓝色 |
| `&2` | 深绿色 |
| `&3` | 深青色 |
| `&4` | 深红色 |
| `&5` | 紫色 |
| `&6` | 金色 |
| `&7` | 灰色 |
| `&8` | 深灰色 |
| `&9` | 蓝色 |
| `&a` | 绿色 |
| `&b` | 青色 |
| `&c` | 红色 |
| `&d` | 淡紫色 |
| `&e` | 黄色 |
| `&f` | 白色 |
格式代码:
| 代码 | 效果 |
|------|--------|
| `&l` | 加粗 |
| `&o` | 斜体 |
| `&n` | 下划线 |
| `&m` | 删除线 |
| `&k` | 随机 |
| `&r` | 重置 |
例如,在配置文件中设置彩色的 MOTD:
```yaml
motd: "&6&l✦ &eBetterLAN &7- &aSurvival Server &6&l✦"
在游戏中,它将显示为金色 ✦ BetterLAN - Survival Server ✦。
LAN 发现协议
该插件实现了与 Minecraft 原版局域网广播完全兼容的协议:
- 协议:UDP 多播
- 地址:
224.0.2.60
- 端口:
4445
- 消息格式:
[MOTD]服务器 MOTD[/MOTD][AD]服务器端口[/AD]
- 编码:UTF-8
构建
git clone https://github.com/myxxr/BetterLANBroadcaster.git
cd BetterLANBroadcaster
mvn clean package
构建产物将位于 target/BetterLANBroadcaster-1.0.0.jar。
依赖
- Spigot 1.20.4+ API
- Java 17+
安装
- 将
BetterLANBroadcaster-1.0.0.jar 放入 plugins/ 目录
- 启动服务器
- 使用
/blb start 开始广播
- 局域网内的 Minecraft 客户端可以在多人游戏菜单中发现该服务器
作者
Immyxxr
许可证
本项目遵循 GNU 通用公共许可证 v3.0 (GPL v3)。详情请参阅 LICENSE 文件。
bStats
BetterLANBroadcaster
A Spigot plugin that broadcasts Minecraft servers over LAN using UDP multicast, allowing clients to discover servers without manually entering addresses.
Features
- Follows the Minecraft LAN discovery protocol, sending server information to
224.0.2.60:4445
- MOTD supports
{online} (current online players) and {max} (max players) variables, automatically replaced in real-time
- Dynamic start/stop broadcasting via commands
- Online modification of broadcast MOTD and broadcast delay
- View current broadcast status
- Custom broadcast port (manual or auto-detect)
- Debug mode for real-time broadcast packet logs
- Multi-language support (English, Chinese)
- Hot-reload all configurations
Commands
| Command |
Description |
/blb |
Show plugin version info |
/blb start |
Start broadcasting |
/blb stop |
Stop broadcasting |
/blb status |
View broadcast status |
/blb setmotd <MOTD> |
Set broadcast MOTD |
/blb setdelay <milliseconds> |
Set broadcast delay |
/blb setport <port|auto> |
Set broadcast port (use auto to auto-detect) |
/blb debug <on|off> |
Enable/disable debug mode |
/blb reload |
Reload configuration files |
/blb help |
Show all subcommand help |
/blb version |
Show plugin version info |
Tip: /betterlanbroadcaster is the full command, /blb is its alias; both are equivalent.
All commands require the betterlanbroadcaster.admin permission, available to OPs by default.
Configuration
plugins/BetterLANBroadcaster/config.yml
# Language setting: en or zh
language: en
# Server MOTD displayed on LAN
# Available variables:
# {online} - Current online player count
# {max} - Maximum player count
motd: "A Minecraft Server"
# Broadcast delay (milliseconds)
# Default: 1500 ms = 1.5 seconds
broadcast-delay-ms: 1500
# Debug mode: when true, each broadcast packet is logged to console
debug: false
# Broadcast port: set to 0 to auto-detect server port, or specify a port number
broadcast-port: 0
Multi-language
Language files are located in the plugins/BetterLANBroadcaster/lang/ directory:
messages_en.yml - English language file
messages_zh.yml - Chinese language file
Set language to en or zh in config.yml to switch languages.
Color Codes
MOTD supports Minecraft color codes using the & symbol followed by a color character to color the server name.
Common color codes:
| Code |
Color |
&0 |
Black |
&1 |
Dark Blue |
&2 |
Dark Green |
&3 |
Dark Aqua |
&4 |
Dark Red |
&5 |
Purple |
&6 |
Gold |
&7 |
Gray |
&8 |
Dark Gray |
&9 |
Blue |
&a |
Green |
&b |
Aqua |
&c |
Red |
&d |
Light Purple |
&e |
Yellow |
&f |
White |
Format codes:
| Code |
Effect |
&l |
Bold |
&o |
Italic |
&n |
Underline |
&m |
Strikethrough |
&k |
Random |
&r |
Reset |
For example, setting a colored MOTD in the config:
motd: "&6&l✦ &eBetterLAN &7- &aSurvival Server &6&l✦"
In-game, it will display as gold ✦ BetterLAN - Survival Server ✦.
LAN Discovery Protocol
The plugin implements a protocol fully compatible with Minecraft's vanilla LAN broadcast:
- Protocol: UDP Multicast
- Address:
224.0.2.60
- Port:
4445
- Message format:
[MOTD]Server MOTD[/MOTD][AD]Server Port[/AD]
- Encoding: UTF-8
Build
git clone https://github.com/myxxr/BetterLANBroadcaster.git
cd BetterLANBroadcaster
mvn clean package
The build artifact will be at target/BetterLANBroadcaster-1.0.0.jar.
Dependencies
- Spigot 1.20.4+ API
- Java 17+
Installation
- Place
BetterLANBroadcaster-1.0.0.jar into the plugins/ directory
- Start the server
- Use
/blb start to start broadcasting
- Minecraft clients on the LAN can discover the server in the Multiplayer menu
Author
Immyxxr
License
This project is licensed under the GNU General Public License v3.0 (GPL v3). For details, see the LICENSE file.
bStats
评论 0
登录后参与评分
还没有评论,来抢沙发吧