diff --git a/opengsq/protocols/minecraft.py b/opengsq/protocols/minecraft.py index 18b6426..2fc9c77 100644 --- a/opengsq/protocols/minecraft.py +++ b/opengsq/protocols/minecraft.py @@ -46,9 +46,10 @@ async def get_status(self, version=47, strip_color=True) -> dict: br = BinaryReader(response) self._unpack_varint(br) # packet length self._unpack_varint(br) # packet id - self._unpack_varint(br) # json length + count = self._unpack_varint(br) # json length - data = json.loads(br.read().decode('utf-8')) + # The packet may response with two json objects, so we need to get the json length exactly + data = json.loads(br.read_bytes(count).decode('utf-8')) if strip_color: if 'sample' in data['players']: @@ -141,7 +142,7 @@ def _unpack_varint(self, br: BinaryReader): import asyncio async def main_async(): - minecraft = Minecraft(host='51.83.219.117', port=25565, timeout=5.0) + minecraft = Minecraft(host='valistar.site', port=25565, timeout=5.0) status = await minecraft.get_status(47, strip_color=True) print(json.dumps(status, indent=None, ensure_ascii=False) + '\n') status = await minecraft.get_status_pre17()