diff --git a/src/MinecraftJSONColors.php b/src/MinecraftJSONColors.php index b4eabf1..b28f191 100644 --- a/src/MinecraftJSONColors.php +++ b/src/MinecraftJSONColors.php @@ -79,7 +79,7 @@ public static function convertToLegacy($json, string $color_char = '§', bool $h self::$color_char = $color_char; self::$hex_colors = $hex_colors; - if (is_string($json)) { + if (!empty($json) && is_string($json)) { $json = json_decode($json, true); //Just return an empty string, if JSON was invalid. @@ -101,7 +101,8 @@ public static function convertToLegacy($json, string $color_char = '§', bool $h } } - $legacy .= self::parseElement($json); + if (is_array($json)) + $legacy .= self::parseElement($json); //If nothing was parsed until here, it's an array of components. if (empty($legacy) && is_array($json)) {