Discord 角色同步
DiscordRoleSync 是一个 Minecraft 插件,用于同步 Discord 角色和 Minecraft 权限。此同步仅从 Discord 到 Minecraft,不支持双向同步。
可以配置并链接受管理的 Discord 角色列表到 Minecraft 用户组。如果 Discord 用户获得了某个角色,他们将被添加到对应的 Minecraft 用户组中;如果该用户失去了这个角色,他们将从 Minecraft 用户组中被移除。
本插件支持使用 SQLite(自动创建,无需设置)或 MySQL。建议在大型服务器上使用 MySQL 以保证稳定性。
本插件已在 Minecraft 1.8.8 至 26.3 版本上经过测试。
功能
部分功能是可选的,可以在配置文件中选择开启或关闭。
- 将 Discord 角色同步到 Minecraft 用户组。用户将根据其在 Discord 中的角色被添加或移除出 Minecraft 用户组
- 为已绑定的用户添加 Discord 角色
- 使用 Discord 角色控制谁能访问你的服务器(白名单)
- 根据用户的 Minecraft 用户名更新其 Discord 昵称
- 与 PlaceholderAPI 集成
安装
首先你需要安装 Vault,因为没有它本插件将无法工作。你还应该安装一个权限插件,例如 LuckPerms 或其他兼容 Vault 的替代方案。
本插件需要 Java 17 或更高版本。
只需将 .jar 文件复制到 plugins 文件夹并运行一次服务器以生成配置文件。由于没有配置文件,插件在首次运行时会出现错误,这是预期的现象。进入 config.yml 文件并添加你的 Discord 机器人令牌 (token)。获取方法如下:
- 前往
- 点击“new application”并为你的机器人起个名字
- 在左侧边栏中,点击“Bot”
- 点击“add bot”并确认
- 在此页面上,你可以更改机器人的头像和用户名。
- 开启“Server Members Intent”(服务器成员意图)——如果不启用此项,机器人将无法正常工作,因为它需要处理成员列表
- 点击复制令牌并将其粘贴到配置文件中。任何拥有你令牌的人都可以登录为你的机器人,因此请像保管密码一样保密它。
- 返回 Discord 开发者网站,在左侧边栏中点击“OAuth2”
- 选择“bot”作为范围,然后复制链接
- 前往你刚刚复制的链接,将机器人添加到你的服务器
别忘了将所有角色放入配置中。你应该填入角色 ID,而不是角色名称。要获取 ID,你需要在 Discord 中启用开发者模式,然后右键点击角色并复制 ID(这是一串大约 18 位数字)。服务器 ID 和频道 ID 也是如此。
工作原理
非常简单:所有用户都应在 Discord 中使用 /link 命令来绑定他们的 Minecraft 账号:
/link myMCusername
一旦他们执行此操作,只要他们在服务器上,他们的角色就会保持同步。当你的用户获得 Discord 角色时,他们将自动获得权限插件的用户组。更新是实时的。
管理员还可以使用 /admlink 命令强制绑定用户:
/admlink discordID mcUsername
用户的 Discord ID 是一串 17 到 20 位的数字。
/info 和 /unlink 命令可供管理员使用。两者均接受 Discord ID 或 Minecraft 用户名。默认情况下,这三个管理命令对拥有 MANAGE ROLES(管理角色)Discord 权限的所有人开放。这可以在你的 Discord 服务器中进行修改。
用户必须留在 Discord 服务器中才能保持其角色。如果他们离开服务器或通过 /unlink 命令解除绑定,他们将被移出白名单,并且所有角色都会被移除。
如果启用了白名单管理(配置中 manageWhitelist: true),请使用 /whitelist off 或在 server.properties 中设置 white-list=false 来关闭原版白名单。否则,即使插件允许玩家进入,原版白名单仍会将他们踢出。自 Minecraft 26.3 起,新服务器的原版白名单默认处于开启状态。
如果启用了验证功能(配置中 requireVerification: true),用户在被白名单踢出时(如果启用了白名单管理)或在 Minecraft 聊天中输入 /drs verify 时会获得验证码。然后通过 Discord 中的 /verify <code> 发送此代码。
语言和翻译
目前支持(并随插件捆绑)的语言有:
- 英语 (en_US)
- 葡萄牙语 (pt_BR)
- 意大利语 (it_IT)
- 法语 (fr_FR)
- 西班牙语 (es_ES)
- 土耳其语 (tr_TR)
- 德语 (de_DE)
- 日语 (ja_JP)
- 俄语 (ru_RU)
如果你想添加自己的语言,可以复制 en_US.yml 文件并根据你的语言进行编辑。如果你希望你的翻译被捆绑到插件中,请通过 Discord 联系我或在 GitLab 上发起合并请求,我很乐意将其包含在内 :D
随着本插件更新的发布,只有英语和葡萄牙语会进行更新(因为这是我使用的语言)。其他语言可能会过时,并将默认使用英语。如果你愿意帮助更新这些语言,请告诉我!
权限插件
本插件应与所有支持 Vault 的权限插件兼容。
已测试并确认可用:
关于 PermissionsEx 的说明:我不推荐使用 PermissionsEx,因为它已被弃用且不支持异步权限添加。在大型服务器上使用它可能会导致性能下降。
权限节点
discordrolesync.reload:使用/drs reload命令discordrolesync.botrestart:使用/drs botrestart命令discordrolesync.notifyupdates:拥有此权限的用户在登录时,如果有可用更新,将会收到通知。discordrolesync.bypasswhitelist:当白名单启用时,拥有此权限的用户将始终被允许加入,即使他们尚未关联。请注意,对于大多数权限插件而言,要向用户添加权限,该用户必须首先尝试加入服务器。
所有用户均被允许使用 /drs verify 命令
集成
PlaceholderAPI
通过在配置文件中将 integrations.plugins.PlaceholderAPI 设置为 true,可以启用 PlaceholderAPI 集成。
这将允许机器人状态消息读取占位符变量。
它还为本插件启用了占位符扩展,支持以下占位符:
%drs_linked_users%:已关联用户的数量%drs_link_status%:用户是否已关联%drs_discord_username%:用户的 Discord 用户名(如果已关联)。如果未关联则为空。%drs_discord_display_name%:用户的 Discord 昵称(如果已关联)。如果未关联则为空。
PlaceholderAPI 集成为新功能,可能仍需进一步完善。如果您有需求或遇到 bug,请告知我。
Geyser
通过在配置文件中将 experimental.geyser.enableGeyserSupport 设置为 true,可以启用 Geyser 集成。
启用后,关联以点号开头(如 .exampleuser)的用户名将被视为 Geyser 用户。
这是一个实验性功能。如果您有需求或遇到 bug,请告知我。
功能请求、Bug 报告与贡献
本插件为开源项目!源代码可在 GitLab 找到。请参阅 CONTRIBUTING.md 获取更多信息。
非常欢迎贡献!我最近重新接手了本插件的支持工作,并正在整理代码。我不是 Java 专家,因此如果您愿意,可以自由进行代码清理和主观性改进方面的贡献。
如有需要,您可以通过 GitLab 或 Discord 联系我。如需报告 bug 或请求功能,您可以在 GitLab 上创建 Issue,或通过 Discord 联系我。
已知问题与限制
离线服务器模式
请注意,在离线模式服务器中,用户名的关联是区分大小写的。
虽然本插件可与离线服务器配合使用,但它可能会与您使用的“登录插件”发生冲突,这些插件会在用户加入后更改其 UUID。如果您使用了登录插件,请尝试使用 userUUIDMode 的 FALLBACK 或 MANUAL 选项。
如果您通过 UUID 模式配置或服务器模式切换在离线和在线模式之间来回切换,则需要删除数据库。如果您使用的是 SQLite,只需删除 database.db 文件即可。如果您使用的是 MySQL,请执行 DROP TABLE syncbot_discordmcusers;,如果在 config.yml 文件中更改了前缀,请将 syncbot 替换为您的自定义前缀。
Discord Role Sync
DiscordRoleSync is a Minecraft plugin for syncing Discord roles and Minecraft permissions. This syncs Discord to Minecraft only, it is not both ways.
A list of managed Discord roles can be configured and linked o Minecraft groups. If a Discord user gets a role added, they will get added to the Minecraft group. If the user gets the role removed, they will be removed from the Minecraft group.
This can use both SQLite (automatically created, no setup needed) or MySQL. MySQL is recommended for stability on large servers.
This plugin has been tested on Minecraft versions 1.8.8 to 26.3.
Features
Some features are optional and can be opted in or out from the config file.
- Sync roles from Discord to Minecraft groups. Users will be added/removed from Minecraft groups based on the Discord roles they have
- Add a Discord role to users that have been linked
- Control who can access your server (whitelist) using a Discord role
- Update user's Discord nicknames based on their Minecraft username
- Integration with PlaceholderAPI
Installation
You should first install Vault as this plugin will not work without it. You should also install a permissions plugin such as LuckPerms or another alternative compatible with Vault.
This plugin requires Java 17 or newer.
Just copy the .jar to the plugins folder and run the server once to generate the config files. The plugin will error out due to no config, but that's expected on the first run. Go to the config.yml file and add your Discord bot token. To get one:
- Go to
- Click "new application" and put a name for your bot
- In the left sidebar, click "Bot"
- Click "add bot" and confirm
- In this page, you can change your bot's picture and username.
- Turn on "Server Members Intent" - it won't work without this as the bot needs to work with the member list
- Click copy token and paste it in the config file. Anyone with your token can log in as your bot, so you should keep it secret as if it were a password.
- Go back to the Discord developer website and on the left sidebar, click "OAuth2"
- Select "bot" as a scope then copy the link
- Go to the link you just copied to add the bot to your server
Don't forget to put all roles in the configs. You should put the role IDs, not the role names. To get the ID you should enable developer mode in Discord, then right-click the role and copy ID (it's a number of approximately 18 digits). The same thing applies for the server ID and channel IDs.
How it Works
It's pretty simple: all your users should use the /link command in Discord to link their Minecraft account:
/link myMCusername
As soon as they do this, their roles will keep synchronized while they are in the server. When your users get the Discord role, they will automatically get the permission plugin group. Updates are instant.
Staff can also use the /admlink command to force link a user:
/admlink discordID mcUsername
The Discord ID of the user is a 17 to 20-digit number.
The /info and /unlink commands are available for staff use. Both accept Discord IDs or Minecraft usernames. By default, these three admin commands are available for everyone that has the MANAGE ROLES Discord permission. This can be modified in your Discord server.
The users need to remain in the Discord server to keep their roles. If they leave the server or are unlinked with the /unlink command, they are removed from the whitelist and every role is removed from them.
If whitelist management is enabled (manageWhitelist: true on the config), turn off the vanilla whitelist with /whitelist off or white-list=false in server.properties. Otherwise the vanilla whitelist will still kick players the plugin lets in. Since Minecraft 26.3, new servers have the vanilla whitelist on by default.
If verification is enabled (requireVerification: true on the config), users will either get the code when they are kicked by whitelist (if whitelist management is enabled) or by typing /drs verify in the Minecraft chat. This code then needs to be sent in Discord using /verify <code>.
Languages and Translation
Currently, the languages supported (and bundled with the plugin) are:
- English (en_US)
- Portuguese (pt_BR)
- Italian (it_IT)
- French (fr_FR)
- Spanish (es_ES)
- Turkish (tr_TR)
- German (de_DE)
- Japanese (ja_JP)
- Russian (ru_RU)
If you want to add your language, you can copy the en_US.yml file and edit it to your language. If you are interested in having your translation bundled with the plugin, please contact me via Discord or make a merge request on GitLab, I'll be happy to include it :D
As updates to this plugin are released, only English and Portuguese are updated (as those are the languages I speak). Other languages might get out of date and will use English as a default. Please let me know if you'd like to help update these languages!
Permission Plugins
This plugin should work with every permission plugin that supports Vault.
Tested and confirmed working:
- LuckPerms (recommended)
- Ultra Permissions
- PermissionsEx (deprecated)
- PowerRanks
A note on PermissionsEx: I do not recommend using PermissionsEx as it is deprecated and does not support asynchronous permission adding. Performance might be worse when using it in large servers.
Permission Nodes
discordrolesync.reload: Use the /drs reload commanddiscordrolesync.botrestart: Use the /drs botrestart commanddiscordrolesync.notifyupdates: Users with this permission will be notified when they join if an update is available.discordrolesync.bypasswhitelist: Users with this permission will always be admitted when the whitelist is enabled, even if they're not linked. Note that for most permissions plugins, to add a permission to the user they must first attempt to join.
All users are permitted to use the /drs verify command
Integrations
PlaceholderAPI
The PlaceholderAPI integration can be enabled by setting integrations.plugins.PlaceholderAPI to true in the config.
This will allow the Bot's status message to read from placeholders.
It also enables a Placeholder Expansion for this plugin, with the following placeholders supported:
%drs_linked_users%: the number of linked users%drs_link_status%: if the user is linked or not%drs_discord_username%: the Discord username of the user, if linked. Empty if not linked.%drs_discord_display_name%: the Discord nick of the user, if linked. Empty if not linked.
PlaceholderAPI integration is new and might still need some improvements. Please let me know if you have a request or bug report.
Geyser
The Geyser integration can be enabled by setting experimental.geyser.enableGeyserSupport to true in the config.
When enabled, linking to a username that starts with a dot (.exampleuser) will be treated as a Geyser user.
This is an experimental feature. Please let me know if you have a request or bug report.
Feature Requests, Bug Reports and Contributions
This plugin is open source! The source code can be found on GitLab. Please see CONTRIBUTING.md for more information.
Contributions are more than welcome! I've recently picked up support for this plugin again, and am in the process of cleaning up the code. I'm not a Java expert, so feel free to make clean-up, opinionated contributions if you'd like.
If needed, you can reach me via GitLab or Discord. To report bugs or request features, you can either create an issue in GitLab or contact me via Discord.
Known Issues and Limitations
Offline Server Mode
Please node that in offline mode servers, linking usernames is case-sensitive.
While this plugin works with offline servers, it might conflict with "login plugins" that change a user's UUID after they join. Please try the userUUIDMode FALLBACK or MANUAL options if you use login plugins.
If you swap between offline and online (or vice-versa), either via the UUID mode config or server mode change, you'll need to delete the database. If you are using SQLite, just delete the database.db file. If you are using MySQL, execute DROP TABLE syncbot_discordmcusers;, replacing syncbot with the prefix in your config.yml file if you have changed it.
下载 Discord Role Sync
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Discord Role Sync
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Discord Role Sync
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Discord Role Sync
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Discord Role Sync
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Discord Role Sync
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Discord Role Sync
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Discord Role Sync
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Discord Role Sync
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Discord Role Sync
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
新增
- 正式支持最高至 Minecraft 26.3 的版本
- 插件现在会创建一个
<tablePrefix>_schema_history表来跟踪数据库升级。未来版本将拒绝在由更高版本升级的数据库上启动 - 当启用白名单管理但原版白名单也处于开启状态时,会在启动时发出警告(该状态会将插件允许进入的玩家踢出)。Minecraft 26.3+ 的新服务器默认开启了原版白名单
更改
- 破坏性更新: 现在需要 Java 17 或更高版本。运行 Java 8 或 11 的服务器必须在更新插件前升级 Java
- 更新 JDA(Discord 库)至 6.7.0,以支持 Discord 的频道混淆功能(自 2026 年 11 月 16 日起强制要求)
- 更新依赖项
- 插件 JAR 包体积更小(减少约 4 MB,现低于 5 MB)
- 配置验证现在会拒绝包含非字母、数字和下划线的
database.tablePrefix,以及包含非字母、数字、下划线和连字符的language - 内部维护:CI 和构建改进
修复
/drs reload现在会验证 config.yml,如果配置无效则保留之前的配置,而不是加载它并导致链接和白名单功能损坏- 机器人缺少“管理角色”权限时的启动警告现在能正常显示
- 修复了数据库查询失败时 MySQL 连接泄漏的问题,这可能导致连接池耗尽并最终使链接功能失效
- Modrinth 不再将 Folia 列为支持平台,因为该插件无法在 Folia 上运行
- 内置翻译(如葡萄牙语)中的带重音符号的字符,在非 UTF-8 系统编码的服务器(如许多 Windows 服务器)上不再显示为乱码
- 已链接的成员如果在 Discord 服务器中离开、被踢或被封禁,即使机器人尚未缓存他们,也会从白名单中移除
- 当 Mojang 或 GeyserMC API 停止响应时,Discord 链接和查找命令不再无限期挂起。它们现在会在 10 秒后超时并显示错误
- 插件现在可以安全地使用
/reload或 PlugMan 重新加载。之前,重新加载会导致 MySQL 连接未关闭且 SQLite 数据库文件被锁定
新增
- 官方支持 1.21.6 和 1.21.7
更改
- 更新了依赖项
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
插件
ExyliaPlugins 的库。
插件
重新定义服务器上的生物运输方式。使用高度可定制的口袋道具,安全地捕获、存储和释放任何实体。
插件
一个在游戏内运行的 Minecraft 地图编辑器! 支持选区、蓝图、复制粘贴、笔刷和脚本。 可在创造模式中使用,也可在生存模式中临时使用。
插件
创建用户友好的菜单以前往不同的世界
插件
专为 Velocity 打造的自制聊天插件,功能丰富——支持跨服群组/全局/私聊消息,并集成 LibertyBans 的禁言功能。
插件
一个高度兼容、功能完善且稳定的 TPA 模组
评论 0
登录后参与评分
还没有评论,来抢沙发吧