diff --git a/plugins/utilities/advanced_party_window.py b/plugins/utilities/advanced_party_window.py index d40b718..8f36b02 100644 --- a/plugins/utilities/advanced_party_window.py +++ b/plugins/utilities/advanced_party_window.py @@ -67,7 +67,7 @@ ssl._create_default_https_context = ssl._create_unverified_context def newconnect_to_party(address, port=43210, print_progress=False): global ip_add global p_port - + dd = _ba.get_connection_to_host_info() if (dd != {}): _ba.disconnect_from_host() @@ -1724,7 +1724,7 @@ def fetchAccountInfo(account, loading_widget): if account in fdata: servers = fdata[account] url = f'https://{BCSSERVER}/player?key={base64.b64encode(account.encode("utf-8")).decode("utf-8")}&base64=true' - + data = urllib.request.urlopen(url) account_data = json.loads(data.read().decode('utf-8'))[0] pbid = account_data["pbid"] @@ -2175,6 +2175,8 @@ class CustomAccountViewerWindow(viewer.AccountViewerWindow): ba.print_exception('Error displaying account info.') # ba_meta export plugin + + class bySmoothy(ba.Plugin): def __init__(self): if _ba.env().get("build_number", 0) >= 20577: diff --git a/plugins/utilities/easy_connect.py b/plugins/utilities/easy_connect.py index 3b3a26e..d14745c 100644 --- a/plugins/utilities/easy_connect.py +++ b/plugins/utilities/easy_connect.py @@ -63,6 +63,7 @@ https://ballistica.net/discord """ BCSURL = 'https://bcsserver.bombsquad.ga/bannedservers' + def is_game_version_lower_than(version): """ Returns a boolean value indicating whether the current game @@ -79,6 +80,7 @@ if is_game_version_lower_than("1.7.7"): else: ba_internal = ba.internal + def updateBannedServersCache(): response = None config = ba.app.config @@ -508,61 +510,62 @@ def popup_menu_selected_choice(self, window: popup.PopupMenu, def _update_party_lists(self) -> None: - if not self._party_lists_dirty: - return - starttime = time.time() - config = ba.app.config - bannedservers = config.get('Banned Servers',[]) - assert len(self._parties_sorted) == len(self._parties) + if not self._party_lists_dirty: + return + starttime = time.time() + config = ba.app.config + bannedservers = config.get('Banned Servers', []) + assert len(self._parties_sorted) == len(self._parties) - self._parties_sorted.sort( - key=lambda p: ( - p[1].ping if p[1].ping is not None else 999999.0, - p[1].index, - ) + self._parties_sorted.sort( + key=lambda p: ( + p[1].ping if p[1].ping is not None else 999999.0, + p[1].index, + ) + ) + + # If signed out or errored, show no parties. + if ( + ba.internal.get_v1_account_state() != 'signed_in' + or not self._have_valid_server_list + ): + self._parties_displayed = {} + else: + if self._filter_value: + filterval = self._filter_value.lower() + self._parties_displayed = { + k: v + for k, v in self._parties_sorted + if (filterval in v.name.lower() or filterval in v.address) and (v.address not in bannedservers if ENABLE_SERVER_BANNING else True) + } + else: + self._parties_displayed = { + k: v + for k, v in self._parties_sorted + if (v.address not in bannedservers if ENABLE_SERVER_BANNING else True) + } + + # Any time our selection disappears from the displayed list, go back to + # auto-selecting the top entry. + if ( + self._selection is not None + and self._selection.entry_key not in self._parties_displayed + ): + self._have_user_selected_row = False + + # Whenever the user hasn't selected something, keep the first visible + # row selected. + if not self._have_user_selected_row and self._parties_displayed: + firstpartykey = next(iter(self._parties_displayed)) + self._selection = Selection(firstpartykey, SelectionComponent.NAME) + + self._party_lists_dirty = False + if DEBUG_PROCESSING: + print( + f'Sorted {len(self._parties_sorted)} parties in' + f' {time.time()-starttime:.5f}s.' ) - # If signed out or errored, show no parties. - if ( - ba.internal.get_v1_account_state() != 'signed_in' - or not self._have_valid_server_list - ): - self._parties_displayed = {} - else: - if self._filter_value: - filterval = self._filter_value.lower() - self._parties_displayed = { - k: v - for k, v in self._parties_sorted - if (filterval in v.name.lower() or filterval in v.address) and (v.address not in bannedservers if ENABLE_SERVER_BANNING else True) - } - else: - self._parties_displayed = { - k: v - for k, v in self._parties_sorted - if (v.address not in bannedservers if ENABLE_SERVER_BANNING else True) - } - - # Any time our selection disappears from the displayed list, go back to - # auto-selecting the top entry. - if ( - self._selection is not None - and self._selection.entry_key not in self._parties_displayed - ): - self._have_user_selected_row = False - - # Whenever the user hasn't selected something, keep the first visible - # row selected. - if not self._have_user_selected_row and self._parties_displayed: - firstpartykey = next(iter(self._parties_displayed)) - self._selection = Selection(firstpartykey, SelectionComponent.NAME) - - self._party_lists_dirty = False - if DEBUG_PROCESSING: - print( - f'Sorted {len(self._parties_sorted)} parties in' - f' {time.time()-starttime:.5f}s.' - ) def replace(): manualtab.ManualGatherTab._build_favorites_tab = new_build_favorites_tab @@ -697,5 +700,5 @@ class InitalRun(ba.Plugin): def __init__(self): replace() config = ba.app.config - if config["launchCount"]% 5 ==0: + if config["launchCount"] % 5 == 0: updateBannedServersCache()