MC Flarum Bridge
它是什么
McFlarumBridge 是 Minecraft 服务器与 Flarum 论坛之间的双向桥梁。公共论坛讨论会被中继到游戏中,而游戏内的命令允许玩家绑定账号并将他人举报至审核面板——因此版主可以在论坛界面中工作,而不是操作数据库。
两个部分
该仓库包含一个 Flarum 扩展(PHP 8.1+ / Flarum 2.x)和 Minecraft 端,两者共享同一个通信协议。
Minecraft 端 — 两个工件
从 0.0.19 版本开始,单个 jar 文件不再涵盖所有内容:
| 文件 |
安装位置 |
运行环境 |
McBridge-<version>.jar |
plugins/ |
Paper 和 Folia 1.21.x |
McBridge-neoforge-<version>.jar |
mods/ |
NeoForge 21.1.x for Minecraft 1.21.1(仅限服务端) |
两者均编译自同一个平台无关的核心模块 (cn.stalir.mcbridge, Java 17 字节码)。核心模块刻意不依赖任何特定平台的库——甚至不包括 Adventure,因为 Paper 自带了它,而 Minecraft 1.21.1 没有。核心模块渲染自己的 Message 对象,并在交付时由各平台进行转换(Paper → Adventure,NeoForge → net.minecraft.network.chat.Component)。NeoForge 位于其独立的 Gradle 项目中,以便 ModDevGradle 管理 Minecraft 依赖关系,确保核心模块在编译类路径中永远看不到它。Velocity 支持已在 0.0.19 版本中移除。
功能
- 论坛 → 游戏。 选定标签下的新讨论会被排队轮询,然后通过聊天、动作栏、标题和 Boss 条的任何组合在游戏内广播。
- 账号绑定。
/bind 会生成一次性代码,玩家需在论坛上输入该代码;绑定后的账号会显示在个人资料页以及帖子作者旁边的徽章上。
- 玩家举报。
/report <player> <reason> 会在可配置的举报标签下创建一篇讨论,并将其记录在 mc_reports 表中。它可以附加被举报玩家最近的公开聊天内容(默认 10 行;仅限公开聊天——绝不包括私信或命令),并渲染在一个代码块中,其大小经过调整,使得玩家无法通过输入反引号将其破坏。
- 举报进度。
/report status 列出玩家自己的举报及其状态,范围限定为其 UUID 和服务器。
- 举报结果。 关闭举报——通过将讨论移至“已解决”/“已拒绝”标签,或使用
php flarum mc-bridge:report <id> --status=...——会以定向出站消息的形式向举报者发送一次游戏内通知。
- 管理功能。
/mcbridge news|outbox|broadcast|stats|reload,以及用于密钥、设置、举报和完整链接自检的论坛控制台命令。
- 国际化 (i18n)。 论坛 (
locale/) 和游戏 (lang/) 翻译是独立的,且默认均为简体中文,并进行键值一致性检查。
- 安全性。 每个机器端点均使用 HMAC-SHA256 进行身份验证,签名内容为
{timestamp}\n{nonce}\n{METHOD}\n{path}\n{body},窗口期为 ±300 秒,采用单次使用的 nonce、恒定时间比较,且路径从 /api/mc-bridge 开始计算,以便子目录安装也能正常工作。玩家进度查询进行了范围限制,确保玩家只能读取自己的举报。
验证
静态检查器 (tools/verify.mjs, 384 项检查)、针对模拟 Flarum 的协议套件 (tools/protocol-test.mjs, 46 项检查) 以及 JVM 内部自检 (SelfTest, 77 项检查) 与两个项目的真实 Gradle 构建并行运行;CI 会运行所有这三项测试。发布基于标签驱动,并发布两个 jar 文件。
当前状态
版本 0.0.21,已发布在 GitHub Releases 和 Packagist 上,包名为 stalirmc/mc-flarum-bridge。诚实地说,未经充分验证:NeoForge 模组从未在真实服务器上加载过,Folia 仅是编译即断言(compile-and-assert),而基于标签的举报结果依赖于框架源码而非实时论坛。详细信息请参阅 README.md 和 VERIFICATION.md。
MC Flarum Bridge
What it is
McFlarumBridge is a bidirectional bridge between a Minecraft server and a Flarum forum. Public forum discussions are relayed into the game, and in-game commands let players link accounts and report others to a moderation board — so moderators work in the forum UI instead of a database.
Two halves
The repository ships a Flarum extension (PHP 8.1+ / Flarum 2.x) and the Minecraft side, sharing one wire protocol.
Minecraft side — two artifacts
Since 0.0.19 a single jar no longer covers everything:
| File |
Install into |
Runs on |
McBridge-<version>.jar |
plugins/ |
Paper and Folia 1.21.x |
McBridge-neoforge-<version>.jar |
mods/ |
NeoForge 21.1.x for Minecraft 1.21.1 (server side only) |
Both are compiled from one platform-neutral core (cn.stalir.mcbridge, Java 17 bytecode). The core deliberately depends on nothing platform-specific — not even Adventure, because Paper ships it and Minecraft 1.21.1 does not. It renders its own Message and each platform converts at delivery time (Paper → Adventure, NeoForge → net.minecraft.network.chat.Component). NeoForge lives in its own Gradle project so ModDevGradle owns the Minecraft dependency and the core never sees it on the compile classpath. Velocity support was removed in 0.0.19.
Features
- Forum → game. New discussions under selected tags are queued and polled, then announced in-game through any combination of chat, action bar, title, and boss bar.
- Account linking.
/bind issues a one-time code that the player consumes in the forum; the bound account is shown on the profile page and as a badge next to post authors.
- Player reports.
/report <player> <reason> files a discussion under configurable report tags and records it in mc_reports. It can attach the reported player's own recent public chat (default 10 lines; public chat only — never private messages or commands), rendered inside a code fence sized so a player typing backticks cannot break out of it.
- Report progress.
/report status lists the player's own reports and their state, scoped to their UUID and server.
- Report outcome. Closing a report — by moving its discussion into a "resolved"/"rejected" tag, or with
php flarum mc-bridge:report <id> --status=... — notifies the reporter in game exactly once, through a targeted outbox message.
- Administration.
/mcbridge news|outbox|broadcast|stats|reload, plus forum console commands for the secret, settings, reports, and a full-link self test.
- i18n. Forum (
locale/) and game (lang/) translations are independent and both default to Simplified Chinese, with key-parity checks.
- Security. Every machine endpoint is authenticated with HMAC-SHA256 over
{timestamp}\n{nonce}\n{METHOD}\n{path}\n{body}, with a ±300 s window, single-use nonces, constant-time comparison, and paths measured from /api/mc-bridge so a sub-directory install works unchanged. Player progress queries are scoped so a player can only read their own reports.
Verification
A static checker (tools/verify.mjs, 384 checks), a protocol suite against a mock Flarum (tools/protocol-test.mjs, 46 checks), and an in-JVM self test (SelfTest, 77 checks) run alongside real Gradle builds of both projects; CI runs all three. Releases are tag-driven and publish both jars.
Current state
Version 0.0.21, published on GitHub Releases and Packagist as stalirmc/mc-flarum-bridge. Honestly unverified: the NeoForge mod has never been loaded by a real server, Folia is compile-and-assert only, and the tag-driven report outcome rests on framework source rather than a live forum. Details are in README.md and VERIFICATION.md.
评论 0
登录后参与评分
还没有评论,来抢沙发吧