From 37e66927f055fd339805c7e643c46f6d27f3ad95 Mon Sep 17 00:00:00 2001 From: Sarasayed0118 <162738632+Sarasayed0118@users.noreply.github.com> Date: Sat, 20 Apr 2024 23:46:01 +0530 Subject: [PATCH] Update servercheck.py --- dist/ba_root/mods/tools/servercheck.py | 50 +++++++++++++++----------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/dist/ba_root/mods/tools/servercheck.py b/dist/ba_root/mods/tools/servercheck.py index 3ad10ff..de645cc 100644 --- a/dist/ba_root/mods/tools/servercheck.py +++ b/dist/ba_root/mods/tools/servercheck.py @@ -326,17 +326,21 @@ def on_player_join_server(pbid, player_data, ip, device_id): verify_account(pbid, player_data) # checked for spoofed ids logger.log( f'{pbid} ip: {serverdata.clients[pbid]["lastIP"]} , Device id: {device_id}') - if settings["ServerForWhitelistplayers"]["enable"]: - check_whitelist_player(clid,pbid) - _ba.screenmessage(settings["regularWelcomeMsg"] + " " + device_string, - color=(0.60, 0.8, 0.6), transient=True, - clients=[clid]) - notification_manager.player_joined(pbid) - if settings["JoinClaim"]: - jc.join_claim(device_string, clid, pbid) - # notify players - if settings["NotifyPlayer"]: - check_notify_mongo(clid,pbid) + def player_join_logic(): + if settings["ServerForWhitelistplayers"]["enable"]: + check_whitelist_player(clid, pbid) + # This logic should only be executed in the main thread + ba.screenmessage(settings["regularWelcomeMsg"] + " " + device_string, + color=(0.60, 0.8, 0.6), transient=True, + clients=[clid]) + notification_manager.player_joined(pbid) + if settings["JoinClaim"]: + jc.join_claim(device_string, clid, pbid) + # Notify players + if settings["NotifyPlayer"]: + check_notify_mongo(clid, pbid) + # Ensure the logic is executed from the main thread + _ba.pushcall(Call(player_join_logic)) else: # fetch id for first time. thread = FetchThread( @@ -347,16 +351,20 @@ def on_player_join_server(pbid, player_data, ip, device_id): ) thread.start() - if settings["ServerForWhitelistplayers"]["enable"]: - check_whitelist_player(clid,pbid) - _ba.screenmessage(settings["firstTimeJoinMsg"], color=(0.6, 0.8, 0.6), - transient=True, clients=[clid]) - notification_manager.player_joined(pbid) - if settings["JoinClaim"]: - jc.join_claim(device_string, clid, pbid) - # notify players - if settings["NotifyPlayer"]: - check_notify_mongo(clid,pbid) + def player_join_logic(): + if settings["ServerForWhitelistplayers"]["enable"]: + check_whitelist_player(clid, pbid) + # This logic should only be executed in the main thread + _ba.screenmessage(settings["firstTimeJoinMsg"], color=(0.6, 0.8, 0.6), + transient=True, clients=[clid]) + notification_manager.player_joined(pbid) + if settings["JoinClaim"]: + jc.join_claim(device_string, clid, pbid) + # Notify players + if settings["NotifyPlayer"]: + check_notify_mongo(clid, pbid) + # Ensure the logic is executed from the main thread + _ba.pushcall(Call(player_join_logic)) # pdata.add_profile(pbid,d_string,d_string)