Requests

插件

· 作者 theMackabu

你 Minecraft 服务器的 API

0 本站下载 0 关注 更新于 3 年前

最新 0.1.0 · 1.19.4 · Paper

一键开服(送7天)

Requests - Minecraft 服务器的 REST API

Requests 是一个 PaperMC 插件,为 Minecraft 服务器提供 RESTful API。通过 Requests,服务器管理员可以使用简单的 REST 语义轻松查询和与服务器进行交互。

功能

  • 适用于 Minecraft 服务器的 RESTful API
  • 查询服务器信息,如玩家数量和服务器状态
  • 向服务器发送命令
  • 使用 API 密钥对请求进行身份验证
  • 易于使用和集成

用法

Requests 提供了一个可通过 HTTP 请求访问的 RESTful API。API 的基础 URL 为 http://localhost:5000,可在 config.toml 中进行配置。

[plugin]
salt = "change this"
prefix = "<light_purple>[requests]<reset> "

[database]
tokens = "tokens.db"
players = "players.db"

[api]
port = 5000
vault = false
luckperms = false

身份验证

Requests 使用 API 密钥来验证请求的身份。要生成主 API 密钥,请在服务器控制台中使用以下命令:

/api generate-key <name>

<name> 参数是可选的,可用于给密钥指定自定义名称。生成的 API 密钥将在控制台中显示。

要在游戏中生成玩家 API 密钥,请使用以下命令:

/api token new

要对请求进行身份验证,请在 HTTP 请求的 Authorization 标头中包含 API 密钥:

Authorization: Bearer <api_key>

API 端点

Requests 提供以下 API 端点:

GET /server

返回 Minecraft 服务器的状态。

GET /players

返回 Minecraft 服务器上在线玩家的列表。

GET /player/<uniqueId>

返回玩家的信息。

POST /command

向 Minecraft 服务器发送命令。此路由仅允许使用管理员令牌,默认情况下已禁用。

示例请求

获取服务器状态

GET /server HTTP/.1
Authorization: Bearer <api_key>
User-Agent: Example Agent/0.0.1

获取玩家资料

GET /player/<uniqueId> HTTP/1.1
Authorization: Bearer <api_key>
User-Agent: Example Agent/0.0.1

发送命令

POST /command HTTP/1.1
Authorization: Bearer <api_key>
Content-Type: application/json; charset=utf-8
User-Agent: Example Agent/0.0.1
Content-Length: 31

{"command":"say Hello, World!"}

构建

要从源代码构建 Requests,请按照以下步骤操作:

  1. 克隆仓库:git clone https://github.com/theMackabu/requests.git
  2. 进入克隆的仓库目录:cd requests
  3. 使用 Gradle 构建插件:./gradlew shadowJar
  4. 构建好的 JAR 文件将位于 build/libs/requests-<version>-all.jar。

许可证

Requests 根据 GPL-3 License 许可发布。

你是这个资源的作者?登录后可认领此资源。

评论 0

0.0
暂无评分
5 星
0
4 星
0
3 星
0
2 星
0
1 星
0
我的评分

登录后参与评分

还没有评论,来抢沙发吧

评论配图

相似资源