Skip to content

Commit

Permalink
Merge branch 'py-mine:master' into forge-data
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolCat467 authored Dec 12, 2023
2 parents b4f30cf + 2176ac9 commit 7427d64
Show file tree
Hide file tree
Showing 10 changed files with 326 additions and 388 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
id: poetry_setup
uses: ItsDrike/setup-poetry@v1
with:
python-version: 3.11
python-version: 3.12
install-args: "--with release"

- name: Prepare pyproject.toml with dynamic version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tox-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.11"]
python-version: ["3.8", "3.12"]

steps:
- name: Checkout repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
id: poetry_setup
uses: ItsDrike/setup-poetry@v1
with:
python-version: 3.11
python-version: 3.12

- name: Pre-commit Environment Caching
uses: actions/cache@v3
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ such error, you can re-encode text into UTF-8.
.. code-block:: python
>>> query = JavaServer.lookup("my-server-ip.com").query()
>>> query.motd
>>> query.motd.to_minecraft()
'Ð\x9fÑ\x80ивÑ\x96Ñ\x82!'
>>> query.motd.encode("iso-8859-1").decode("utf-8")
>>> query.motd.to_minecraft().encode("iso-8859-1").decode("utf-8")
'Привіт!'
:attr:`query.motd <mcstatus.querier.QueryResponse.motd>` here can be anything,
Expand Down
6 changes: 3 additions & 3 deletions mcstatus/motd/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class Formatting(Enum):
"""Enum for Formatting codes.
See `Minecraft wiki <https://minecraft.fandom.com/wiki/Formatting_codes#Formatting_codes>`__
See `Minecraft wiki <https://minecraft.wiki/w/Formatting_codes#Formatting_codes>`__
for more info.
.. note::
Expand All @@ -30,7 +30,7 @@ class Formatting(Enum):
class MinecraftColor(Enum):
"""Enum for Color codes.
See `Minecraft wiki <https://minecraft.fandom.com/wiki/Formatting_codes#Color_codes>`_
See `Minecraft wiki <https://minecraft.wiki/w/Formatting_codes#Color_codes>`_
for more info.
"""

Expand Down Expand Up @@ -117,7 +117,7 @@ class TranslationTag:
This just exists, but is completely ignored by our transformers.
You can find translation tags in :attr:`Motd.parsed <mcstatus.motd.Motd.parsed>` attribute.
.. seealso:: `Minecraft's wiki. <https://minecraft.fandom.com/wiki/Raw_JSON_text_format#Translated_Text>`__
.. seealso:: `Minecraft's wiki. <https://minecraft.wiki/w/Raw_JSON_text_format#Translated_Text>`__
"""

id: str
Expand Down
16 changes: 13 additions & 3 deletions mcstatus/status_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ class JavaStatusResponse(BaseStatusResponse):
"""
players: JavaStatusPlayers
version: JavaStatusVersion
enforces_secure_chat: bool | None
"""Whether the server enforces secure chat (every message is signed up with a key).
.. seealso::
`Signed Chat explanation <https://gist.github.com/kennytv/ed783dd244ca0321bbd882c347892874>`_,
`22w17a changelog, where this was added <https://www.minecraft.net/nl-nl/article/minecraft-snapshot-22w17a>`_.
.. versionadded:: 11.1.0
"""
icon: str | None
"""The icon of the server. In `Base64 <https://en.wikipedia.org/wiki/Base64>`_ encoded PNG image format.
Expand Down Expand Up @@ -143,6 +152,7 @@ def build(cls, raw: RawJavaResponse, latency: float = 0) -> Self:
players=JavaStatusPlayers.build(raw["players"]),
version=JavaStatusVersion.build(raw["version"]),
motd=Motd.parse(raw["description"], bedrock=False),
enforces_secure_chat=raw.get("enforcesSecureChat"),
icon=raw.get("favicon"),
latency=latency,
forge_data=forge_data,
Expand Down Expand Up @@ -317,13 +327,13 @@ class BaseStatusVersion(ABC):
name: str
"""The version name, like ``1.19.3``.
See `Minecraft wiki <https://minecraft.fandom.com/wiki/Java_Edition_version_history#Full_release>`__
See `Minecraft wiki <https://minecraft.wiki/w/Java_Edition_version_history#Full_release>`__
for complete list.
"""
protocol: int
"""The protocol version, like ``761``.
See `Minecraft wiki <https://minecraft.fandom.com/wiki/Protocol_version#Java_Edition_2>`__.
See `Minecraft wiki <https://minecraft.wiki/w/Protocol_version#Java_Edition_2>`__.
"""


Expand Down Expand Up @@ -351,7 +361,7 @@ class BedrockStatusVersion(BaseStatusVersion):
name: str
"""The version name, like ``1.19.60``.
See `Minecraft wiki <https://minecraft.fandom.com/wiki/Bedrock_Edition_version_history#Bedrock_Edition>`__
See `Minecraft wiki <https://minecraft.wiki/w/Bedrock_Edition_version_history#Bedrock_Edition>`__
for complete list.
"""
brand: str
Expand Down
649 changes: 286 additions & 363 deletions poetry.lock

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Games/Entertainment",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: System :: Monitoring",
Expand All @@ -40,13 +41,13 @@ tox-poetry = "0.5.0" # deprecated, no sense in `^`

[tool.poetry.group.test.dependencies]
pytest = "^7.4.0"
pytest-asyncio = "^0.21.1"
pytest-asyncio = "^0.23.2"
pytest-cov = "^4.1.0"
pytest-rerunfailures = "^12.0"
pytest-rerunfailures = "^13.0"
coverage = "^7.3.0"

[tool.poetry.group.lint.dependencies]
ruff = "0.0.290"
ruff = "0.1.7"
black = "^23.7.0"
coverage = "^7.3.0"
isort = "^5.12.0"
Expand All @@ -62,15 +63,15 @@ sphinx-autodoc-typehints = "^1.24.0"
furo = ">=2022.12.7"
m2r2 = "^0.3.3"
tomli = { version = "^2.0.1", markers = "python_version < '3.11'" }
packaging = "23.1"
packaging = "23.2"
poetry-dynamic-versioning = "*" # actual version is in `release` group

[tool.poetry.group.release]
optional = true

[tool.poetry.group.release.dependencies]
twine = "^4.0.2"
poetry-dynamic-versioning = "^0.25.0"
poetry-dynamic-versioning = "^1.1.0"

[tool.poetry.group.workflow-tox]
optional = true
Expand Down
15 changes: 9 additions & 6 deletions tests/status_response/test_java.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pytest import fixture
import pytest

from mcstatus.forge_data import ForgeDataChannel, ForgeDataMod, RawForgeData
from mcstatus.motd import Formatting, Motd
Expand All @@ -12,6 +12,7 @@ class TestJavaStatusResponse(BaseStatusResponseTest):
"players": {"max": 20, "online": 0},
"version": {"name": "1.8-pre1", "protocol": 44},
"description": "A Minecraft Server",
"enforcesSecureChat": True,
"favicon": "data:image/png;base64,foo",
}

Expand All @@ -20,18 +21,20 @@ class TestJavaStatusResponse(BaseStatusResponseTest):
("version", JavaStatusVersion("1.8-pre1", 44)),
("motd", Motd.parse("A Minecraft Server", bedrock=False)),
("latency", 0),
("enforces_secure_chat", True),
("icon", "data:image/png;base64,foo"),
("raw", RAW),
("forge_data", None),
]
OPTIONAL_FIELDS = [("favicon", "icon")], {
OPTIONAL_FIELDS = [("favicon", "icon"), ("enforcesSecureChat", "enforces_secure_chat")], {
"players": {"max": 20, "online": 0},
"version": {"name": "1.8-pre1", "protocol": 44},
"description": "A Minecraft Server",
"enforcesSecureChat": True,
"favicon": "data:image/png;base64,foo",
}

@fixture(scope="class")
@pytest.fixture(scope="class")
def build(self):
return JavaStatusResponse.build(self.RAW) # type: ignore # dict[str, Unknown] cannot be assigned to TypedDict

Expand Down Expand Up @@ -60,7 +63,7 @@ class TestJavaStatusPlayers(BaseStatusResponseTest):
],
}

@fixture(scope="class")
@pytest.fixture(scope="class")
def build(self):
return JavaStatusPlayers.build(
{
Expand All @@ -82,7 +85,7 @@ def test_empty_sample_turns_into_empty_list(self):
class TestJavaStatusPlayer(BaseStatusResponseTest):
EXPECTED_VALUES = [("name", "foo"), ("id", "0b3717c4-f45d-47c8-b8e2-3d9ff6f93a89")]

@fixture(scope="class")
@pytest.fixture(scope="class")
def build(self):
return JavaStatusPlayer.build({"name": "foo", "id": "0b3717c4-f45d-47c8-b8e2-3d9ff6f93a89"})

Expand All @@ -98,7 +101,7 @@ def test_id_field_the_same_as_uuid(self):
class TestJavaStatusVersion(BaseStatusResponseTest):
EXPECTED_VALUES = [("name", "1.8-pre1"), ("protocol", 44)]

@fixture(scope="class")
@pytest.fixture(scope="class")
def build(self):
return JavaStatusVersion.build({"name": "1.8-pre1", "protocol": 44})

Expand Down
7 changes: 4 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[tox]
isolated_build = True
envlist =
format-check,lint,py{38,39,310,311},coverage
format-check,lint,py{38,39,310,311,312},coverage

[gh-actions]
python =
3.8: py38
3.9: py39
3.10: py310
3.11: py311, coverage
3.11: py311
3.12: py312, coverage

[testenv]
setenv =
Expand All @@ -18,7 +19,7 @@ commands =

[testenv:coverage]
depends =
py{38,39,310,311}
py{38,39,310,311,312}
setenv =
COVERAGE_FILE=.coverage
commands =
Expand Down

0 comments on commit 7427d64

Please sign in to comment.