From c672838f1da7506bdd70adcdfc3e1f05c5c74637 Mon Sep 17 00:00:00 2001 From: Dennis Heinrich Date: Thu, 28 Nov 2024 09:44:31 +0100 Subject: [PATCH] Receiving of mods may fail, so return then an empty array as fallback --- source/Services/ServerStatusFeed.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/Services/ServerStatusFeed.ts b/source/Services/ServerStatusFeed.ts index 036fb80..61f43a7 100644 --- a/source/Services/ServerStatusFeed.ts +++ b/source/Services/ServerStatusFeed.ts @@ -119,9 +119,13 @@ export default class ServerStatusFeed { return dayTime / (60 * 60 * 1000) + 0.0001; } + /** + * Get the server mods from the server stats feed + * @returns {IMod[]} The server mods as an array of IMod objects + */ public getServerMods(): IMod[] { - let modList = this.getServerStats()?.Server.Mods.Mod; - if(modList === undefined || !Array.isArray(modList)) { + let modList = this.getServerStats()?.Server?.Mods?.Mod; + if(modList === undefined || !Array.isArray(modList) || modList == null) { return []; } return modList.map((mod: any) => {