Austinb / GameQ

A PHP Gameserver Status Query Library
https://austinb.github.io/GameQ/
GNU Lesser General Public License v3.0
403 stars 136 forks source link

Terraria: Undefined propery when server does not return player list #712

Open RikoDEV opened 11 months ago

RikoDEV commented 11 months ago

Server: penguingames.fun:7777

{
  "status": 200,
  "name": "Penguin Games",
  "serverversion": "1.4.4.9 (PC/Mobile)",
  "tshockversion": "4.4.0.15",
  "port": 7777,
  "playercount": 54,
  "maxplayers": 99999,
  "world": "Penguin Games",
  "uptime": "6.14:41:30",
  "serverpassword": false
}

Error:

  Undefined property: stdClass::$players

  at vendor\austinb\gameq\src\GameQ\Protocols\Tshock.php:132
    128▕         $result->add('numplayers', $json->playercount);
    129▕         $result->add('maxplayers', $json->maxplayers);
    130▕
    131▕         // Parse players
  ➜ 132▕         foreach ($json->players as $player) {
    133▕             $result->addPlayer('nickname', $player->nickname);
    134▕             $result->addPlayer('username', $player->username);
    135▕             $result->addPlayer('group', $player->group);
    136▕             $result->addPlayer('active', (int)$player->active);

  1   vendor\austinb\gameq\src\GameQ\Protocols\Tshock.php:132
      Illuminate\Foundation\Bootstrap\HandleExceptions::Illuminate\Foundation\Bootstrap\{closure}("Undefined property: stdClass::$players", "C:\Users\user\PhpstormProjects\project\vendor\austinb\gameq\src\GameQ\Protocols\Tshock.php")

  2   vendor\austinb\gameq\src\GameQ\GameQ.php:595
      GameQ\Protocols\Tshock::processResponse()