Dinnerbone / mcstatus

A Python class for checking the status of an enabled Minecraft server
http://dinnerbone.com/minecraft/tools/status/
1.11k stars 146 forks source link

Add bedrock server support #104

Closed Iapetus-11 closed 3 years ago

Iapetus-11 commented 3 years ago

Code for checking the status of a Minecraft BE server has been added, but is commented out as a dependency doesn't support Python 3.5. I also wasn't sure whether to add support for Python 2.x as it seemed like it was no longer being supported by this project.

Let me know if I need to make any tweaks or changes!

Example usage:

import mcstatus

bedrock_server = mcstatus.MinecraftBedrockServer.lookup('xenonmc.ml')
response = bedrock_server.status()

print(response.latency)
print(response.version.protocol)
print(response.version.brand)
print(response.motd)
print(response.players_max)
print(response.players_online)
print(response.map)
print(response.gamemode)
Iapetus-11 commented 3 years ago

Looks like the module I used for async UDP support isn't supported by Python 3.5. I guess I'll work on a solution unless the maintainer wants to remove support for Python 3.5.

Iapetus-11 commented 3 years ago

I figured out + implemented regular (non-async) support for getting the status of Bedrock Edition servers, and commented out the async methods + removed asyncio-dgram from the requirements.txt. It should now be compatible with Python 3.5-3.9!

kevinkjt2000 commented 3 years ago

Thanks for taking the time to do this! Would you mind adding some unit tests under mcstatus/tests/ directory? To run the tests in the same way the release automation does, feel free to follow along with these highlighted commands https://github.com/Dinnerbone/mcstatus/blob/c2fb996528c64d6e84ea72e6f438e8ef02ac6a64/release.sh#L4-L12

kevinkjt2000 commented 3 years ago

Please don't bother with python2 support. This library is only promising python3 support as of v3.0.0 https://github.com/Dinnerbone/mcstatus/commit/db85166ad540cb52e1613a660a18e18a97808fa0

I will have to check when 3.5's end-of-life date is. Possibly a dependency needs updated or replaced. It's also possible that python3.5 is a low percentage of users. I shall take the time to evaluate this later. https://github.com/Dinnerbone/mcstatus/issues/105

Iapetus-11 commented 3 years ago

Unit tests were added, and as asyncio-dgram now supports Python 3.5 async Bedrock Edition status was also added back.

kevinkjt2000 commented 3 years ago

I’ll volunteer some time tomorrow to look at this.

Iapetus-11 commented 3 years ago

It might need some restructuring as I wasn't exactly sure where to put everything, but I'd be happy to do it!