py-mine / mcstatus

A Python library for checking the status of Minecraft servers
https://mcstatus.readthedocs.io
Apache License 2.0
470 stars 37 forks source link

Wrong json server info #130

Closed py-mine-bot closed 2 years ago

py-mine-bot commented 2 years ago

Xoma163 Authored by Xoma163 Closed

Hello

mcstatus example.com:25566 json
{"online": true, "ping": 0.766}
mcstatus example.com:25566 status
version: v1.16.5 (protocol 754)
description: "{'text': '...'}"
players: 1/5 ['...']

Why json returns Incomplete information? On 1.12.2 there was no such problem

Thanks

py-mine-bot commented 2 years ago

kevinkjt2000 Authored by kevinkjt2000


What kind of Minecraft server is this? Is it vanilla 1.16.5? Can you run the following python script?

from mcstatus import MinecraftServer
ms = MinecraftServer("example.com", 25566) # replace with the correct values that you have hidden from us here
print(ms.status().raw)

I'm not seeing any issue for several servers that I selected at random from a Minecraft server list:


$ mcstatus simplyvanilla.net json
{"online": true, "ping": 36.39, "version": "Velocity 1.7.2-1.16.5", "protocol": 47, "motd": {"extra": [{"text": "\u00a79\u00a7l\u00a7oSimply   \u00a77Hello world"}, {"text": "\n\u00a79\u00a7l\u00a7o Vanilla"}], "text": ""}, "player_count": 41, "player_max": 999, "players": []}

$ mcstatus mordonia.com json
{"online": true, "ping": 36.042, "version": "Paper 1.16.5", "protocol": 754, "motd": {"extra": [{"color": "aqua", "text": "                \u22d6"}, {"color": "dark_aqua", "text": "\u2322\u2323\u2322\u2323\u2322"}, {"color": "aqua", "text": "\u22d7 "}, {"color": "gold", "text": "\u263c"}, {"text": " "}, {"color": "light_purple", "text": "Mordonia"}, {"text": " "}, {"color": "gold", "text": "\u263c"}, {"text": " "}, {"color": "aqua", "text": "\u22d6"}, {"color": "dark_aqua", "text": "\u2322\u2323\u2322\u2323\u2322"}, {"color": "aqua", "text": "\u22d7\n     \u2653 "}, {"color": "dark_purple", "text": "Mythic Drops"}, {"color": "aqua", "text": " \u2653 "}, {"color": "dark_green", "text": "Towny"}, {"color": "aqua", "text": " \u2653 "}, {"color": "gold", "text": "PVP"}, {"color": "aqua", "text": " \u2653 "}, {"color": "dark_red", "text": "Rp"}, {"color": "aqua", "text": " \u2653 "}, {"color": "blue", "text": "Ranks "}, {"color": "aqua", "text": "\u2653"}], "text": ""}, "player_count": 0, "player_max": 60, "players": []}

$ mcstatus pixelsmp.my.pebble.host json
{"online": true, "ping": 36.536, "version": "Spigot 1.16.5", "protocol": 754, "motd": {"extra": [{"text": "A Minecraft Server"}], "text": ""}, "player_count": 1, "player_max": 100, "players": [{"name": "ComradeSpyer", "id": "85ed3420-5e39-4dad-9c9a-754d0f105d2d"}]}
py-mine-bot commented 2 years ago

Xoma163 Authored by Xoma163


What kind of Minecraft server is this? Is it vanilla 1.16.5? Can you run the following python script?

from mcstatus import MinecraftServer
ms = MinecraftServer("example.com", 25566) # replace with the correct values that you have hidden from us here
print(ms.status().raw)

I'm not seeing any issue for several servers that I selected at random from a Minecraft server list:

$ mcstatus simplyvanilla.net json
{"online": true, "ping": 36.39, "version": "Velocity 1.7.2-1.16.5", "protocol": 47, "motd": {"extra": [{"text": "\u00a79\u00a7l\u00a7oSimply   \u00a77Hello world"}, {"text": "\n\u00a79\u00a7l\u00a7o Vanilla"}], "text": ""}, "player_count": 41, "player_max": 999, "players": []}

$ mcstatus mordonia.com json
{"online": true, "ping": 36.042, "version": "Paper 1.16.5", "protocol": 754, "motd": {"extra": [{"color": "aqua", "text": "                \u22d6"}, {"color": "dark_aqua", "text": "\u2322\u2323\u2322\u2323\u2322"}, {"color": "aqua", "text": "\u22d7 "}, {"color": "gold", "text": "\u263c"}, {"text": " "}, {"color": "light_purple", "text": "Mordonia"}, {"text": " "}, {"color": "gold", "text": "\u263c"}, {"text": " "}, {"color": "aqua", "text": "\u22d6"}, {"color": "dark_aqua", "text": "\u2322\u2323\u2322\u2323\u2322"}, {"color": "aqua", "text": "\u22d7\n     \u2653 "}, {"color": "dark_purple", "text": "Mythic Drops"}, {"color": "aqua", "text": " \u2653 "}, {"color": "dark_green", "text": "Towny"}, {"color": "aqua", "text": " \u2653 "}, {"color": "gold", "text": "PVP"}, {"color": "aqua", "text": " \u2653 "}, {"color": "dark_red", "text": "Rp"}, {"color": "aqua", "text": " \u2653 "}, {"color": "blue", "text": "Ranks "}, {"color": "aqua", "text": "\u2653"}], "text": ""}, "player_count": 0, "player_max": 60, "players": []}

$ mcstatus pixelsmp.my.pebble.host json
{"online": true, "ping": 36.536, "version": "Spigot 1.16.5", "protocol": 754, "motd": {"extra": [{"text": "A Minecraft Server"}], "text": ""}, "player_count": 1, "player_max": 100, "players": [{"name": "ComradeSpyer", "id": "85ed3420-5e39-4dad-9c9a-754d0f105d2d"}]}
{'description': {'text': 'VR Server'}, 'players': {'max': 5, 'online': 0}, 'version': {'name': '1.16.5', 'protocol': 754}, 'forgeData': {'channels': [{'res': 'jei:channel', 'version': '1.0.0', 'required': True}, {'res': 'cookingforblockheads:network', 'version': '1.0', 'required': False}, {'res': 'carryon:carryonpackets', 'version': '1.15.3.13', 'required': False}, {'res': 'minecraft:unregister', 'version': 'FML2', 'required': True}, {'res': 'colossalchests:channel_main', 'version': '1.0.0', 'required': True}, {'res': 'enderstorage:network', 'version': '1', 'required': True}, {'res': 'curios:main', 'version': '1', 'required': False}, {'res': 'placebo:placebo', 'version': '1.0.0', 'required': True}, {'res': 'cofh_core:general', 'version': '1', 'required': True}, {'res': 'autoreglib:main', 'version': '1', 'required': False}, {'res': 'worldinfo:world_id', 'version': '1', 'required': True}, {'res': 'fastbench:channel', 'version': '1.1.0', 'required': True}, {'res': 'cyclopscore:channel_main', 'version': '1.0.0', 'required': True}, {'res': 'journeymap:external_waypoint', 'version': '1', 'required': True}, {'res': 'ccl:internal', 'version': '1', 'required': True}, {'res': 'itemphysic:main', 'version': '1.0', 'required': False}, {'res': 'journeymap:channel', 'version': '5.7.1', 'required': True}, {'res': 'quark:main', 'version': '1', 'required': False}, {'res': 'naturescompass:naturescompass', 'version': '1.0', 'required': True}, {'res': 'creativecore:main', 'version': '1.0', 'required': False}, {'res': 'kleeslabs:network', 'version': '1.0', 'required': True}, {'res': 'solpotato:main', 'version': '1.0', 'required': False}, {'res': 'vivecraft:data', 'version': 'lol', 'required': True}, {'res': 'hats:channel', 'version': '1', 'required': False}, {'res': 'mob_grinding_utils:network', 'version': 'mob_grinding_utils:1', 'required': True}, {'res': 'minecraft:register', 'version': 'FML2', 'required': True}, {'res': 'forge:split', 'version': '1.0', 'required': True}, {'res': 'waystones:network', 'version': '1.0', 'required': False}], 'mods': [{'modId': 'minecraft', 'modmarker': '1.16.5'}, {'modId': 'mcwbridges', 'modmarker': '1.0.5'}, {'modId': 'cyclopscore', 'modmarker': '1.11.6'}, {'modId': 'clienttweaks', 'modmarker': 'OHNOES😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱'}, {'modId': 'solpotato', 'modmarker': '1.16.X-1.1.0'}, {'modId': 'netherportalfix', 'modmarker': 'OHNOES😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱'}, {'modId': 'hats', 'modmarker': 'OHNOES😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱'}, {'modId': 'biomesoplenty', 'modmarker': '1.16.5-13.1.0.466'}, {'modId': 'mining_helmet', 'modmarker': '2.0.1'}, {'modId': 'opticmanager', 'modmarker': '1.2.0'}, {'modId': 'creativecore', 'modmarker': '2.0.0'}, {'modId': 'jei', 'modmarker': '7.7.0.91'}, {'modId': 'kleeslabs', 'modmarker': '9.2.1'}, {'modId': 'curios', 'modmarker': '1.16.5-4.0.5.1'}, {'modId': 'thermal', 'modmarker': '1.2.0'}, {'modId': 'quark', 'modmarker': 'r2.4-311'}, {'modId': 'waystones', 'modmarker': '7.4.0'}, {'modId': 'clumps', 'modmarker': '6.0.0.22'}, {'modId': 'journeymap', 'modmarker': 'OHNOES😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱'}, {'modId': 'fastbench', 'modmarker': '4.5.1'}, {'modId': 'cookingforblockheads', 'modmarker': '9.3.1'}, {'modId': 'reauth', 'modmarker': '3.9.3'}, {'modId': 'placebo', 'modmarker': '4.4.2'}, {'modId': 'autoreglib', 'modmarker': '1.6-47'}, {'modId': 'naturescompass', 'modmarker': '1.16.5-1.8.6'}, {'modId': 'thermal_expansion', 'modmarker': '1.2.0'}, {'modId': 'inventoryhud', 'modmarker': '3.3.0'}, {'modId': 'vivecraftforgeextensions', 'modmarker': 'OHNOES😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱'}, {'modId': 'cofh_core', 'modmarker': '1.2.1'}, {'modId': 'login_shield', 'modmarker': '1.16.5-5-g909ffa8'}, {'modId': 'globalxp', 'modmarker': 'v1.8'}, {'modId': 'backtools', 'modmarker': 'OHNOES😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱'}, {'modId': 'toastcontrol', 'modmarker': 'OHNOES😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱'}, {'modId': 'itemphysic', 'modmarker': '1.6.0'}, {'modId': 'ichunutil', 'modmarker': '10.2.0'}, {'modId': 'carryon', 'modmarker': '1.15.3.13'}, {'modId': 'enderstorage', 'modmarker': '2.7.1.166'}, {'modId': 'forge', 'modmarker': 'ANY'}, {'modId': 'fastleafdecay', 'modmarker': 'v25'}, {'modId': 'codechickenlib', 'modmarker': '3.5.1.408'}, {'modId': 'mob_grinding_utils', 'modmarker': '1.16.5-0.4.21'}, {'modId': 'colossalchests', 'modmarker': '1.7.13'}], 'fmlNetworkVersion': 2}}

We played in minecraft in VR (Vivecraft) based on forge with mods

py-mine-bot commented 2 years ago

kevinkjt2000 Authored by kevinkjt2000


I'm 99% confident that you should have seen version in the json output based on the result of that script. Let's take that same raw dictionary and create a PingResponse object like the status function is doing:

from mcstatus import MinecraftServer
from mcstatus.pinger import PingResponse
ms = MinecraftServer("example.com", 25566) # replace with the correct values that you have hidden from us here
ms_status = ms.status(tries=1)
ping_resp = PingResponse(ms_status.raw)
print(ping_resp.version.name)

You would probably see 1.16.5. This is very similar to what the json CLI command is doing, so I'm not sure why it isn't working for you. Just to rule things out though, I added tries=1 to the script.

The status function in the script calls read_status: https://github.com/Dinnerbone/mcstatus/blob/a5522934f44f51f995151f2601dba5423926986d/mcstatus/server.py#L106-L108 Which creates a PingResponse object from the raw dict: https://github.com/Dinnerbone/mcstatus/blob/a5522934f44f51f995151f2601dba5423926986d/mcstatus/pinger.py#L37-L44

Maybe there's some exception happening that I'm not expecting though, so would you mind doing exactly what the json CLI command is doing with this?

import json
from mcstatus import MinecraftServer

server = MinecraftServer.lookup("example.com:25566") # of course, change this
data = {"online": False}

ping_res = server.ping()
data["online"] = True
data["ping"] = ping_res

status_res = server.status(tries=1)
data["version"] = status_res.version.name
data["protocol"] = status_res.version.protocol
data["motd"] = status_res.description
data["player_count"] = status_res.players.online
data["player_max"] = status_res.players.max
data["players"] = []
if status_res.players.sample is not None:
    data["players"] = [{"name": player.name, "id": player.id} for player in status_res.players.sample]

# I'm skipping the query stuff for now

print(json.dumps(data))
py-mine-bot commented 2 years ago

Xoma163 Authored by Xoma163


The first code result is

1.16.5

The second code result is

{"online": true, "ping": 1.623, "version": "1.16.5", "protocol": 754, "motd": {"text": "VR Server"}, "player_count": 0, "player_max": 5, "players": []}

hm... it's working, but why not working in cli?

Can I get your Email? I will send server link to you :)

py-mine-bot commented 2 years ago

Xoma163 Authored by Xoma163


Ok, my bad. I bump from 5.1.1 to 5.2.0 and it works!

{"online": true, "ping": 1.044, "version": "1.16.5", "protocol": 754, "motd": {"text": "VR Server"}, "player_count": 0, "player_max": 5, "players": []}

Thanks!