REST HTTP API
一个 Minecraft Paper 插件,允许通过 HTTP 请求执行服务器命令并获取各种信息。非常适合将外部工具、Web 仪表板或自动化脚本与你的 Minecraft 服务器集成。
功能
- 通过 HTTP API 执行 Minecraft 命令
- 用于服务器信息的 RESTful 端点
- Bearer token 身份验证
- 支持离线玩家的命令队列
- 支持在等待玩家加入后再执行命令
- 自动生成交互式 API 文档
要求
- 运行 Paper 或其分支(Spigot、Bukkit 可能可用,但未经过测试)的 Minecraft 服务器
- Java 17 或更高版本
安装
从发布版安装
- 从 Releases 页面下载最新版本
- 将
http-commands-*.jar 文件放入服务器的 plugins 文件夹中
- 重启或重载服务器
从源码构建
# 克隆仓库
git clone https://github.com/lelenaic/minecraft-http-commands-plugin.git
cd http-commands-plugin
# 构建插件
./gradlew build
# JAR 文件将位于 build/libs/ 目录中
cp build/libs/http-commands-*.jar /path/to/server/plugins/
配置
首次启动后,插件会创建 plugins/http-commands/config.yml 文件。
安全建议
- 更改 bearer token - 使用强随机字符串
- 使用 HTTPS - 始终使用带有 TLS/SSL 的反向代理
- 防火墙 - 如果可能,仅允许受信任的 IP 访问
配合反向代理使用(推荐)
在生产环境中,请使用带有 HTTPS 的反向代理(如 Nginx 或 Caddy):
Nginx 示例:
server {
listen 443 ssl;
server_name mc-api.example.com;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
API 文档
交互式 API 文档由 OpenAPI 规范生成。
你可以从这里访问 API 文档:
生成文档
# 生成 HTML API 文档
./gradlew openApiGenerate
# 输出将位于 docs/index.html
查看文档
在 Web 浏览器中打开 docs/index.html 以查看交互式 Swagger UI。
文档包括:
- 所有可用的端点
- 请求/响应模式
- 示例请求
- Try-it-out 功能
命令
/http-commands reload
重载插件配置并重启 HTTP 服务器。
/http-commands reload
需要权限:httpcommands.reload
构建
# 构建插件
./gradlew build
# 构建并生成 API 文档
./gradlew build openApiGenerate
输出的 JAR 文件将位于 build/libs/ 目录中。
许可证
MIT License
REST HTTP API
A Minecraft Paper plugin that allows executing server commands via HTTP requests and get various information. Perfect for integrating external tools, web dashboards, or automation scripts with your Minecraft server.
Features
- Execute Minecraft commands via HTTP API
- RESTful endpoints for server information
- Bearer token authentication
- Command queuing for offline players
- Support for waiting for players to join before executing commands
- Auto-generated interactive API documentation
Requirements
- Minecraft Server running Paper or a Paper fork (Spigot, Bukkit may work but not tested)
- Java 17 or higher
Installation
From Release
- Download the latest release from the Releases page
- Drop the
http-commands-*.jar file into your server's plugins folder
- Restart or reload your server
From Source
# Clone the repository
git clone https://github.com/lelenaic/minecraft-http-commands-plugin.git
cd http-commands-plugin
# Build the plugin
./gradlew build
# The JAR file will be in build/libs/
cp build/libs/http-commands-*.jar /path/to/server/plugins/
Configuration
After first launch, the plugin creates plugins/http-commands/config.yml.
Security Recommendations
- Change the bearer token - Use a strong, random string
- Use HTTPS - Always use a reverse proxy with TLS/SSL
- Firewall - Only allow access from trusted IPs if possible
Using with a Reverse Proxy (Recommended)
For production, use a reverse proxy like Nginx or Caddy with HTTPS:
Nginx example:
server {
listen 443 ssl;
server_name mc-api.example.com;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
API Documentation
Interactive API documentation is generated from the OpenAPI specification.
You can access the API documentation from here:
Generating Documentation
# Generate HTML API documentation
./gradlew openApiGenerate
# Output will be in docs/index.html
Viewing Documentation
Open docs/index.html in a web browser to view the interactive Swagger UI.
The documentation includes:
- All available endpoints
- Request/response schemas
- Example requests
- Try-it-out functionality
Commands
/http-commands reload
Reloads the plugin configuration and restarts the HTTP server.
/http-commands reload
Requires permission: httpcommands.reload
Building
# Build the plugin
./gradlew build
# Build and generate API docs
./gradlew build openApiGenerate
The output JAR will be in build/libs/.
License
MIT License
评论 0
登录后参与评分
还没有评论,来抢沙发吧