Magnus (服务端)
一个模块化、高性能且具备弹性的 Minecraft Fabric 服务器同步套件。支持实时物品栏同步、跨服聊天和全局玩家管理。
功能
核心同步
- 多服务器同步:同步物品栏、末影箱、生命值、饥饿值、经验值和药水效果。
- 高性能:使用 Redis 实现亚毫秒级数据检索。
- 持久化存储:使用 PostgreSQL 进行永久可靠存储。
- 容错性:
- 熔断机制:自动检测数据库故障。
- 本地回退:当数据库宕机时,将数据保存到磁盘。
- 自动恢复:“清洁工”服务在数据库重新上线后自动恢复数据。
模块
| 模块 | 描述 |
|---|---|
| 物品栏同步 | 核心同步物品栏、末影箱、生命值、饥饿值、经验值和药水效果。默认启用。 |
| 全球聊天 | 通过 Redis pub/sub 在所有服务器间同步聊天消息。使用纯文本格式以兼容 LuckPerms、Stylist 等插件。 |
| 全球玩家列表 | 维护带有心跳机制的全局玩家计数。提供 /glist 命令。 |
| 会话锁定 | 通过在同步期间锁定玩家会话来防止并发登录。玩家将保持在队列中,直到其数据安全传输完毕。 |
安全性
| 特性 | 默认值 | 描述 |
|---|---|---|
| 消息签名 | ✅ 已启用 | HMAC-SHA256 防止消息注入攻击 |
| 自动生成密钥 | ✅ | 首次运行时生成 32 字节加密密钥 |
| 防重放攻击 | 30 秒 | 拒绝超过 30 秒的旧消息 |
| 载荷大小限制 | 64KB | 防止通过超大消息实施 DoS 攻击 |
| SSL/TLS 支持 | 可选 | 加密 Redis 连接 |
配置
Magnus 需要 PostgreSQL 数据库和 Redis 实例才能运行。
- 生成配置:启动服务器一次以在
config/magnus.json生成默认配置文件。 - 编辑配置:停止服务器并打开
config/magnus.json:
{
"postgresUrl": "jdbc:postgresql://your-db-host:5432/magnus",
"postgresUser": "your_user",
"postgresPass": "your_password",
"redisHost": "your-redis-host",
"redisPort": 6379,
"redisPass": null,
"serverName": "survival",
"enableInventorySync": true,
"enableGlobalChat": false,
"enableGlobalPlayerList": false,
"enableSessionLock": false,
"enableMessageSigning": true,
"messageSigningSecret": "auto-generated-on-first-run",
"redisSsl": false
}
- 启动:重启服务器。Magnus 将自动验证连接并创建必要的数据库结构。
[!IMPORTANT] 多服务器设置:从第一个服务器复制
messageSigningSecret到所有其他服务器。所有服务器必须使用相同的密钥。
配置选项
| 选项 | 默认值 | 描述 |
|---|---|---|
serverName |
"default" |
此服务器的唯一标识符(例如 "survival", "lobby") |
enableInventorySync |
true |
启用物品栏/玩家数据同步。大厅服务器建议禁用。 |
enableGlobalChat |
false |
启用跨服聊天同步 |
enableGlobalPlayerList |
false |
启用全局玩家列表和 /glist 命令 |
enableSessionLock |
false |
启用会话锁定以防止并发登录 |
enableMessageSigning |
true |
启用 HMAC 消息签名(推荐) |
redisSsl |
false |
为 Redis 连接启用 SSL/TLS |
命令
| 命令 | 描述 |
|---|---|
/glist |
显示总玩家数量及按服务器分组的玩家列表(需要 enableGlobalPlayerList) |
架构
有关详细的流程图和行为文档:
- 核心同步流程 - 数据同步与容错
- 全球聊天流程 - 跨服聊天消息传递
- 全球玩家列表流程 - 玩家列表心跳与
/glist - 会话锁定流程 - 登录队列与会话锁定
- 消息安全流程 - HMAC 签名与防重放
- 服务器生命周期流程 - 启动与关闭序列
Magnus (Server-Side)
A modular, high-performance, and resilient synchronization suite for Minecraft Fabric servers. Features real-time inventory sync, cross-server chat, and global player management.
Features
Core Sync
- Multi-Server Sync: Syncs Inventory, Ender Chest, Health, Hunger, XP, Potion Effects.
- High Performance: Uses Redis for sub-millisecond data retrieval.
- Persistence: Uses PostgreSQL for permanent reliable storage.
- Fault Tolerance:
- Circuit Breaker: Detects database failures automatically.
- Local Fallback: Saves data to disk if the database goes down.
- Auto-Recovery: "The Janitor" service automatically restores data when the database comes back online.
Modules
| Module | Description |
|---|---|
| Inventory Sync | Core synchronization of inventory, ender chest, health, hunger, XP, and potion effects. Enabled by default. |
| Global Chat | Syncs chat messages across all servers via Redis pub/sub. Raw text format for compatibility with LuckPerms, Stylist, etc. |
| Global Player List | Maintains a global player count with heartbeat. Provides /glist command. |
| Session Lock | Prevents concurrent logins by locking player sessions during sync. Players are held in queue until their data is safely transferred. |
Security
| Feature | Default | Description |
|---|---|---|
| Message Signing | ✅ Enabled | HMAC-SHA256 prevents message injection attacks |
| Auto-Generated Secret | ✅ | 32-byte cryptographic secret generated on first run |
| Replay Prevention | 30 sec | Messages older than 30 seconds are rejected |
| Payload Size Limits | 64KB | Prevents DoS via oversized messages |
| SSL/TLS Support | Optional | Encrypt Redis connections |
Configuration
Magnus requires a PostgreSQL database and a Redis instance to function.
- Generate Config: Start your server once to generate the default configuration file at
config/magnus.json. - Edit Config: Stop the server and open
config/magnus.json:
{
"postgresUrl": "jdbc:postgresql://your-db-host:5432/magnus",
"postgresUser": "your_user",
"postgresPass": "your_password",
"redisHost": "your-redis-host",
"redisPort": 6379,
"redisPass": null,
"serverName": "survival",
"enableInventorySync": true,
"enableGlobalChat": false,
"enableGlobalPlayerList": false,
"enableSessionLock": false,
"enableMessageSigning": true,
"messageSigningSecret": "auto-generated-on-first-run",
"redisSsl": false
}
- Launch: Restart your server. Magnus will automatically verify the connection and create the necessary database schema.
[!IMPORTANT] Multi-Server Setup: Copy the
messageSigningSecretfrom the first server to all other servers. All servers must use the same secret.
Configuration Options
| Option | Default | Description |
|---|---|---|
serverName |
"default" |
Unique identifier for this server (e.g., "survival", "lobby") |
enableInventorySync |
true |
Enable inventory/player data synchronization. Disable for lobby servers. |
enableGlobalChat |
false |
Enable cross-server chat synchronization |
enableGlobalPlayerList |
false |
Enable global player list and /glist command |
enableSessionLock |
false |
Enable session locking to prevent concurrent logins |
enableMessageSigning |
true |
Enable HMAC message signing (recommended) |
redisSsl |
false |
Enable SSL/TLS for Redis connections |
Commands
| Command | Description |
|---|---|
/glist |
Shows total player count and players grouped by server (requires enableGlobalPlayerList) |
Architecture
For detailed flow diagrams and behavior documentation:
- Core Sync Flow - Data synchronization and fault tolerance
- Global Chat Flow - Cross-server chat messaging
- Global Player List Flow - Player list heartbeat and
/glist - Session Lock Flow - Login queue and session locking
- Message Security Flow - HMAC signing and replay prevention
- Server Lifecycle Flow - Startup and shutdown sequence
下载 Magnus
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Magnus
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Magnus
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Magnus
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Magnus
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Magnus
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Magnus
下载 Magnus
下载 Magnus
下载 Magnus
1.4.2 (2026-09-06)
构建系统
- 依赖: 将 actions/labeler 从 6 升级至 7 (07ca77b)
- 依赖: 将 actions/labeler 从 6 升级至 7 (576a024)
- 依赖: 将 actions/setup-java 从 5 升级至 6 (b009b08)
- 依赖: 将 actions/setup-java 从 5 升级至 6 (3bf5980)
- 依赖: 将 github/codeql-action 从 4 升级至 4.37.4 (ff6abd6)
- 依赖: 将 github/codeql-action 从 4 升级至 4.37.4 (4ed3c2d)
- 依赖: 将 github/codeql-action 从 4.37.4 升级至 4.37.9 (f85deab)
- 依赖: 将 github/codeql-action 从 4.37.4 升级至 4.37.9 (364d98f)
- 依赖: 在 minor-and-patch 组中将 gradle-wrapper 从 9.7.0 升级至 9.7.1 (463b4a4)
- 依赖: 在 minor-and-patch 组中升级 gradle-wrapper (1761d55)
- 依赖: 将 gradle/actions 从 6 升级至 6.2.0 (e4458f2)
- 依赖: 将 gradle/actions 从 6 升级至 6.2.0 (c5a5c1e)
- 依赖: 将 gradle/actions 从 6.2.0 升级至 6.3.0 (5aa5ae7)
- 依赖: 将 gradle/actions 从 6.2.0 升级至 6.3.0 (ed3b404)
- 依赖: 在 minor-and-patch 组中应用 2 项更新 (db39aee)
- 依赖: 在 minor-and-patch 组中应用 2 项更新 (a2e6034)
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
缓冲的原始输入和线程化的事件轮询
模组
一个用于收集生物掉落物的多区块模组。
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
原版世界生成优化模组
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
查看物品与配方
评论 0
登录后参与评分
还没有评论,来抢沙发吧