UNPKG

jka-core

Version:

Library for working with Jedi Academy servers

29 lines (28 loc) 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.rconStatusBaseParser = void 0; const index_1 = require("../../../index"); const clientUsersFromRconStatusBase_parser_1 = require("../clientUsers/clientUsersFromRconStatusBase.parser"); function rconStatusBaseParser(strToParse) { let lines = strToParse.split('\n'); if (lines.length < 2) throw new Error('No information provided!'); const clientsInfo = []; let map = ''; lines.map(line => { if (!line || line.startsWith('-') || line.startsWith('num')) return; if (line.startsWith('map')) { const match = line.match(/map:\s(.+)/); map = match ? match[1] : null; } else clientsInfo.push(line); }); return { type: index_1.EServerTypes.BASE, map, players: (0, clientUsersFromRconStatusBase_parser_1.clientUsersFromRconStatusBase)(clientsInfo), }; } exports.rconStatusBaseParser = rconStatusBaseParser;