bug fixes, servermanager link in stats, toml to json config

This commit is contained in:
Ayush Saini 2025-04-13 12:17:10 +05:30
parent 039c7d3645
commit a2cf2bfcb6
8 changed files with 88 additions and 206 deletions

44
config.json Normal file
View file

@ -0,0 +1,44 @@
{
"party_name":"BombSquad Community Server",
"party_is_public":true,
"authenticate_clients":true,
"admins":[
"pb-yOuRAccOuNtIdHErE",
"pb-aNdMayBeAnotherHeRE"
],
"enable_default_kick_voting":true,
"port":43210,
"max_party_size":6,
"session_max_players_override":8,
"session_type":"ffa",
"playlist_code":12345,
"playlist_shuffle":true,
"auto_balance_teams":true,
"enable_telnet":false,
"teams_series_length":7,
"ffa_series_length":24,
"stats_url":"https://discord.gg/ucyaesh",
"clean_exit_minutes":60,
"unclean_exit_minutes":90,
"idle_exit_minutes":20,
"show_tutorial":false,
"team_names":[
"ladoo",
"barfi"
],
"team_colors":[
[
0.8,
0.0,
0.6
],
[
0,
1,
0.8
]
],
"enable_queue":true,
"protocol_version":35,
"player_rejoin_cooldown":10.0
}

View file

@ -1,175 +0,0 @@
# To configure your server, create a config.toml file in the same directory
# as the ballisticakit_server script. The config_template.toml file can be
# copied or renamed as a convenient starting point.
# Uncomment any of these values to override defaults.
# Name of our server in the public parties list.
party_name = "BombSquad Community Server"
# If true, your party will show up in the global public party list
# Otherwise it will still be joinable via LAN or connecting by IP
# address.
#party_is_public = true
# If true, all connecting clients will be authenticated through the
# master server to screen for fake account info. Generally this
# should always be enabled unless you are hosting on a LAN with no
# internet connection.
#authenticate_clients = true
# IDs of server admins. Server admins are not kickable through the
# default kick vote system and they are able to kick players without
# a vote. To get your account id, enter 'getaccountid' in
# settings->advanced->enter-code.
#admins = ["pb-yOuRAccOuNtIdHErE", "pb-aNdMayBeAnotherHeRE"]
# Whether the default kick-voting system is enabled.
#enable_default_kick_voting = true
# To be included in the public server list, your server MUST be
# accessible via an ipv4 address. By default, the master server will
# try to use the address your server contacts it from, but this may
# be an ipv6 address these days so you may need to provide an ipv4
# address explicitly.
#public_ipv4_address = "123.123.123.123"
# You can optionally provide an ipv6 address for your server for the
# public server list. Unlike ipv4, a server is not required to have
# an ipv6 address to appear in the list, but is still good to
# provide when available since more and more devices are using ipv6
# these days. Your server's ipv6 address will be autodetected if
# your server uses ipv6 when communicating with the master server. You
# can pass an empty string here to explicitly disable the ipv6
# address.
#public_ipv6_address = "123A::A123:23A1:A312:12A3:A213:2A13"
# UDP port to host on. Change this to work around firewalls or run
# multiple servers on one machine.
#
# 43210 is the default and the only port that will show up in the
# LAN browser tab.
#port = 43210
# Max devices in the party. Note that this does *NOT* mean max
# players. Any device in the party can have more than one player on
# it if they have multiple controllers. Also, this number currently
# includes the server so generally make it 1 bigger than you need.
#max_party_size = 6
# Max players that can join a session. If present this will override
# the session's preferred max_players. if a value below 0 is given
# player limit will be removed.
#session_max_players_override = 8
# Options here are 'ffa' (free-for-all), 'teams' and 'coop'
# (cooperative) This value is ignored if you supply a playlist_code
# (see below).
#session_type = "ffa"
# Playlist-code for teams or free-for-all mode sessions. To host
# your own custom playlists, use the 'share' functionality in the
# playlist editor in the regular version of the game. This will give
# you a numeric code you can enter here to host that playlist.
#playlist_code = 12345
# Alternately, you can embed playlist data here instead of using
# codes. Make sure to set session_type to the correct type for the
# data here.
#playlist_inline = []
# Whether to shuffle the playlist or play its games in designated
# order.
#playlist_shuffle = true
# If true, keeps team sizes equal by disallowing joining the largest
# team (teams mode only).
#auto_balance_teams = true
# The campaign used when in co-op session mode. Do
# print(ba.app.campaigns) to see available campaign names.
#coop_campaign = "Easy"
# The level name within the campaign used in co-op session mode. For
# campaign name FOO, do print(ba.app.campaigns['FOO'].levels) to see
# available level names.
#coop_level = "Onslaught Training"
# Whether to enable telnet access.
#
# IMPORTANT: This option is no longer available, as it was being
# used for exploits. Live access to the running server is still
# possible through the mgr.cmd() function in the server script. Run
# your server through tools such as 'screen' or 'tmux' and you can
# reconnect to it remotely over a secure ssh connection.
#enable_telnet = false
# Series length in teams mode (7 == 'best-of-7' series; a team must
# get 4 wins)
#teams_series_length = 7
# Points to win in free-for-all mode (Points are awarded per game
# based on performance)
#ffa_series_length = 24
# If you have a custom stats webpage for your server, you can use
# this to provide a convenient in-game link to it in the
# server-browser alongside the server name.
#
# if ${ACCOUNT} is present in the string, it will be replaced by the
# currently-signed-in account's id. To fetch info about an account,
# your back-end server can use the following url:
# https://legacy.ballistica.net/accountquery?id=ACCOUNT_ID_HERE
stats_url = "https://discord.gg/ucyaesh"
# If present, the server subprocess will attempt to gracefully exit
# after this amount of time. A graceful exit can occur at the end of
# a series or other opportune time. Server-managers set to
# auto-restart (the default) will then spin up a fresh subprocess.
# This mechanism can be useful to clear out any memory leaks or
# other accumulated bad state in the server subprocess.
#clean_exit_minutes = 60
# If present, the server subprocess will shut down immediately after
# this amount of time. This can be useful as a fallback for
# clean_exit_time. The server manager will then spin up a fresh
# server subprocess if auto-restart is enabled (the default).
#unclean_exit_minutes = 90
# If present, the server subprocess will shut down immediately if
# this amount of time passes with no activity from any players. The
# server manager will then spin up a fresh server subprocess if
# auto-restart is enabled (the default).
#idle_exit_minutes = 20
# Should the tutorial be shown at the beginning of games?
#show_tutorial = false
# Team names (teams mode only).
team_names = ["ladoo", "barfi"]
# Team colors (teams mode only).
team_colors = [[0.8, 0.0, 0.6], [0, 1, 0.8]]
# Whether to enable the queue where players can line up before
# entering your server. Disabling this can be used as a workaround
# to deal with queue spamming attacks.
#enable_queue = true
# Protocol version we host with. Currently the default is 33 which
# still allows older 1.4 game clients to connect. Explicitly setting
# to 35 no longer allows those clients but adds/fixes a few things
# such as making camera shake properly work in net games.
#protocol_version = 35
# How many seconds individual players from a given account must wait
# before rejoining the game. This can help suppress exploits
# involving leaving and rejoining or switching teams rapidly.
#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

@ -381,7 +381,19 @@ def on_player_request(func) -> bool:
Session.on_player_request = on_player_request(Session.on_player_request)
ServerController._access_check_response = servercontroller._access_check_response
def on_access_check_response(self, data):
if data is not None:
addr = data['address']
port = data['port']
if settings["ballistica_web"]["enable"]:
bs.set_public_party_stats_url(
f'https://bombsquad-community.web.app/server-manager/?host={addr}&port={port}')
servercontroller._access_check_response(self, data)
ServerController._access_check_response = on_access_check_response
def wrap_player_spaz_init(original_class):

View file

@ -10,13 +10,13 @@ party_name = "BombSquad Community Server"
# If true, your party will show up in the global public party list
# Otherwise it will still be joinable via LAN or connecting by IP
# address.
#party_is_public = true
party_is_public = true
# If true, all connecting clients will be authenticated through the
# master server to screen for fake account info. Generally this
# should always be enabled unless you are hosting on a LAN with no
# internet connection.
#authenticate_clients = true
authenticate_clients = true
# IDs of server admins. Server admins are not kickable through the default
# kick vote system and they are able to kick players without a vote. To get
@ -24,7 +24,7 @@ party_name = "BombSquad Community Server"
admins = ["pb-yOuRAccOuNtIdHErE", "pb-aNdMayBeAnotherHeRE"]
# Whether the default kick-voting system is enabled.
#enable_default_kick_voting = true
enable_default_kick_voting = true
# To be included in the public server list, your server MUST be
# accessible via an ipv4 address. By default, the master server will
@ -48,23 +48,23 @@ admins = ["pb-yOuRAccOuNtIdHErE", "pb-aNdMayBeAnotherHeRE"]
#
# 43210 is the default and the only port that will show up in the
# LAN browser tab.
#port = 43210
port = 43210
# Max devices in the party. Note that this does *NOT* mean max
# players. Any device in the party can have more than one player on
# it if they have multiple controllers. Also, this number currently
# includes the server so generally make it 1 bigger than you need.
#max_party_size = 6
max_party_size = 6
# Max players that can join a session. If present this will override
# the session's preferred max_players. if a value below 0 is given
# player limit will be removed.
#session_max_players_override = 8
session_max_players_override = 8
# Options here are 'ffa' (free-for-all), 'teams' and 'coop'
# (cooperative) This value is ignored if you supply a playlist_code
# (see below).
#session_type = "ffa"
session_type = "ffa"
# Playlist-code for teams or free-for-all mode sessions.
# To host your own custom playlists, use the 'share' functionality in the
@ -80,11 +80,11 @@ playlist_code = 12345
# Whether to shuffle the playlist or play its games in designated
# order.
#playlist_shuffle = true
playlist_shuffle = true
# If true, keeps team sizes equal by disallowing joining the largest
# team (teams mode only).
#auto_balance_teams = true
auto_balance_teams = true
# The campaign used when in co-op session mode. Do
# print(ba.app.campaigns) to see available campaign names.
@ -102,7 +102,7 @@ playlist_code = 12345
# possible through the mgr.cmd() function in the server script. Run
# your server through tools such as 'screen' or 'tmux' and you can
# reconnect to it remotely over a secure ssh connection.
#enable_telnet = false
enable_telnet = false
# Series length in teams mode (7 == 'best-of-7' series; a team must
# get 4 wins)
@ -128,22 +128,22 @@ stats_url = "https://discord.gg/ucyaesh"
# auto-restart (the default) will then spin up a fresh subprocess.
# This mechanism can be useful to clear out any memory leaks or
# other accumulated bad state in the server subprocess.
#clean_exit_minutes = 60
clean_exit_minutes = 60
# If present, the server subprocess will shut down immediately after
# this amount of time. This can be useful as a fallback for
# clean_exit_time. The server manager will then spin up a fresh
# server subprocess if auto-restart is enabled (the default).
#unclean_exit_minutes = 90
unclean_exit_minutes = 90
# If present, the server subprocess will shut down immediately if
# this amount of time passes with no activity from any players. The
# server manager will then spin up a fresh server subprocess if
# auto-restart is enabled (the default).
#idle_exit_minutes = 20
idle_exit_minutes = 20
# Should the tutorial be shown at the beginning of games?
#show_tutorial = false
show_tutorial = false
# Team names (teams mode only).
team_names = ["ladoo", "barfi"]
@ -154,15 +154,15 @@ team_colors = [[0.8, 0.0, 0.6], [0, 1, 0.8]]
# Whether to enable the queue where players can line up before
# entering your server. Disabling this can be used as a workaround
# to deal with queue spamming attacks.
#enable_queue = true
enable_queue = true
# Protocol version we host with. Currently the default is 33 which
# still allows older 1.4 game clients to connect. Explicitly setting
# to 35 no longer allows those clients but adds/fixes a few things
# such as making camera shake properly work in net games.
#protocol_version = 35
protocol_version = 35
# How many seconds individual players from a given account must wait
# before rejoining the game. This can help suppress exploits
# involving leaving and rejoining or switching teams rapidly.
#player_rejoin_cooldown = 10.0
player_rejoin_cooldown = 10.0

View file

@ -15,7 +15,7 @@ cLastIdle = 0
class checkIdle(object):
def start(self):
self.t1 = bs.timer(2, babase.Call(self.check), repeat=True)
self.t1 = bs.AppTimer(2, babase.Call(self.check), repeat=True)
self.lobbies = {}
def check(self):

View file

@ -3,6 +3,7 @@
import time
import _babase
import _bascenev1
import bascenev1 as bs
@ -81,11 +82,11 @@ def vote(pb_id, client_id, vote_type):
except:
pass
elif vote_type == "nv":
_babase.chatmessage("/nv")
_bascenev1.chatmessage("/nv")
elif vote_type == "dv":
_babase.chatmessage("/dv")
_bascenev1.chatmessage("/dv")
elif vote_type == "sm":
_babase.chatmessage("/sm")
_bascenev1.chatmessage("/sm")
def reset_votes():

View file

@ -16,6 +16,7 @@ from typing import Type
import babase
import bascenev1 as bs
from tools import servercheck, logger, notification_manager
from tools.file_handle import OpenJson
stats = {}
leaderboard = {}
@ -29,7 +30,7 @@ class BsDataThread(object):
global stats
stats["name"] = _babase.app.classic.server._config.party_name
stats["discord"] = get_server_settings(
)["ballistica_web"]["server_password"]
)["ballistica_web"]["discord_link"]
stats["vapidKey"] = notification_manager.get_vapid_keys()["public_key"]
self.refresh_stats_cache_timer = bs.AppTimer(8, babase.Call(
@ -117,7 +118,7 @@ class BsDataThread(object):
return data
v = bs.AppTimer(5, babase.Call(
v = bs.AppTimer(8, babase.Call(
BsDataThread))
@ -273,10 +274,10 @@ def get_server_config():
def update_server_config(config):
current_dir = os.getcwd()
file_path = os.path.join(current_dir, '..', 'config.yaml')
file_path = os.path.join(current_dir, '..', 'config.json')
with open(file_path, "w") as f:
f.write(yaml.dump(config))
with OpenJson(file_path) as f:
f.dump(config, indent=4)
def do_action(action, value):

View file

@ -1,4 +1,4 @@
# ba_meta require api 8
# ba_meta require api 9
'''
Character Chooser by Mr.Smoothy
@ -36,7 +36,6 @@ from typing import TYPE_CHECKING
import babase
import bauiv1 as bui
from babase._error import print_error
from babase._language import Lstr
if TYPE_CHECKING:
@ -248,11 +247,11 @@ def handlemessage(self, msg: Any) -> Any:
# If we've been removed from the lobby, ignore this stuff.
if self._dead:
print_error('chooser got ChangeMessage after dying')
print('chooser got ChangeMessage after dying')
return
if not self._text_node:
print_error('got ChangeMessage after nodes died')
print('got ChangeMessage after nodes died')
return
if msg.what == 'characterchooser':
self._click_sound.play()