From 781ec0df2380ec7e5a4933024b1ad043ee656ee9 Mon Sep 17 00:00:00 2001 From: Lloyd Dilley Date: Sat, 30 Mar 2024 15:45:31 -0400 Subject: [PATCH] Fix JSON null players --- composer.json | 2 +- minestat.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 83d2cce..7329a29 100644 --- a/composer.json +++ b/composer.json @@ -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"], diff --git a/minestat.php b/minestat.php index 4d855b7..52d6c2f 100644 --- a/minestat.php +++ b/minestat.php @@ -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 @@ -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)) {