Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Bedrock support and misc improvements #849

Merged
merged 36 commits into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2ee93a5
fix crash with one command-line argument
katrinafyi Jul 15, 2024
ec1a0f5
implement ping() on BedrockServer
katrinafyi Jul 15, 2024
60e3512
support Bedrock servers in CLI
katrinafyi Jul 15, 2024
a0e41a2
print server kind and tweak player sample printing
katrinafyi Jul 15, 2024
47ce944
JavaServer ping() doesn't work?
katrinafyi Jul 16, 2024
213fc2a
fix precommit warnings
katrinafyi Jul 17, 2024
848fc57
review: remove Bedrock ping()
katrinafyi Jul 17, 2024
f9577b5
review: change CLI ping comment to be more permanent
katrinafyi Jul 17, 2024
3a0ee8c
review: formalise hostip/hostport within QueryResponse
katrinafyi Jul 17, 2024
73a4543
review: only squash traceback in common errors
katrinafyi Jul 17, 2024
47f62fc
review: leading line break for multi-line motd
katrinafyi Jul 19, 2024
1130b99
Revert "review: formalise hostip/hostport within QueryResponse"
katrinafyi Jul 19, 2024
bb51ac5
review: use motd.to_minecraft() in json
katrinafyi Jul 19, 2024
b6a28fa
review amendment: factor out motd line breaking
katrinafyi Jul 19, 2024
de8be4d
review: refactor CLI json() to use dataclasses.asdict()
katrinafyi Jul 20, 2024
faf208b
amendment: add NoNameservers and remove ValueError from squashed errors
katrinafyi Jul 19, 2024
890d378
review: fallback logic in CLI ping
katrinafyi Jul 20, 2024
80079b3
review: use ip/port fields in CLI's JSON output
katrinafyi Jul 20, 2024
05d37a5
review: avoid kind() classmethod
katrinafyi Jul 20, 2024
6155980
review: clarify MOTD serialisation comment
katrinafyi Jul 20, 2024
b42b1b7
review: simplify ping fallback logic
katrinafyi Jul 20, 2024
6ae1dbf
make version consistent between status and query
katrinafyi Jul 21, 2024
ceb43ff
review: apply simplify() to motd in CLI JSON output
katrinafyi Jul 21, 2024
1799c3d
review: use separate JSON field for simplified MOTD
katrinafyi Jul 22, 2024
50b825e
review: remove MOTD fixup comment
katrinafyi Jul 22, 2024
c23d40d
review: update README with new CLI
katrinafyi Jul 22, 2024
4ad7f6c
review: no raw motd
katrinafyi Jul 23, 2024
8d29673
no --help output in readme
katrinafyi Jul 24, 2024
06e8b80
review: allow main() with no arguments
katrinafyi Jul 25, 2024
f82ae9e
Update mcstatus/__main__.py
katrinafyi Jul 25, 2024
80fb48b
avoid json collision
katrinafyi Jul 25, 2024
f4fdabd
oops! good linter
katrinafyi Jul 25, 2024
2540089
drike review
katrinafyi Jul 25, 2024
551caa4
good linter
katrinafyi Jul 25, 2024
9189de7
one more ci failure and i turn on the computer
katrinafyi Jul 25, 2024
d690735
also squash ConnectionError
katrinafyi Jul 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mcstatus/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def json(server: SupportedServers) -> int:

if isinstance(server, JavaServer):
query_res = server.query(tries=1)
data["host_ip"] = query_res.raw["hostip"]
data["host_port"] = query_res.raw["hostport"]
data["host_ip"] = query_res.hostip
data["host_port"] = query_res.hostport
data["map"] = query_res.map
data["plugins"] = query_res.software.plugins
except Exception: # TODO: Check what this actually excepts
Expand All @@ -93,7 +93,7 @@ def query(server: SupportedServers) -> int:
)
return 1

print(f"host: {response.raw['hostip']}:{response.raw['hostport']}")
print(f"host: {response.hostip}:{response.hostport}")
print(f"software: v{response.software.version} {response.software.brand}")
print(f"plugins: {response.software.plugins}")
print(f"motd: {response.motd.to_ansi()}")
Expand Down
8 changes: 6 additions & 2 deletions mcstatus/querier.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ def __init__(self, version: str, plugins: str):
map: str
players: Players
software: Software
hostip: str
hostport: int

def __init__(self, raw: dict[str, str], players: list[str]):
try:
Expand All @@ -140,8 +142,10 @@ def __init__(self, raw: dict[str, str], players: list[str]):
self.map = raw["map"]
self.players = QueryResponse.Players(raw["numplayers"], raw["maxplayers"], players)
self.software = QueryResponse.Software(raw["version"], raw["plugins"])
except KeyError:
raise ValueError("The provided data is not valid")
self.hostip = raw["hostip"]
self.hostport = int(raw["hostport"])
except KeyError as e:
raise ValueError("The provided data is not valid") from e

@classmethod
def from_connection(cls, response: Connection) -> Self:
Expand Down