2023-11-12 12:14:43 +01:00
|
|
|
import Core from './core.js'
|
|
|
|
|
|
|
|
export default class eco extends Core {
|
|
|
|
async run (state) {
|
|
|
|
if (!this.options.port) this.options.port = 3001
|
|
|
|
|
|
|
|
const request = await this.request({
|
2024-01-31 19:29:02 +01:00
|
|
|
url: `http://${this.options.host}:${this.options.port}/frontpage`,
|
2023-11-12 12:14:43 +01:00
|
|
|
responseType: 'json'
|
|
|
|
})
|
|
|
|
const serverInfo = request.Info
|
|
|
|
|
|
|
|
state.name = serverInfo.Description
|
2024-01-31 19:29:02 +01:00
|
|
|
state.numplayers = serverInfo.OnlinePlayers
|
2023-11-12 12:14:43 +01:00
|
|
|
state.maxplayers = serverInfo.TotalPlayers
|
|
|
|
state.password = serverInfo.HasPassword
|
|
|
|
state.gamePort = serverInfo.GamePort
|
2024-01-31 19:29:02 +01:00
|
|
|
state.players = serverInfo.OnlinePlayersNames?.map(name => ({ name, raw: {} })) || []
|
2023-11-12 12:14:43 +01:00
|
|
|
state.raw = serverInfo
|
2024-02-24 19:46:40 +01:00
|
|
|
state.version = state.raw.Version
|
2023-11-12 12:14:43 +01:00
|
|
|
}
|
|
|
|
}
|