Python minecraft server status

Basic Usage#

We are small package, so our API is not so big. There are only few classes, which are suggested for a basic usage.

Request Classes#

  • host – The host/ip of the minecraft server.
  • port – The port that the server is on.
  • timeout – The timeout in seconds before failing to connect.

Mimics minecraft’s server address field.

  • address – The address of the Minecraft server, like example.com:19132
  • timeout – The timeout in seconds before failing to connect.

Base class for a Minecraft Java Edition server.

  • host – The host/ip of the minecraft server.
  • port – The port that the server is on.
  • timeout – The timeout in seconds before failing to connect.

Mimics minecraft’s server address field.

With Java servers, on top of just parsing the address, we also check the DNS records for an SRV record that points to the server, which is the same behavior as with minecraft’s server address field for Java. This DNS record resolution is happening synchronously (see async_lookup() ).

  • address – The address of the Minecraft server, like example.com:25565 .
  • timeout – The timeout in seconds before failing to connect.
Читайте также:  Introduction to time series forecasting with python pdf

Asynchronous alternative to lookup() .

For more details, check the JavaServer.lookup() docstring.

Checks the latency between a Minecraft Java Edition server and the client (you).

kwargs – Passed to a ServerPinger instance.

The latency between the Minecraft Server and you.

Asynchronously checks the latency between a Minecraft Java Edition server and the client (you).

kwargs – Passed to a AsyncServerPinger instance.

The latency between the Minecraft Server and you.

Checks the status of a Minecraft Java Edition server via the status protocol.

kwargs – Passed to a ServerPinger instance.

Status information in a JavaStatusResponse instance.

Asynchronously checks the status of a Minecraft Java Edition server via the status protocol.

kwargs – Passed to a AsyncServerPinger instance.

Status information in a JavaStatusResponse instance.

Checks the status of a Minecraft Java Edition server via the query protocol.

Asynchronously checks the status of a Minecraft Java Edition server via the query protocol.

Base class for a Minecraft Bedrock Edition server.

  • host – The host/ip of the minecraft server.
  • port – The port that the server is on.
  • timeout – The timeout in seconds before failing to connect.

Checks the status of a Minecraft Bedrock Edition server.

kwargs – Passed to a BedrockServerStatus instance.

Status information in a BedrockStatusResponse instance.

Asynchronously checks the status of a Minecraft Bedrock Edition server.

kwargs – Passed to a BedrockServerStatus instance.

Status information in a BedrockStatusResponse instance.

Response Objects#

These are the classes that you get back after making a request.

For Java Server#

Raw response from the server.

This is TypedDict actually, please see sources to find what is here.

The icon of the server. In Base64 encoded PNG image format.

Deprecated since version 11.0.0: Will be removed 2023-12, use icon instead.

Message Of The Day. Also known as description.

Latency between a server and the client (you). In milliseconds.

Class for storing information about players on the server.

List of players, who are online. If server didn’t provide this, it will be None .

Actually, this is what appears when you hover over the slot count on the multiplayer screen.

It’s often empty or even contains some advertisement, because the specific server implementations or plugins can disable providing this information or even change it to something custom.

There is nothing that mcstatus can to do here if the player sample was modified/disabled like this.

Current number of online players.

The maximum allowed number of players (aka server slots).

Class with information about a single player.

ID of the player (in UUID format).

A class for storing version information.

The version name, like 1.19.3 .

The protocol version, like 761 .

Class for storing information about players on the server.

The number of online players.

The maximum allowed number of players (server slots).

The list of online players.

Class for storing information about software on the server.

The version of the software.

The brand of the software. Like Paper or Spigot.

The list of plugins. Can be empty if hidden.

The MOTD of the server. Also known as description.

For Bedrock Servers#

The name of the gamemode on the server.

Deprecated since version 11.0.0: Will be removed 2023-12, use players.online instead.

Deprecated since version 11.0.0: Will be removed 2023-12, use players.max instead.

Deprecated since version 11.0.0: Will be removed 2023-12, use map_name instead.

Message Of The Day. Also known as description.

Latency between a server and the client (you). In milliseconds.

Class for storing information about players on the server.

Current number of online players.

The maximum allowed number of players (aka server slots).

A class for storing version information.

The protocol version, like 761 .

The version name, like 1.19.60 .

MCPE or MCEE for Education Edition.

Deprecated since version 11.0.0: Will be removed 2023-12, use name instead.

Conclusion#

Источник

MCStatus#

Mcstatus provides an API and command line script to fetch publicly available data from Minecraft servers. Specifically, mcstatus retrieves data by using these protocols: Server List Ping and Query. Because of mcstatus, you do not need to fully understand those protocols and can instead skip straight to retrieving minecraft server data quickly in your own programs.

Installation#

python3 -m pip install mcstatus

Usage#

Python API#

Java Edition#

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)>") 

Bedrock Edition#

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") 

Command Line Interface#

This only works with Java servers; Bedrock is not yet supported. Use mcstatus -h to see helpful information on how to use this script.

License#

Content#

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

A Python library for checking the status of Minecraft servers

License

py-mine/mcstatus

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Bumps [sphinx-autodoc-typehints](https://github.com/tox-dev/sphinx-autodoc-typehints) from 1.23.3 to 1.24.0. — [Release notes](https://github.com/tox-dev/sphinx-autodoc-typehints/releases) — [Changelog](https://github.com/tox-dev/sphinx-autodoc-typehints/blob/main/CHANGELOG.md) — [Commits](tox-dev/sphinx-autodoc-typehints@1.23.3. 1.24.0) — updated-dependencies: — dependency-name: sphinx-autodoc-typehints dependency-type: direct:development update-type: version-update:semver-minor . Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot]

Git stats

Files

Failed to load latest commit information.

README.md

Mcstatus provides an API and command line script to fetch publicly available data from Minecraft servers. Specifically, mcstatus retrieves data by using these protocols: Server List Ping and Query. Because of mcstatus, you do not need to fully understand those protocols and can instead skip straight to retrieving minecraft server data quickly in your own programs.

Mcstatus is available on PyPI, and can be installed trivially with:

python3 -m pip install mcstatus
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)>")
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")

See the documentation to find what you can do with our library!

This only works with Java servers; Bedrock is not yet supported. Use mcstatus -h to see helpful information on how to use this script.

Mcstatus is licensed under the Apache 2.0 license. See LICENSE for full text.

About

A Python library for checking the status of Minecraft servers

Источник

Оцените статью