
ServerAPI 是一个高性能的 REST API 插件,通过安全且受令牌保护的接口,提供实时的 Minecraft 服务器指标、玩家统计信息以及第三方插件数据。

它通过在单独的线程上运行异步 HTTP 服务器来工作,并使用反射技术安全地获取深层服务器信息,而不会影响游戏性能或 TPS(每秒刻数)。
使用指南
-
安装与构建
将 ServerAPI-1.0.jar 放入你的 plugins 文件夹。
启动服务器以生成 config.yml 配置文件。
-
API 端点与数据说明
状态 (GET /status)
提供服务器的总体概览:
- online: 服务器在线状态。
- version: 服务器软件版本。
- paper_version: 具体实现版本。
- players: 包含在线人数和最大人数的子对象。
- tps: 当前每秒刻数(1 分钟平均值)。
- mspt: 每刻毫秒数(平均值)。
- uptime: 服务器总运行时间(秒)。
- worlds: 已加载的世界名称列表。
性能 (GET /performance)
详细的资源与健康指标:
- tps: 精确的 1 分钟、5 分钟和 15 分钟平均值。
- mspt: 平均刻时间(高度准确)。
- lag_warning: 布尔值,如果 TPS 低于 18.0 则标记为 true。
玩家信息 (GET /player/{name})
针对在线和离线玩家的全面数据:
- name, uuid, online status: 名称、UUID、在线状态。
- lastSeen: 可读的时间格式(例如,“2 小时前”)。
- playtime: 格式化后的总游玩时间(小时)。
- kills / deaths: 安全统计数据(如果数据尚未加载/追踪,则安全返回 0)。
- money: 使用 Vault 插件格式化显示的余额。
- alts: 来自 EssentialsX 的 IP 匹配的小号账号。
- crates: 特定箱子类型的列表,以及玩家拥有的虚拟钥匙数量。
其他端点
- /misc/balancetop: 最富有的前 10 名玩家(基于配置缓存)。
- /misc/statistics: 击杀/死亡总数的全球前 10 名(已缓存)。
- /misc/warps: 所有可用的 EssentialsX 传送点。
- /misc/crates: 所有注册的 ExcellentCrates ID。
- /misc/projectkorra: 按元素分组的所有 bending 能力。
配置 (config.yml)
- 安全性: 所有请求都需要
Authorization: Bearer YOUR_TOKEN。
- 开关: 上述每个端点和子端点都可以单独禁用。
- 缓存: 像 BalTop 和全局统计这类重度查询具有可配置的缓存持续时间(默认 5 分钟),以保护服务器的 TPS。
- 异步: API 在单独的线程池上运行,确保对 Minecraft 服务器性能零影响。
一张展示该插件用例示例的图片:


ServerAPI is a high-performance REST API plugin that exposes real-time Minecraft server metrics, player statistics, and third-party plugin data through a secure, token-protected interface.

It works by running an asynchronous HTTP server on a separate thread, using reflection to safely retrieve deep server information without impacting game performance or TPS.
Usage Guide
1.Installation & Build
Place ServerAPI-1.0.jar into your plugins/folder.
Start the server to generate the config.yml
- API Endpoints & Data Info
Status (GET /status)
Provides a general overview of the server:
- online: Server accessibility status.
- version: Server software version.
- paper_version: Specific implementation version.
- players: Sub-object containing online and max counts.
- tps: Current Ticks Per Second (1-minute average).
- mspt: Milliseconds Per Tick (Average).
- uptime: Total server uptime in seconds.
- worlds: List of loaded world names.
Performance (GET /performance)
Detailed resource and health metrics:
- tps: Precise 1m, 5m, and 15m averages.
- mspt: Average tick time (highly accurate).
- lag_warning: Boolean that flags true if TPS drops below 18.0.
Player Info (GET /player/{name})
Comprehensive data for online and offline players:
- name, uuid, online status.
- lastSeen: Human-readable time (e.g., "2 hours ago").
- playtime: Formatted total time in hours.
- kills / deaths: Secure stats (safely returns 0 if data isn't loaded/tracked yet).
- money: Formatted balance using Vault.
- alts: IP-matched alt accounts from EssentialsX.
- crates: List of specific crate types and how many virtual keys the player owns.
Miscellaneous Endpoints
- /misc/balancetop: Top 10 richest players (cached based on config).
- /misc/statistics: Global Top 10 for kills/deaths (cached).
- /misc/warps: All available EssentialsX warps.
- /misc/crates: All registered ExcellentCrates IDs.
- /misc/projectkorra: All bending abilities grouped by element.
Configuration (config.yml)
- Security: All requests require Authorization: Bearer YOUR_TOKEN.
- Toggles: Every endpoint and sub-endpoint listed above can be individually disabled.
- Caching: Heavy lookups like BalTop and Global Stats have configurable cache durations (default 5 mins) to protect your server's TPS.
- Asynchronous: The API runs on a separate thread pool to ensure zero impact on your Minecraft server performance.
An image that gives an example of a use-case of the plugin:

评论 0
登录后参与评分
还没有评论,来抢沙发吧