Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

CustomServerHome

Shirasawa edited this page Mar 21, 2020 · 1 revision

自定义服务器主页 - Custom Server Home

资源-版本 (整合包) 中的 serverHome 为自己的网页链接时, 启动器会在启动时在启动器内打开该链接, 同时会在网页中注入以下接口.

查询 MC 服务器信息

具体函数请查看 @xmcl/client

window.queryMinecraftServer(server: { host: string, port?: number }, options: { protocol?: number, timeout?: number, retryTimes?: number })

返回值: Promise<{ players: { max: number, online: number }, ping: number, description: string, ... }>

以上参数只有 server 中的 host 为必填, 其他为选填.

例子:

window
  .queryMinecraftServer({ host: 'mc.hypixel.net' })
  .then(info => {
    console.log(info.players, info.ping)
  })
  .catch(error => {
    console.error(error)
  })
Clone this wiki locally