mirror of
https://github.com/tribufu/node-gamedig
synced 2026-06-01 09:42:41 +00:00
feat: add vintage story support (#606)
* feat: add vintage story support * remove debug console.log
This commit is contained in:
parent
72893df2b3
commit
dcd12d0360
6 changed files with 60 additions and 6 deletions
24
protocols/vintagestory.js
Normal file
24
protocols/vintagestory.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import Core from './core.js'
|
||||
import vintagestorymaster from './vintagestorymaster.js'
|
||||
|
||||
export default class vintagestory extends Core {
|
||||
async run (state) {
|
||||
const master = new vintagestorymaster()
|
||||
master.options = this.options
|
||||
const masterState = await master.runOnceSafe()
|
||||
const servers = masterState.raw.servers
|
||||
const server = servers.find(s => s.serverIP === `${this.options.address}:${this.options.port}`)
|
||||
|
||||
if (!server) {
|
||||
throw new Error('Server not found in the master list')
|
||||
}
|
||||
|
||||
state.name = server.serverName
|
||||
state.password = server.hasPassword
|
||||
state.numplayers = parseInt(server.players)
|
||||
state.maxplayers = parseInt(server.maxPlayers)
|
||||
state.version = server.gameVersion
|
||||
|
||||
state.raw = server
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue