diff --git a/CommonClient.py b/CommonClient.py index 3665b9f1..a7b7828a 100644 --- a/CommonClient.py +++ b/CommonClient.py @@ -20,8 +20,8 @@ if __name__ == "__main__": Utils.init_logging("TextClient", exception_logger="Client") from MultiServer import CommandProcessor -from NetUtils import Endpoint, decode, NetworkItem, encode, JSONtoTextParser, \ - ClientStatus, Permission, NetworkSlot, RawJSONtoTextParser +from NetUtils import (Endpoint, decode, NetworkItem, encode, JSONtoTextParser, ClientStatus, Permission, NetworkSlot, + RawJSONtoTextParser, add_json_text, add_json_location, add_json_item, JSONTypes) from Utils import Version, stream_input, async_start from worlds import network_data_package, AutoWorldRegister import os @@ -72,9 +72,16 @@ class ClientCommandProcessor(CommandProcessor): def _cmd_received(self) -> bool: """List all received items""" - self.output(f'{len(self.ctx.items_received)} received items:') + item: NetworkItem + self.output(f'{len(self.ctx.items_received)} received items, sorted by time:') for index, item in enumerate(self.ctx.items_received, 1): - self.output(f"{self.ctx.item_names[item.item]} from {self.ctx.player_names[item.player]}") + parts = [] + add_json_item(parts, item.item, self.ctx.slot, item.flags) + add_json_text(parts, " from ") + add_json_location(parts, item.location, item.player) + add_json_text(parts, " by ") + add_json_text(parts, item.player, type=JSONTypes.player_id) + self.ctx.on_print_json({"data": parts, "cmd": "PrintJSON"}) return True def _cmd_missing(self, filter_text = "") -> bool: diff --git a/NetUtils.py b/NetUtils.py index a2db6a2a..8fc3929e 100644 --- a/NetUtils.py +++ b/NetUtils.py @@ -290,8 +290,8 @@ def add_json_item(parts: list, item_id: int, player: int = 0, item_flags: int = parts.append({"text": str(item_id), "player": player, "flags": item_flags, "type": JSONTypes.item_id, **kwargs}) -def add_json_location(parts: list, item_id: int, player: int = 0, **kwargs) -> None: - parts.append({"text": str(item_id), "player": player, "type": JSONTypes.location_id, **kwargs}) +def add_json_location(parts: list, location_id: int, player: int = 0, **kwargs) -> None: + parts.append({"text": str(location_id), "player": player, "type": JSONTypes.location_id, **kwargs}) class Hint(typing.NamedTuple):