• 本站是 我的世界国际版 资源分享论坛
    不会发布也不会允许用户发布有关 网易我的世界 的作弊工具以及修改器
    望周知
[转载] ServerTap - 通过API获取玩家信息和操作服务器 [1.16-1.19]

JE Plugins/JE-插件 [转载] ServerTap - 通过API获取玩家信息和操作服务器 [1.16-1.19] 0.6.1

没有下载权限
支持的版本
1.16.x
upload_2021-12-16_17-2-4.png



插件简介​

ServerTap 是一个支持 Bukkit、Spigot 和 Paper 服务器的 REST API 插件。 它允许通过 HTTP、Webhooks 和 Websockets 与服务器进行交互。

@Cnzw 说:
该插件很适合用于 QQ 机器人和各种状态监测网页。

安装要求​

  • Bukkit/Spigot/Paper 或其分支:1.16.5 或更高版本
  • Java:16 或更高版本
  • 无前置插件

如何使用​

将本插件文件复制到服务器的 plugins 文件夹中即完成了安装。

然后可以使用 CurlPostman 或任意浏览器来访问 API。

例如,查询有关服务器信息的 API:
JSON:
$ curl http: //localhost:4567/v1/server
{
    "name": "Paper",
    "motd": "This is my MOTD",
    "version": "git-Paper-89 (MC: 1.15.2)",
    "bukkitVersion": "1.15.2-R0.1-SNAPSHOT",
    "health": {
        "cpus": 4,
        "uptime": 744,
        "totalMemory": 2010644480,
        "maxMemory": 2010644480,
        "freeMemory": 1332389360
    },
    "bannedIps": [],
    "bannedPlayers": [{
        "target": "phybros",
        "source": "Server"
    }]
}

或查询在线玩家列表的 API:
JSON:
$ curl http://localhost:4567/v1/players
[{
    "uuid": "55f584e4-f095-48e0-bb8a-eb5c87ffe494",
    "displayName": "phybros",
    "address": "localhost",
    "port": 58529,
    "exhaustion": 3.5640976,
    "exp": 0.45454547,
    "whitelisted": false,
    "banned": false,
    "op": true
}]

API 文档​

插件自带 API 文档。可以在 http://服务器IP:4567/swagger 查看完整的 API 文档并且直接调试。

@Cnzw 说:
我直接导出了API接口,在这里查看

API 验证​

需要配置 plugins/ServerTap/config.yml 文件:
YAML:
useKeyAuth: true
key: some-long-super-random-string
然后,在需要在请求头(Header)中包含 key 和对应的密钥。

WebHook​

ServerTap 可以在服务器上发生事件时发送 WebHook 消息。

要使用 WebHook,需要配置 plugins/ServerTap/config.yml 文件:
YAML:
webhooks:
  default:
    listener: "https://your-webhook-target.com/whatever"
    events:
    - PlayerJoin
    - PlayerQuit
目前可用的事件有:
  • PlayerJoin
  • PlayerDeath
  • PlayerChat
  • PlayerKick
  • PlayerQuit

WebHook 通过 POST 请求发送 JSON 数据:
JSON:
{
  "player": {
    "uuid": "55f584e4-f095-48e0-bb8a-eb5c87ffe494",
    "displayName": "phybros",
    "address": "localhost",
    "port": 52809,
    "exhaustion": 0,
    "exp": 0.5714286,
    "whitelisted": true,
    "banned": false,
    "op": true
  },
  "joinMessage": "§ephybros joined the game",
  "eventType": "PlayerJoin"
}

Websockets​

ServerTap 支持正向 WebSocket ,能够实时接收服务器日志。

一旦连接,服务器上通过正常日志过滤器的任何服务器日志行都会以类似这样的 JSON 对象形式通过 WebSocket 发送:
JSON:
{
  "message": "§6/version: §fGets the version of this server including any plugins in use",
  "timestampMillis": 1631834015918,
  "loggerName": "",
  "level": "INFO"
}
WebSocket 地址是 ws://服务器IP:4567/v1/ws/console

最后 1000 条服务器日志消息将缓存并在客户端连接时发送。您可以通过更改 config.yml 中的 websocketConsoleBuffer 来配置服务器日志缓冲区的大小。

使用统计​


count


更多​

本插件已加入 插件搬运计划,会定期同步外网资源的更新。

搬运催更 & 问题反馈快速响应问卷 或在下方留下评论。
pkQMn9U.png
作者
Cnzw
下载
2
查看
431
首次发布
最后更新
评分
0.00 星 0 星

来自Cnzw的更多资源

最新更新

  1. ServerTap v0.6.1

    下载链接 https://github.com/servertap-io/servertap/releases/download/v0.6.1/ServerTap-0.6.1.jar...
  2. ServerTap v0.5.3 - 最后一个支持1.16.5的版本

    下载链接 https://github.com/servertap-io/servertap/releases/download/v0.5.3/ServerTap-0.5.3.jar...