2023-12-30 21:41:56 +01:00
|
|
|
import Core from './core.js'
|
|
|
|
import beammpmaster from './beammpmaster.js'
|
|
|
|
|
|
|
|
export default class beammp extends Core {
|
|
|
|
async run (state) {
|
|
|
|
const master = new beammpmaster()
|
|
|
|
master.options = this.options
|
|
|
|
const masterState = await master.runOnceSafe()
|
|
|
|
const servers = masterState.raw.servers
|
|
|
|
const server = servers.find(s => s.ip === this.options.host)
|
|
|
|
|
|
|
|
if (!server) {
|
|
|
|
throw new Error('Server not found in the master list')
|
|
|
|
}
|
|
|
|
|
|
|
|
state.name = server.sname.replace(/\^./g, '')
|
|
|
|
state.map = server.map
|
|
|
|
state.password = server.password
|
|
|
|
state.numplayers = parseInt(server.players)
|
2024-02-26 16:26:24 +01:00
|
|
|
state.maxplayers = parseInt(server.maxplayers)
|
2023-12-30 21:41:56 +01:00
|
|
|
|
|
|
|
const players = server.playerslist.split(';')
|
|
|
|
if (players[players.length - 1] === '') {
|
|
|
|
players.pop()
|
|
|
|
}
|
|
|
|
players.forEach(player => {
|
|
|
|
state.players.push({ name: player })
|
|
|
|
})
|
|
|
|
|
|
|
|
state.raw = server
|
2024-02-24 19:46:40 +01:00
|
|
|
if ('version' in state.raw) state.version = state.raw.version
|
2023-12-30 21:41:56 +01:00
|
|
|
}
|
|
|
|
}
|