Minecraft 用 MongoDB Java 驱动
本仓库将官方 MongoDB Java 同步驱动(包含 mongodb-driver-sync 及其核心和 BSON 依赖)重新打包为 Bukkit/Spigot/Paper 插件以及 Fabric/Forge/NeoForge 模组。
该模组本身不执行任何操作。希望与 MongoDB 通信的其他插件或模组会通过软依赖(softdepend,或仅通过处于同一个类加载器)引入此模组,并通过标准的 MongoClients.create(...) API 使用驱动程序。
Jar 包内容
完整的同步驱动包:
org.mongodb:mongodb-driver-sync:5.3.1— API 接口(MongoClient、MongoCollection等)org.mongodb:mongodb-driver-core:5.3.1— 协议实现、连接池、服务器发现org.mongodb:bson:5.3.1— BSON 编解码器和文档模型org.mongodb:bson-record-codec:5.3.1— Java Record 支持
此外还包含了针对 Spigot、Forge 1.12、Forge 1.13–1.16、Forge 1.17–1.20、NeoForge 1.21+ 和 Fabric 的最小化加载器存根。类保持其规范路径 com.mongodb.* 和 org.bson.*——不进行重定位(relocation),因此消费者可以通过普通的 Class.forName 找到它们。
BSON 编解码器的服务文件通过 Shadow 的 mergeServiceFiles() 进行合并,以确保编解码器的自动发现功能正常工作。
兼容性
| 加载器 | MC 版本 | 备注 |
|---|---|---|
| Bukkit / Spigot / Paper / Folia / Purpur | 1.8 → 当前最新版 | 放入 plugins/ 目录 |
| Fabric | 1.16.1 → 当前最新版 | 需要 Fabric Loader 0.14+ |
| Forge | 1.12 → 1.20 | 通用 jar,无 Mixins |
| NeoForge | 1.21 → 当前最新版 | 放入 mods/ 目录 |
需要 Java 8+(driver 5.x 基线要求)。
在插件或模组中使用
compileOnly("org.mongodb:mongodb-driver-sync:5.3.1")
探测并连接:
try {
Class.forName("com.mongodb.client.MongoClients");
} catch (ClassNotFoundException e) {
getLogger().warning("MongoDB 后端已禁用 —— 请安装 minecraft-mongodb-driver");
return;
}
MongoClient client = MongoClients.create("mongodb://user:pass@host:27017/?authSource=admin");
在 Paper 1.17+ 中,请在你的 plugin.yml 中添加 softdepend: [minecraft-mongodb-driver],以便你的插件的类加载器能够看到这些类。
连接字符串包含了所有配置项——认证源、副本集成员、读取偏好、写入关注点。将所有设置放在 URI 中;除非你有特殊需求,否则不要尝试通过 MongoClientOptions 单独设置它们。
版本说明
Jar 包的版本号跟随上游同步驱动的版本。5.3.1+2026-04-25 表示包含 driver-sync 5.3.1 以及匹配的核心/BSON 版本;后缀部分是构建日期。自动更新每天针对 Maven Central 运行。
许可证
Apache 2.0 (MongoDB, Inc.)。重新打包未添加任何功能性更改。完整文本见 LICENSE。
问题反馈及源代码:GitHub。
MongoDB Java Driver for Minecraft
The official MongoDB Java sync driver (mongodb-driver-sync plus its core and BSON dependencies) repackaged as a Bukkit/Spigot/Paper plugin and a Fabric/Forge/NeoForge mod.
The mod does nothing on its own. Other plugins/mods that want to talk to MongoDB pick this up via softdepend (or just by being on the same classloader) and use the driver via the standard MongoClients.create(...) API.
What's in the jar
The full sync-driver bundle:
org.mongodb:mongodb-driver-sync:5.3.1— the API surface (MongoClient,MongoCollection, etc.)org.mongodb:mongodb-driver-core:5.3.1— wire-protocol implementation, connection pooling, server discoveryorg.mongodb:bson:5.3.1— BSON codecs and document modelorg.mongodb:bson-record-codec:5.3.1— Java record support
Plus minimal loader stubs for Spigot, Forge 1.12, Forge 1.13–1.16, Forge 1.17–1.20, NeoForge 1.21+, and Fabric. Classes stay at canonical com.mongodb.* and org.bson.* paths — no relocation — so consumers find them with plain Class.forName.
Service files for BSON codecs are merged via Shadow's mergeServiceFiles() so codec auto-discovery works.
Compatibility
| Loader | MC versions | Notes |
|---|---|---|
| Bukkit / Spigot / Paper / Folia / Purpur | 1.8 → current | drop into plugins/ |
| Fabric | 1.16.1 → current | needs Fabric Loader 0.14+ |
| Forge | 1.12 → 1.20 | universal jar, no Mixins |
| NeoForge | 1.21 → current | drop into mods/ |
Java 8+ required (driver 5.x baseline).
Using it from a plugin or mod
compileOnly("org.mongodb:mongodb-driver-sync:5.3.1")
Probe and connect:
try {
Class.forName("com.mongodb.client.MongoClients");
} catch (ClassNotFoundException e) {
getLogger().warning("MongoDB backend disabled — install minecraft-mongodb-driver");
return;
}
MongoClient client = MongoClients.create("mongodb://user:pass@host:27017/?authSource=admin");
On Paper 1.17+ add softdepend: [minecraft-mongodb-driver] to your plugin.yml so the classes are visible to your plugin's classloader.
Connection strings carry everything — auth source, replica set members, read preference, write concern. Put it all in the URI; don't try to set them via MongoClientOptions unless you're doing something unusual.
Versioning
The jar version tracks the upstream sync driver. 5.3.1+2026-04-25 ships driver-sync 5.3.1 plus matching core/bson; the suffix is the build date. Auto-bump runs daily against Maven Central.
License
Apache 2.0 (MongoDB, Inc.). The repackage adds no functional changes. Full text in LICENSE.
Issues, source: GitHub.
下载 Minecraft MongoDB Driver
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Minecraft MongoDB Driver
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Minecraft MongoDB Driver
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Minecraft MongoDB Driver
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Minecraft MongoDB Driver
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
ci:发布兼容 Fabric 游戏版本的 holders
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
插件
PacketEvents 是一款专为 Minecraft Java 版打造的协议库,旨在简化数据包的处理与传输。
插件
ExyliaPlugins 的库。
插件
为基于 Spigot/Paper/Folia 的服务器添加对 Vivecraft 的支持
插件
一个在游戏内运行的 Minecraft 地图编辑器! 支持选区、蓝图、复制粘贴、笔刷和脚本。 可在创造模式中使用,也可在生存模式中临时使用。
插件
SkyBlock、OneBlock、Boxed、SkyGrid、AcidIsland、CaveBlock、Poseidon、StrangerRealms——以及更多!这些只是由 BentoBox 支持的基于岛屿的游戏模式之一。来自原版 ASkyBlock 的作者。
插件
一个强大的 API,用于为你的 Minecraft 服务器创建自定义进度。
评论 0
登录后参与评分
还没有评论,来抢沙发吧