feat: add palworld new new query implementation (#560)
* feat: add initial first working query * feat: map serverInfo data * feat: add players, settings and metrics queries * update docs stuff * fix broken palworld hyperlink in games list
This commit is contained in:
parent
4e6ab05291
commit
ee5baaff13
|
@ -15,6 +15,7 @@
|
||||||
* Myth of Empires - Added support.
|
* Myth of Empires - Added support.
|
||||||
* Fix: BeamMP maxplayers that was displaying player count (By @dgibbs64 #551)
|
* Fix: BeamMP maxplayers that was displaying player count (By @dgibbs64 #551)
|
||||||
* Fix: BeamMP filter servers by address, not host (By @Rephot #558)
|
* Fix: BeamMP filter servers by address, not host (By @Rephot #558)
|
||||||
|
* Palworld - Replace old and broken protocol with the new one (#560)
|
||||||
|
|
||||||
## 5.0.0-beta.2
|
## 5.0.0-beta.2
|
||||||
* Fixed support for projects using `require`.
|
* Fixed support for projects using `require`.
|
||||||
|
|
|
@ -210,7 +210,7 @@
|
||||||
| openarena | OpenArena | |
|
| openarena | OpenArena | |
|
||||||
| openttd | OpenTTD | |
|
| openttd | OpenTTD | |
|
||||||
| painkiller | Painkiller | |
|
| painkiller | Painkiller | |
|
||||||
| palworld | Palworld | [EOS Protocol](#epic) |
|
| palworld | Palworld | [Notes](#palworld) |
|
||||||
| pce | Primal Carnage: Extinction | [Valve Protocol](#valve) |
|
| pce | Primal Carnage: Extinction | [Valve Protocol](#valve) |
|
||||||
| pixark | PixARK | [Valve Protocol](#valve) |
|
| pixark | PixARK | [Valve Protocol](#valve) |
|
||||||
| postal2 | Postal 2 | |
|
| postal2 | Postal 2 | |
|
||||||
|
@ -459,3 +459,8 @@ option: `requestRules: true`. Beware that this may increase query time.
|
||||||
|
|
||||||
### <a name="epic"></a>Epic Online Services (EOS) Protocol
|
### <a name="epic"></a>Epic Online Services (EOS) Protocol
|
||||||
EOS does not provide players data.
|
EOS does not provide players data.
|
||||||
|
|
||||||
|
### <a name="palworld"></a>Palworld
|
||||||
|
Palworld support can be unstable, the devs mention the api is currently experimental.
|
||||||
|
To query palworld servers, the `RESTAPIEnabled` must be `True` in the configuration file, and you need to pass
|
||||||
|
the `username` (currently always `admin`) and `password` (settings parameter) for it.
|
||||||
|
|
|
@ -2092,8 +2092,9 @@ export const games = {
|
||||||
name: 'Palworld',
|
name: 'Palworld',
|
||||||
release_year: 2024,
|
release_year: 2024,
|
||||||
options: {
|
options: {
|
||||||
port: 8211,
|
port: 8212,
|
||||||
protocol: 'palworld'
|
protocol: 'palworld',
|
||||||
|
doc_notes: 'palworld'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pvak2: {
|
pvak2: {
|
||||||
|
|
|
@ -1,20 +1,32 @@
|
||||||
import Epic from './epic.js'
|
import Core from './core.js'
|
||||||
|
|
||||||
export default class palworld extends Epic {
|
export default class palworld extends Core {
|
||||||
constructor () {
|
async makeCall (endpoint) {
|
||||||
super()
|
const url = `http://${this.options.host}:${this.options.port}/v1/api/${endpoint}`
|
||||||
|
const headers = {
|
||||||
|
Authorization: `Basic ${Buffer.from(`${this.options.username}:${this.options.password}`).toString('base64')}`,
|
||||||
|
Accept: 'application/json'
|
||||||
|
}
|
||||||
|
|
||||||
// OAuth2 credentials extracted from Palworld files.
|
return await this.request({ url, headers, method: 'GET', responseType: 'json' })
|
||||||
this.clientId = 'xyza78916PZ5DF0fAahu4tnrKKyFpqRE'
|
|
||||||
this.clientSecret = 'j0NapLEPm3R3EOrlQiM8cRLKq3Rt02ZVVwT0SkZstSg'
|
|
||||||
this.deploymentId = '0a18471f93d448e2a1f60e47e03d3413'
|
|
||||||
this.authByExternalToken = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async run (state) {
|
async run (state) {
|
||||||
await super.run(state)
|
const serverInfo = await this.makeCall('info')
|
||||||
state.name = state.raw.attributes.NAME_s
|
state.version = serverInfo.version
|
||||||
state.numplayers = state.raw.attributes.PLAYERS_l
|
state.name = serverInfo.servername
|
||||||
state.version = state.raw.attributes.VERSION_S
|
state.raw.serverInfo = serverInfo
|
||||||
|
|
||||||
|
const { players } = await this.makeCall('players')
|
||||||
|
state.numplayers = players.length
|
||||||
|
state.players = players.map(p => p.name)
|
||||||
|
state.raw.players = players
|
||||||
|
|
||||||
|
state.raw.settings = await this.makeCall('settings')
|
||||||
|
|
||||||
|
const metrics = await this.makeCall('metrics')
|
||||||
|
state.numplayers = metrics.currentplayernum
|
||||||
|
state.maxplayers = metrics.maxplayernum
|
||||||
|
state.raw.metrics = metrics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ for (const id in sortedGames) {
|
||||||
if (game.options.protocol === 'valve' || game.options.protocol === 'dayz') {
|
if (game.options.protocol === 'valve' || game.options.protocol === 'dayz') {
|
||||||
notes.push('[Valve Protocol](#valve)')
|
notes.push('[Valve Protocol](#valve)')
|
||||||
}
|
}
|
||||||
if (game.options.protocol === 'epic' || game.options.protocol === 'asa' || game.options.protocol === 'palworld' || game.options.protocol === 'theisleevrima') {
|
if (game.options.protocol === 'epic' || game.options.protocol === 'asa' || game.options.protocol === 'theisleevrima') {
|
||||||
notes.push('[EOS Protocol](#epic)')
|
notes.push('[EOS Protocol](#epic)')
|
||||||
}
|
}
|
||||||
if (notes.length) {
|
if (notes.length) {
|
||||||
|
|
Loading…
Reference in New Issue