From b2de68f551f491cc96f865652c6683d049453f6f Mon Sep 17 00:00:00 2001 From: Vito0912 <86927734+Vito0912@users.noreply.github.com> Date: Wed, 31 Jan 2024 19:29:02 +0100 Subject: [PATCH] fix: Updated the eco protocol to include player names and fix problems encountered when using the eco web interface behind a proxy. (#526) * Update eco protocol to include player names and fixed problems when using eco webinterface behind a proxy * changelog + readability * Typo * Typo --- CHANGELOG.md | 1 + protocols/eco.js | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92f17af..a857544 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## To Be Released... ## 5.0.0-beta.3 * Euro Truck Simulator 2 (2012) - Added support (By @podrivo #523) +* Eco - Added support for Eco servers that require connection from a domain (By @Vito0912) ## 5.0.0-beta.2 * Fixed support for projects using `require`. diff --git a/protocols/eco.js b/protocols/eco.js index 714b86c..c3c3854 100644 --- a/protocols/eco.js +++ b/protocols/eco.js @@ -5,16 +5,17 @@ export default class eco extends Core { if (!this.options.port) this.options.port = 3001 const request = await this.request({ - url: `http://${this.options.address}:${this.options.port}/frontpage`, + url: `http://${this.options.host}:${this.options.port}/frontpage`, responseType: 'json' }) const serverInfo = request.Info state.name = serverInfo.Description - state.numplayers = serverInfo.OnlinePlayers; + state.numplayers = serverInfo.OnlinePlayers state.maxplayers = serverInfo.TotalPlayers state.password = serverInfo.HasPassword state.gamePort = serverInfo.GamePort + state.players = serverInfo.OnlinePlayersNames?.map(name => ({ name, raw: {} })) || [] state.raw = serverInfo } }