fixing bcs web plugin

This commit is contained in:
Ayush Saini 2025-02-22 11:46:01 +05:30
parent be5a8f6104
commit 28dbe5fcd2
5 changed files with 50 additions and 24 deletions

View file

@ -67,12 +67,11 @@ party_name = "BombSquad Community Server"
# (see below). # (see below).
#session_type = "ffa" #session_type = "ffa"
# Playlist-code for teams or free-for-all mode sessions. # Playlist-code for teams or free-for-all mode sessions. To host
# To host your own custom playlists, use the 'share' functionality in the # your own custom playlists, use the 'share' functionality in the
# playlist editor in the regular version of the game. # playlist editor in the regular version of the game. This will give
# This will give you a numeric code you can enter here to host that # you a numeric code you can enter here to host that playlist.
# playlist. #playlist_code = 12345
playlist_code = 12345
# Alternately, you can embed playlist data here instead of using # Alternately, you can embed playlist data here instead of using
# codes. Make sure to set session_type to the correct type for the # codes. Make sure to set session_type to the correct type for the
@ -107,7 +106,7 @@ playlist_code = 12345
# Series length in teams mode (7 == 'best-of-7' series; a team must # Series length in teams mode (7 == 'best-of-7' series; a team must
# get 4 wins) # get 4 wins)
teams_series_length = 7 #teams_series_length = 7
# Points to win in free-for-all mode (Points are awarded per game # Points to win in free-for-all mode (Points are awarded per game
# based on performance) # based on performance)
@ -167,3 +166,10 @@ team_colors = [[0.8, 0.0, 0.6], [0, 1, 0.8]]
# before rejoining the game. This can help suppress exploits # before rejoining the game. This can help suppress exploits
# involving leaving and rejoining or switching teams rapidly. # involving leaving and rejoining or switching teams rapidly.
#player_rejoin_cooldown = 10.0 #player_rejoin_cooldown = 10.0
# Log levels for particular loggers, overriding the engine's
# defaults. Valid values are NOTSET, DEBUG, INFO, WARNING, ERROR, or
# CRITICAL.
#[log_levels]
#"ba.lifecycle" = "INFO"
#"ba.assets" = "INFO"

View file

@ -21,6 +21,8 @@ from typing import TYPE_CHECKING
import babase import babase
import bascenev1 as bs import bascenev1 as bs
import _bascenev1
from baclassic._appmode import ClassicAppMode
import bauiv1 as bui import bauiv1 as bui
import setting import setting
from baclassic._servermode import ServerController from baclassic._servermode import ServerController
@ -130,11 +132,6 @@ def bootstraping():
"""Bootstarps the server.""" """Bootstarps the server."""
logging.warning("Bootstraping mods...") logging.warning("Bootstraping mods...")
# server related # server related
# _bascenev1.set_server_name(settings["HostName"])
# _bascenev1.set_transparent_kickvote(settings["ShowKickVoteStarterName"])
# _bascenev1.set_kickvote_msg_type(settings["KickVoteMsgType"])
# bs.hide_player_device_id(settings["Anti-IdRevealer"]) TODO add call in
# cpp
# check for auto update stats # check for auto update stats
_thread.start_new_thread(mystats.refreshStats, ()) _thread.start_new_thread(mystats.refreshStats, ())
@ -417,3 +414,25 @@ def wrap_player_spaz_init(original_class):
playerspaz.PlayerSpaz = wrap_player_spaz_init(playerspaz.PlayerSpaz) playerspaz.PlayerSpaz = wrap_player_spaz_init(playerspaz.PlayerSpaz)
original_classic_app_mode_activate = ClassicAppMode.on_activate
def new_classic_app_mode_activate(*args, **kwargs):
# Call the original function
result = original_classic_app_mode_activate(*args, **kwargs)
# Perform additional actions after the original function call
on_classic_app_mode_active()
return result
ClassicAppMode.on_activate = new_classic_app_mode_activate
def on_classic_app_mode_active():
_bascenev1.set_server_name(settings["HostName"])
_bascenev1.set_transparent_kickvote(settings["ShowKickVoteStarterName"])
_bascenev1.set_kickvote_msg_type(settings["KickVoteMsgType"])
_bascenev1.hide_player_device_id(settings["Anti-IdRevealer"])

View file

@ -11,6 +11,7 @@ from functools import wraps
from threading import Thread from threading import Thread
import _babase import _babase
import _bascenev1
from flask import Flask, request, jsonify from flask import Flask, request, jsonify
# import uvicorn # import uvicorn
@ -42,7 +43,7 @@ def check_admin(func):
@wraps(func) @wraps(func)
def wrapper(*args, **kwargs): def wrapper(*args, **kwargs):
if "Secret-Key" not in request.headers or request.headers[ if "Secret-Key" not in request.headers or request.headers[
"Secret-Key"] != SECRET_KEY: "Secret-Key"] != SECRET_KEY:
return jsonify({"message": "Invalid secret key provided."}), 401 return jsonify({"message": "Invalid secret key provided."}), 401
return func(*args, **kwargs) return func(*args, **kwargs)
@ -277,7 +278,7 @@ def update_server_config():
def run_server(): def run_server():
from waitress import serve from waitress import serve
serve(app, host="0.0.0.0", port=_babase.get_game_port()) serve(app, host="0.0.0.0", port=_bascenev1.get_game_port())
def enable(password): def enable(password):

View file

@ -32,7 +32,7 @@ class BsDataThread(object):
stats["vapidKey"] = notification_manager.get_vapid_keys()["public_key"] stats["vapidKey"] = notification_manager.get_vapid_keys()["public_key"]
self.refresh_stats_cache_timer = bs.AppTimer(8, babase.Call( self.refresh_stats_cache_timer = bs.AppTimer(8, babase.Call(
self.refreshStats) , repeat=True) self.refreshStats), repeat=True)
self.refresh_leaderboard_cache_timer = bs.AppTimer(10, babase.Call( self.refresh_leaderboard_cache_timer = bs.AppTimer(10, babase.Call(
self.refreshLeaderboard), repeat=True) self.refreshLeaderboard), repeat=True)
@ -116,7 +116,8 @@ class BsDataThread(object):
return data return data
BsDataThread() v = bs.AppTimer(5, babase.Call(
BsDataThread))
def get_stats(): def get_stats():
@ -191,7 +192,7 @@ def search_player_profile(search_key: str, db: str):
if (search_key == key or if (search_key == key or
any(search_key.lower() in s.lower() for s in any(search_key.lower() in s.lower() for s in
selectedDB[key].get("display_string", [])) or selectedDB[key].get("display_string", [])) or
search_key.lower() in selectedDB[key].get("name", "").lower()): search_key.lower() in selectedDB[key].get("name", "").lower()):
matching_objects[key] = selectedDB[key] matching_objects[key] = selectedDB[key]
count += 1 count += 1
if count > 50: if count > 50:
@ -216,15 +217,15 @@ def get_player_details(account_id: str):
isBanned = True isBanned = True
extra_info += " , Banned for > " + haveBanReason extra_info += " , Banned for > " + haveBanReason
if account_id in pdata.get_blacklist()[ if account_id in pdata.get_blacklist()[
"muted-ids"] and current_time < datetime.strptime( "muted-ids"] and current_time < datetime.strptime(
pdata.get_blacklist()["muted-ids"][account_id]["till"], pdata.get_blacklist()["muted-ids"][account_id]["till"],
"%Y-%m-%d %H:%M:%S"): "%Y-%m-%d %H:%M:%S"):
isMuted = True isMuted = True
extra_info += f', Muted for > {pdata.get_blacklist()["muted-ids"][account_id]["reason"]} , till > {pdata.get_blacklist()["muted-ids"][account_id]["till"]} ,' extra_info += f', Muted for > {pdata.get_blacklist()["muted-ids"][account_id]["reason"]} , till > {pdata.get_blacklist()["muted-ids"][account_id]["till"]} ,'
if account_id in pdata.get_blacklist()[ if account_id in pdata.get_blacklist()[
"kick-vote-disabled"] and current_time < datetime.strptime( "kick-vote-disabled"] and current_time < datetime.strptime(
pdata.get_blacklist()["kick-vote-disabled"][account_id]["till"], pdata.get_blacklist()["kick-vote-disabled"][account_id]["till"],
"%Y-%m-%d %H:%M:%S"): "%Y-%m-%d %H:%M:%S"):
isKickVoteDisabled = True isKickVoteDisabled = True
extra_info += f', Kick vote disabled for > {pdata.get_blacklist()["kick-vote-disabled"][account_id]["reason"]} , till > {pdata.get_blacklist()["kick-vote-disabled"][account_id]["till"]} ' extra_info += f', Kick vote disabled for > {pdata.get_blacklist()["kick-vote-disabled"][account_id]["reason"]} , till > {pdata.get_blacklist()["kick-vote-disabled"][account_id]["till"]} '

View file

@ -48,7 +48,6 @@ def addhp(node, spaz):
position=(0, 1.75, 0), shad=1.4) position=(0, 1.75, 0), shad=1.4)
else: else:
spaz.hptimer = None spaz.hptimer = None
spaz.hptimer = bs.Timer(2, babase.Call( spaz.hptimer = bs.Timer(2, babase.Call(
showHP), repeat=True) showHP), repeat=True)