Skip to content

Commit

Permalink
Receiving of mods may fail, so return then an empty array as fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudmaker97 committed Nov 28, 2024
1 parent bdb80db commit c672838
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions source/Services/ServerStatusFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit c672838

Please sign in to comment.