diff --git a/mcstatus/status_response.py b/mcstatus/status_response.py index ae5ef768..acaac9c2 100644 --- a/mcstatus/status_response.py +++ b/mcstatus/status_response.py @@ -109,7 +109,15 @@ class JavaStatusResponse(BaseStatusResponse): """ players: JavaStatusPlayers version: JavaStatusVersion - enforces_secure_chat: bool + enforces_secure_chat: bool | None + """Whether the server enforces secure chat (every message is signed up with a key). + + .. seealso:: + `Signed Chat explanation `_, + `22w17a changelog, where this was added `_. + + .. versionadded:: 11.1.0 + """ icon: str | None """The icon of the server. In `Base64 `_ encoded PNG image format. @@ -133,7 +141,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", False), + enforces_secure_chat=raw.get("enforcesSecureChat"), icon=raw.get("favicon"), latency=latency, ) diff --git a/tests/status_response/test_java.py b/tests/status_response/test_java.py index 7632faef..6eb8743a 100644 --- a/tests/status_response/test_java.py +++ b/tests/status_response/test_java.py @@ -11,6 +11,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", } @@ -19,13 +20,15 @@ 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), ] - 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", } @@ -33,12 +36,6 @@ class TestJavaStatusResponse(BaseStatusResponseTest): def build(self): return JavaStatusResponse.build(self.RAW) # type: ignore # dict[str, Unknown] cannot be assigned to TypedDict - @pytest.mark.parametrize("value", (True, False, object())) - def test_enforces_secure_chat(self, value): - raw = self.RAW.copy() - raw["enforcesSecureChat"] = value - assert JavaStatusResponse.build(raw, 0).enforces_secure_chat is value # type: ignore # dict[str, Unknown] cannot be assigned to TypedDict - @BaseStatusResponseTest.construct class TestJavaStatusPlayers(BaseStatusResponseTest):