mirror of
https://github.com/gamedig/node-gamedig.git
synced 2024-11-17 17:25:19 +01:00
feat: add BeamMP support (#447)
* feat: add beammp support * fix: cleanup server name of escape codes * chore: add a new line for better readability
This commit is contained in:
parent
68c8423c84
commit
6bfbc883be
6 changed files with 61 additions and 1 deletions
|
@ -36,6 +36,7 @@ see next point) and `tshock` (which is `terraria`).
|
||||||
* Removed the players::setNum method, the library will no longer add empty players as
|
* Removed the players::setNum method, the library will no longer add empty players as
|
||||||
a placeholder in the `players` fields.
|
a placeholder in the `players` fields.
|
||||||
* Stabilized field `numplayers`.
|
* Stabilized field `numplayers`.
|
||||||
|
* BeamMP (2021) - Added support.
|
||||||
|
|
||||||
### 4.3.1
|
### 4.3.1
|
||||||
* Fixed support for the Minecraft [Better Compatibility Checker](https://www.curseforge.com/minecraft/mc-mods/better-compatibility-checker) Mod (By @Douile, #436).
|
* Fixed support for the Minecraft [Better Compatibility Checker](https://www.curseforge.com/minecraft/mc-mods/better-compatibility-checker) Mod (By @Douile, #436).
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
| `ballisticoverkill` | Ballistic Overkill (2017) | [Valve Protocol](#valve) |
|
| `ballisticoverkill` | Ballistic Overkill (2017) | [Valve Protocol](#valve) |
|
||||||
| `barotrauma` | Barotrauma (2019) | [Valve Protocol](#valve) |
|
| `barotrauma` | Barotrauma (2019) | [Valve Protocol](#valve) |
|
||||||
| `bat1944` | Battalion 1944 (2018) | [Valve Protocol](#valve) |
|
| `bat1944` | Battalion 1944 (2018) | [Valve Protocol](#valve) |
|
||||||
|
| `beammp` | BeamMP (2021) | |
|
||||||
| `bf1942` | Battlefield 1942 (2002) | |
|
| `bf1942` | Battlefield 1942 (2002) | |
|
||||||
| `bf2` | Battlefield 2 (2005) | |
|
| `bf2` | Battlefield 2 (2005) | |
|
||||||
| `bf2142` | Battlefield 2142 (2006) | |
|
| `bf2142` | Battlefield 2142 (2006) | |
|
||||||
|
|
|
@ -227,6 +227,13 @@ export const games = {
|
||||||
protocol: 'valve'
|
protocol: 'valve'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
beammp: {
|
||||||
|
name: 'BeamMP (2021)',
|
||||||
|
options: {
|
||||||
|
port: 30814,
|
||||||
|
protocol: 'beammp'
|
||||||
|
}
|
||||||
|
},
|
||||||
bf1942: {
|
bf1942: {
|
||||||
name: 'Battlefield 1942 (2002)',
|
name: 'Battlefield 1942 (2002)',
|
||||||
options: {
|
options: {
|
||||||
|
|
32
protocols/beammp.js
Normal file
32
protocols/beammp.js
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
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)
|
||||||
|
state.maxplayers = parseInt(server.players)
|
||||||
|
|
||||||
|
const players = server.playerslist.split(';')
|
||||||
|
if (players[players.length - 1] === '') {
|
||||||
|
players.pop()
|
||||||
|
}
|
||||||
|
players.forEach(player => {
|
||||||
|
state.players.push({ name: player })
|
||||||
|
})
|
||||||
|
|
||||||
|
state.raw = server
|
||||||
|
}
|
||||||
|
}
|
17
protocols/beammpmaster.js
Normal file
17
protocols/beammpmaster.js
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import Core from './core.js'
|
||||||
|
|
||||||
|
export default class beammpmaster extends Core {
|
||||||
|
constructor () {
|
||||||
|
super()
|
||||||
|
|
||||||
|
// Don't use the tcp ping probing
|
||||||
|
this.usedTcp = true
|
||||||
|
}
|
||||||
|
|
||||||
|
async run (state) {
|
||||||
|
state.raw.servers = await this.request({
|
||||||
|
url: 'https://backend.beammp.com/servers-info',
|
||||||
|
responseType: 'json'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
|
@ -48,11 +48,13 @@ import valve from './valve.js'
|
||||||
import vcmp from './vcmp.js'
|
import vcmp from './vcmp.js'
|
||||||
import ventrilo from './ventrilo.js'
|
import ventrilo from './ventrilo.js'
|
||||||
import warsow from './warsow.js'
|
import warsow from './warsow.js'
|
||||||
|
import beammpmaster from './beammpmaster.js'
|
||||||
|
import beammp from './beammp.js'
|
||||||
|
|
||||||
export {
|
export {
|
||||||
armagetron, ase, asa, assettocorsa, battlefield, buildandshoot, cs2d, discord, doom3, eco, epic, ffow, fivem, gamespy1,
|
armagetron, ase, asa, assettocorsa, battlefield, buildandshoot, cs2d, discord, doom3, eco, epic, ffow, fivem, gamespy1,
|
||||||
gamespy2, gamespy3, geneshift, goldsrc, hexen2, jc2mp, kspdmp, mafia2mp, mafia2online, minecraft,
|
gamespy2, gamespy3, geneshift, goldsrc, hexen2, jc2mp, kspdmp, mafia2mp, mafia2online, minecraft,
|
||||||
minecraftbedrock, minecraftvanilla, mumble, mumbleping, nadeo, openttd, quake1, quake2, quake3, rfactor, samp,
|
minecraftbedrock, minecraftvanilla, mumble, mumbleping, nadeo, openttd, quake1, quake2, quake3, rfactor, samp,
|
||||||
savage2, starmade, starsiege, teamspeak2, teamspeak3, terraria, tribes1, tribes1master, unreal2, ut3, valve,
|
savage2, starmade, starsiege, teamspeak2, teamspeak3, terraria, tribes1, tribes1master, unreal2, ut3, valve,
|
||||||
vcmp, ventrilo, warsow, eldewrito
|
vcmp, ventrilo, warsow, eldewrito, beammpmaster, beammp
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue