From c22548245228fd018adfe73b811479f17e41f4d1 Mon Sep 17 00:00:00 2001 From: Tristan Gosselin-Hane Date: Sat, 13 Oct 2018 04:41:43 -0400 Subject: [PATCH] Fixed bug that crashed the client when a user logged off Mojang does not provide the username in the remove player list packet --- webhook-bridge.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/webhook-bridge.py b/webhook-bridge.py index e9edc4d..1fc77a8 100755 --- a/webhook-bridge.py +++ b/webhook-bridge.py @@ -110,11 +110,18 @@ def main(): handle_tab_list, clientbound.play.PlayerListItemPacket) def handle_tab_list(tab_list_packet): + logging.debug("Processing tab list packet") for action in tab_list_packet.actions: if isinstance(action, clientbound.play.PlayerListItemPacket.AddPlayerAction): - UUID_CACHE[action.name] = action.uuid + logging.debug("Processing AddPlayerAction tab list packet, name: {}, uuid: {}".format(action.name, action.uuid)) + if action.name not in UUID_CACHE: + UUID_CACHE[action.name] = action.uuid if isinstance(action, clientbound.play.PlayerListItemPacket.RemovePlayerAction): - del UUID_CACHE[action.name] + logging.debug("Processing RemovePlayerAction tab list packet, uuid: {}".format(action.uuid)) + for username in UUID_CACHE: + if UUID_CACHE[username] == action.uuid: + del UUID_CACHE[username] + break def handle_join_game(join_game_packet): logging.info('Connected.')