Skip to content

Commit

Permalink
Fix JSON null players
Browse files Browse the repository at this point in the history
  • Loading branch information
ldilley committed Mar 30, 2024
1 parent cd50b0e commit 781ec0d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fragland/minestat",
"version": "3.0.0",
"version": "3.0.1",
"type": "library",
"description": "A Minecraft server status checker",
"keywords": ["Minecraft","status"],
Expand Down
6 changes: 3 additions & 3 deletions minestat.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

class MineStat
{
const VERSION = "3.0.0"; // MineStat version
const VERSION = "3.0.1"; // MineStat version
const NUM_FIELDS = 6; // number of values expected from server
const NUM_FIELDS_BETA = 3; // number of values expected from a 1.8b/1.3 server
const MAX_VARINT_SIZE = 5; // maximum number of bytes a varint can be
Expand Down Expand Up @@ -610,8 +610,8 @@ public function json_request()
$this->version = @$json_data['version']['name'];
$this->motd = @$json_data['description'];
$this->strip_motd();
$this->current_players = (int)@$json_data['players']['online'];
$this->max_players = (int)@$json_data['players']['max'];
$this->current_players = (int)@$json_data['players']['online'] ?? -1;
$this->max_players = (int)@$json_data['players']['max'] ?? -1;
$this->favicon_b64 = @$json_data['favicon'];
if(isset($this->favicon_b64))
{
Expand Down

0 comments on commit 781ec0d

Please sign in to comment.