diff --git a/mcstatus/pinger.py b/mcstatus/pinger.py index 84954a1..0b0a64e 100644 --- a/mcstatus/pinger.py +++ b/mcstatus/pinger.py @@ -102,7 +102,7 @@ class PingResponse: if "sample" in raw: if type(raw["sample"]) is not list: raise ValueError("Invalid players object (expected 'sample' to be list, was %s)" % type(raw["max"])) - self.sample = raw["sample"] + self.sample = [PingResponse.Players.Player(p) for p in raw["sample"]] class Version: def __init__(self, raw): diff --git a/mcstatus/tests/test_pinger.py b/mcstatus/tests/test_pinger.py index 7a478a7..e42ad30 100644 --- a/mcstatus/tests/test_pinger.py +++ b/mcstatus/tests/test_pinger.py @@ -123,6 +123,7 @@ class TestPingResponsePlayers(TestCase): players = PingResponse.Players({"max":20,"online":1,"sample":[{"name":'Dinnerbone','id':"61699b2e-d327-4a01-9f1e-0ea8c3f06bc6"}]}) self.assertIsNotNone(players.sample) + self.assertEqual(players.sample[0].name, "Dinnerbone") def test_sample_invalid(self): self.assertRaises(ValueError, PingResponse.Players, {"max":20,"online":1,"sample":"foo"})