? DiscordStats — 嵌入您服务器中的 Discord Bot
DiscordStats 将功能完整的 Discord bot 直接嵌入到您的 Folia/Paper 插件中。只需将一个 .jar 文件放入 plugins/ 文件夹即可——无需 Node.js,无需额外的 HTTP 服务器,也无需运行单独的脚本。
? 描述
DiscordStats 以最简单的方式连接您的 Minecraft 服务器和 Discord 社区。所有数据在每次命令执行时都直接从 Bukkit 实时读取——调用之间不会在内存中存储任何内容。您的玩家和管理员可以随时通过三个斜杠命令直接从 Discord 查询服务器信息,而无需打开游戏。
该插件使用通过 Maven Shade 打包进 jar 文件的 JDA 5 (Java Discord API)。JDA 线程与 Folia 主线程之间的通信通过带有可配置超时的 CompletableFuture 处理,从而防止任何静默死锁。
✨ 特性
- ? 嵌入式 Discord bot —— 完全自包含,无需外部运行时环境
- ? 实时数据 —— 所有统计数据均在每次请求时直接从 Bukkit 获取
- ⚡ Folia 安全 —— 使用
GlobalRegionScheduler,无线程违规
- ? 启动时自动注册斜杠命令
- ? 支持离线玩家统计 —— 无需在线
- ? 报告 1分钟、5分钟、15分钟的 TPS
- ? 热重载 —— 通过
/dstats reload 实现,无需重启
- ? Adventure API —— 无已弃用的
ChatColor
- ? 丰富的彩色 Discord 嵌入消息
- ⏱️ 5秒超时 —— 当服务器负载过高时触发,避免静默冻结
? Discord 斜杠命令
| 命令 |
描述 |
/server |
TPS、内存使用情况、运行时间和世界信息 |
/players |
在线玩家列表,包含所在世界和延迟 |
/stats <player> |
任意玩家的完整统计信息,无论在线或离线 |
? 游戏内命令
| 命令 |
描述 |
/dstats reload |
热重载插件配置 |
⚙️ 配置
discord:
token: "" # 您的 Discord bot 令牌
guild-id: "" # 您的 Discord 服务器 ID
timeout: 5 # Bukkit 线程调用的超时时间(秒)
设置步骤:
- 前往 discord.dev/applications 并创建一个新的应用程序
- 添加一个 bot,启用所需的通知意图(intents),然后复制令牌
- 将令牌和您的公会 ID 粘贴到
config.yml 中
- 重启服务器或运行
/dstats reload
- 斜杠命令将自动注册
?️ 兼容性
| 平台 |
版本 |
| Paper |
1.21.x |
| Folia |
1.21.x |
| Java |
21+ |
| API |
Paper API 1.21.1-R0.1-SNAPSHOT |
? 安装
- 下载插件
- 将其放入服务器的
plugins/ 文件夹中
- 重启服务器
- 使用您的 bot 令牌和公会 ID 配置
plugins/DiscordStats/config.yml
- 斜杠命令会自动注册——无需手动设置
? DiscordStats — Discord Bot Embedded in Your Server
DiscordStats embeds a fully functional Discord bot directly into your Folia/Paper plugin. Drop a single .jar into your plugins/ folder — no Node.js, no secondary HTTP server, no separate script to run.
? Description
DiscordStats bridges your Minecraft server and your Discord community in the simplest way possible. All data is read live from Bukkit on every command — nothing is stored in memory between calls. Your players and admins can query the server directly from Discord using three slash commands, at any time, without ever opening the game.
The plugin uses JDA 5 (Java Discord API) bundled into the jar via Maven Shade. Communication between the JDA thread and Folia's main thread is handled through a CompletableFuture with a configurable timeout, preventing any silent deadlock.
✨ Features
- ? Embedded Discord bot — fully self-contained, no external runtime needed
- ? Live data — all stats are fetched directly from Bukkit on every request
- ⚡ Folia-safe — uses
GlobalRegionScheduler, no thread violations
- ? Slash commands registered automatically on startup
- ? Offline player stats supported — no need to be online
- ? TPS reported over 1min, 5min, 15min
- ? Hot reload via
/dstats reload — no restart needed
- ? Adventure API — no deprecated
ChatColor
- ? Rich colored Discord embeds
- ⏱️ 5s timeout if the server is under load — no silent freeze
? Discord Slash Commands
| Command |
Description |
/server |
TPS, memory usage, uptime and world info |
/players |
Online players list with world and ping |
/stats <player> |
Full stats for any player, online or offline |
? In-game Commands
| Command |
Description |
/dstats reload |
Hot reload the plugin configuration |
⚙️ Configuration
discord:
token: "" # Your Discord bot token
guild-id: "" # Your Discord server ID
timeout: 5 # Timeout in seconds for Bukkit thread calls
Setup:
- Go to discord.dev/applications and create a new application
- Add a bot, enable the required intents, and copy the token
- Paste the token and your guild ID in
config.yml
- Restart or run
/dstats reload
- Slash commands will register automatically
?️ Compatibility
| Platform |
Version |
| Paper |
1.21.x |
| Folia |
1.21.x |
| Java |
21+ |
| API |
Paper API 1.21.1-R0.1-SNAPSHOT |
? Installation
- Download the plugin
- Place it in your server's
plugins/ folder
- Restart the server
- Configure
plugins/DiscordStats/config.yml with your bot token and guild ID
- Slash commands are registered automatically — no manual setup needed
评论 0
登录后参与评分
还没有评论,来抢沙发吧