From 35a0598f2d51bf655370f74630fdd5ac88cb45e8 Mon Sep 17 00:00:00 2001 From: Battlefield Duck Date: Wed, 7 Feb 2024 22:59:13 +0800 Subject: [PATCH] Resolve Minecraft Protocol issue --- opengsq/protocols/minecraft.py | 36 ++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/opengsq/protocols/minecraft.py b/opengsq/protocols/minecraft.py index d28670f..328fe49 100644 --- a/opengsq/protocols/minecraft.py +++ b/opengsq/protocols/minecraft.py @@ -71,24 +71,26 @@ async def get_status(self, version=47, strip_color=True) -> dict[str, Any]: if isinstance(data["description"], str): data["description"] = Minecraft.strip_colors(data["description"]) + else: + if "text" in data["description"] and isinstance( + data["description"]["text"], str + ): + data["description"]["text"] = Minecraft.strip_colors( + data["description"]["text"] + ) - if "text" in data["description"] and isinstance( - data["description"]["text"], str - ): - data["description"]["text"] = Minecraft.strip_colors( - data["description"]["text"] - ) - - if "extra" in data["description"] and isinstance( - data["description"]["extra"], list - ): - for i, extra in enumerate(data["description"]["extra"]): - if isinstance(extra, str): - data["description"]["extra"][i] = Minecraft.strip_colors(extra) - elif isinstance(extra["text"], str): - data["description"]["extra"][i][ - "text" - ] = Minecraft.strip_colors(extra["text"]) + if "extra" in data["description"] and isinstance( + data["description"]["extra"], list + ): + for i, extra in enumerate(data["description"]["extra"]): + if isinstance(extra, str): + data["description"]["extra"][i] = Minecraft.strip_colors( + extra + ) + elif isinstance(extra["text"], str): + data["description"]["extra"][i]["text"] = ( + Minecraft.strip_colors(extra["text"]) + ) return data