mirror of
https://github.com/tribufu/node-gamedig
synced 2026-05-06 15:17:36 +00:00
* Implement fast-xml-parser replacing cheerio for farmingsim * Add extra player raw fields * Update buildandshoot for server 0.75 which uses json. * Remove cheerio * Add changelog entry * Add notes for build and shoot query server * Update CHANGELOG.md * Update package.json to fix version * Update buildandshoot.js * update lock * Add specific key and value to bas config in note * Add spacing for import * Run eslint on bas protocol * Use includes for check. Add doc notes to games.js * Updates GAMES_LIST.md * fix: support stable and master * attempt to manually fix conflict * fix players * fix fx * Update CHANGELOG.md --------- Co-authored-by: CosminPerRam <cosmin.p@live.com>
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
import Core from './core.js'
|
|
|
|
// We are doing some shenanigans here as we are trying to support the stable version and the git master version
|
|
// as in the latest (0.75) releases they are mixed up.
|
|
export default class buildandshoot extends Core {
|
|
async run (state) {
|
|
const request = await this.request({
|
|
url: 'http://' + this.options.address + ':' + this.options.port + '/json',
|
|
responseType: 'json'
|
|
})
|
|
|
|
state.name = request.serverName
|
|
state.map = request.map.name
|
|
state.version = request.serverVersion
|
|
|
|
const bluePlayers = request.players?.blue || []
|
|
const greenPlayers = request.players?.green || []
|
|
let players = bluePlayers.concat(greenPlayers)
|
|
if (Array.isArray(request.players)) {
|
|
players = players.concat(request.players)
|
|
}
|
|
|
|
state.numplayers = players.length
|
|
state.maxplayers = request.maxPlayers || request.players?.maxPlayers
|
|
|
|
state.players = []
|
|
for (const player of players) {
|
|
if (typeof player === 'string') {
|
|
state.players.push({
|
|
name: player
|
|
})
|
|
} else {
|
|
state.players.push({
|
|
...player,
|
|
name: player.name
|
|
})
|
|
}
|
|
}
|
|
|
|
state.raw = request
|
|
}
|
|
}
|