### Install mcstatus via pip Source: https://mcstatus.readthedocs.io/ Use this command to install the mcstatus library from PyPI. ```bash python3 -m pip install mcstatus ``` -------------------------------- ### Access mcstatus CLI help Source: https://mcstatus.readthedocs.io/ Display the help menu for the mcstatus command line interface. ```bash python3 -m mcstatus --help ``` -------------------------------- ### Query Java Edition (1.7+) Servers Source: https://mcstatus.readthedocs.io/ Use JavaServer to retrieve status, latency, and query information. Note that query must be enabled in the server's server.properties file. ```python from mcstatus import JavaServer # You can pass the same address you'd enter into the address field in minecraft into the 'lookup' function # If you know the host and port, you may skip this and use JavaServer("example.org", 1234) server = JavaServer.lookup("example.org:1234") # 'status' is supported by all Minecraft servers that are version 1.7 or higher. # Don't expect the player list to always be complete, because many servers run # plugins that hide this information or limit the number of players returned or even # alter this list to contain fake players for purposes of having a custom message here. status = server.status() print(f"The server has {status.players.online} player(s) online and replied in {status.latency} ms") # 'ping' is supported by all Minecraft servers that are version 1.7 or higher. # It is included in a 'status' call, but is also exposed separate if you do not require the additional info. latency = server.ping() print(f"The server replied in {latency} ms") # 'query' has to be enabled in a server's server.properties file! # It may give more information than a ping, such as a full player list or mod information. query = server.query() print(f"The server has the following players online: {', '.join(query.players.names)}") ``` -------------------------------- ### Query Bedrock Edition Servers Source: https://mcstatus.readthedocs.io/ Use BedrockServer to retrieve status information for Bedrock edition servers. ```python from mcstatus import BedrockServer # You can pass the same address you'd enter into the address field in minecraft into the 'lookup' function # If you know the host and port, you may skip this and use BedrockServer("example.org", 19132) server = BedrockServer.lookup("example.org:19132") # 'status' is the only feature that is supported by Bedrock at this time. # In this case status includes players.online, latency, motd, map, gamemode, and players.max. (ex: status.gamemode) status = server.status() print(f"The server has {status.players.online} players online and replied in {status.latency} ms") ``` -------------------------------- ### Query Legacy Java Edition (Beta 1.8-1.6) Servers Source: https://mcstatus.readthedocs.io/ Use LegacyServer to retrieve status information for older Minecraft Java Edition servers. ```python from mcstatus import LegacyServer # You can pass the same address you'd enter into the address field in minecraft into the 'lookup' function # If you know the host and port, you may skip this and use LegacyServer("example.org", 1234) server = LegacyServer.lookup("example.org:1234") # 'status' is supported by all Minecraft servers. status = server.status() print(f"The server has {status.players.online} player(s) online and replied in {status.latency} ms") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.