Closed TomSipsOnCurry closed 2 years ago
Most of the async alternatives are simply prefixed by async_
, here's a simple example:
import asyncio
from mcstatus import JavaServer
async def main():
server = await JavaServer.async_lookup("mc.hypixel.net")
status = await server.async_status()
print(status.description)
asyncio.run(main())
Oh, thank you. I just want to ask how I would get the player list without using query. Because when I used this before I remember doing it with status.
Try this with example by ItsDrike
if status.players.sample is not None:
players = [player.name for player in status.players.sample]
else:
players = []
Note that this can be empty as well as contain some advertisement by server.
For some reason tis always returning none
Are you trying one server?
Yes
So you will always get the same result. This depends on server's configuration, and if it didn't change - result also will not change.
Yeah, the player sample is not a perfect solution, it's often going to be incomplete and might only include first few players, or even be completely empty, because many servers run plugins to hide it, especially the bigger ones.
In some cases, these plugins can even alter the player sample to contain fake players for purposes of advertisement, so for example there might be a player named "SkyBlock now updated!", or similar things.
Using status for getting player names is very unreliable, however it's the best option you have if the server doesn't support query. For vanilla servers, using sample should work without issues.
It's my server. I don't want to use query because I'm making a discord bot and since query takes more than 3 seconds the discord.py interaction times out. Sample might be alright because we only have max 7 players.
Then you should find how to enable players list while hovering their count in servers list on your core. Do not use plugins, it's already implemented even in Vanilla.
@TomSipsOnCurry
query takes more than 3 seconds
Because there is either a firewall or query was not enabled in server.properties.
Then you should find how to enable players list while hovering their count in servers list on your core. Do not use plugins, it's already implemented even in Vanilla.
It works
@TomSipsOnCurry
query takes more than 3 seconds
Because there is either a firewall or query was not enabled in server.properties.
I use a server hoster, but I enabled query
Nvr mind turns out i put the wrong port :(
I remember this used to have an async alternative but now I cant find the function.