昨晚为了50金粒的悬赏肝了大概两个小时解决了一大堆问题,终于把获取Minecraft服务器在线玩家的API做好了。

请求

下面,隆重介绍Uncode API:mcPlayer ——

https://api.miri.site/mcPlayer/get.php?ip=<ServerIP>&port=<ServerPort>
参数描述示例
ServerIP服务器IPmc.test.com
ServerPort服务器端口25565

返回

请求此API将返回一串JSON:

{
    "max": 20,
    "online": 2,
    "sample": [{
        "id": "853c80ef-3c37-49fd-aa49-938b674adae6",
        "name": "Jeb_"
    }, {
        "id": "7a1495fb-2e47-4bb2-9846-aed0626b7758",
        "name": "Mr_Fang"
    }]
}
参数描述示例
max最大在线人数20
online在线人数2
sample在线玩家{...}

Demo

JQuery:

$.ajax({
    type: 'get',
    url: 'https://api.miri.site/mcPlayer/get.php?ip=mc.test.com&port=25565';
    success: function(body, heads, status) {
        var max = body.max;
        var online = body.online;
        var sample = body.sample;
    }
})

完整示例请参考:https://api.miri.site/mcPlayer/test.html (进入后右键查看源代码即可)