mirror of
https://github.com/imayushsaini/Bombsquad-Ballistica-Modded-Server.git
synced 2025-11-07 17:36:15 +00:00
End Vote system
This commit is contained in:
parent
db6bad9f59
commit
a2c7b303d0
4 changed files with 154 additions and 72 deletions
70
dist/ba_root/mods/custom_hooks.py
vendored
70
dist/ba_root/mods/custom_hooks.py
vendored
|
|
@ -14,6 +14,7 @@ from datetime import datetime
|
|||
|
||||
import _thread
|
||||
import importlib
|
||||
import time
|
||||
import os
|
||||
import ba
|
||||
import _ba
|
||||
|
|
@ -29,11 +30,11 @@ from stats import mystats
|
|||
from spazmod import modifyspaz
|
||||
from tools import servercheck, ServerUpdate, logger
|
||||
from playersData import pdata
|
||||
from features import EndVote
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Optional, Any
|
||||
|
||||
|
||||
settings = setting.get_settings_data()
|
||||
|
||||
|
||||
|
|
@ -72,9 +73,9 @@ def bootstraping():
|
|||
_ba.set_kickvote_msg_type(settings["KickVoteMsgType"])
|
||||
|
||||
# check for auto update stats
|
||||
_thread.start_new_thread(mystats.refreshStats,())
|
||||
_thread.start_new_thread(mystats.refreshStats, ())
|
||||
pdata.load_cache()
|
||||
_thread.start_new_thread(pdata.dump_cache,())
|
||||
_thread.start_new_thread(pdata.dump_cache, ())
|
||||
|
||||
# import plugins
|
||||
if settings["elPatronPowerups"]["enable"]:
|
||||
|
|
@ -108,65 +109,73 @@ def import_discord_bot() -> None:
|
|||
"""Imports the discord bot."""
|
||||
if settings["discordbot"]["enable"]:
|
||||
from features import discord_bot
|
||||
discord_bot.token=settings["discordbot"]["token"]
|
||||
discord_bot.liveStatsChannelID=settings["discordbot"]["liveStatsChannelID"]
|
||||
discord_bot.logsChannelID=settings["discordbot"]["logsChannelID"]
|
||||
discord_bot.liveChat=settings["discordbot"]["liveChat"]
|
||||
discord_bot.token = settings["discordbot"]["token"]
|
||||
discord_bot.liveStatsChannelID = settings["discordbot"]["liveStatsChannelID"]
|
||||
discord_bot.logsChannelID = settings["discordbot"]["logsChannelID"]
|
||||
discord_bot.liveChat = settings["discordbot"]["liveChat"]
|
||||
discord_bot.BsDataThread()
|
||||
discord_bot.init()
|
||||
|
||||
|
||||
def import_games():
|
||||
"""Imports the custom games from games directory."""
|
||||
import sys
|
||||
sys.path.append(_ba.env()['python_directory_user']+os.sep+"games")
|
||||
games=os.listdir("ba_root/mods/games")
|
||||
sys.path.append(_ba.env()['python_directory_user'] + os.sep + "games")
|
||||
games = os.listdir("ba_root/mods/games")
|
||||
for game in games:
|
||||
if game.endswith(".so"):
|
||||
importlib.import_module("games."+game.replace(".so",""))
|
||||
importlib.import_module("games." + game.replace(".so", ""))
|
||||
|
||||
maps=os.listdir("ba_root/mods/maps")
|
||||
maps = os.listdir("ba_root/mods/maps")
|
||||
for _map in maps:
|
||||
if _map.endswith(".py") or _map.endswith(".so"):
|
||||
importlib.import_module("maps."+_map.replace(".so","").replace(".py",""))
|
||||
importlib.import_module("maps." + _map.replace(".so", "").replace(".py", ""))
|
||||
|
||||
|
||||
def import_dual_team_score() -> None:
|
||||
"""Imports the dual team score."""
|
||||
if settings["newResultBoard"]:
|
||||
dualteamscore.TeamVictoryScoreScreenActivity= newdts.TeamVictoryScoreScreenActivity
|
||||
dualteamscore.TeamVictoryScoreScreenActivity = newdts.TeamVictoryScoreScreenActivity
|
||||
multiteamscore.MultiTeamScoreScreenActivity.show_player_scores = newdts.show_player_scores
|
||||
drawscore.DrawScoreScreenActivity=newdts.DrawScoreScreenActivity
|
||||
drawscore.DrawScoreScreenActivity = newdts.DrawScoreScreenActivity
|
||||
|
||||
|
||||
org_begin = ba._activity.Activity.on_begin
|
||||
|
||||
|
||||
def new_begin(self):
|
||||
"""Runs when game is began."""
|
||||
org_begin(self)
|
||||
night_mode()
|
||||
EndVote.voters = []
|
||||
EndVote.game_started_on = time.time()
|
||||
|
||||
|
||||
ba._activity.Activity.on_begin = new_begin
|
||||
|
||||
org_end = ba._activity.Activity.end
|
||||
|
||||
org_end=ba._activity.Activity.end
|
||||
|
||||
def new_end(self,results:Any=None,delay:float=0.0,force:bool=False):
|
||||
def new_end(self, results: Any = None, delay: float = 0.0, force: bool = False):
|
||||
"""Runs when game is ended."""
|
||||
activity=_ba.get_foreground_host_activity()
|
||||
if isinstance(activity,CoopScoreScreen):
|
||||
activity = _ba.get_foreground_host_activity()
|
||||
if isinstance(activity, CoopScoreScreen):
|
||||
team_balancer.checkToExitCoop()
|
||||
org_end(self,results,delay,force)
|
||||
|
||||
ba._activity.Activity.end=new_end
|
||||
org_end(self, results, delay, force)
|
||||
|
||||
|
||||
org_player_join=ba._activity.Activity.on_player_join
|
||||
ba._activity.Activity.end = new_end
|
||||
|
||||
org_player_join = ba._activity.Activity.on_player_join
|
||||
|
||||
|
||||
def on_player_join(self, player) -> None:
|
||||
"""Runs when player joins the game."""
|
||||
team_balancer.on_player_join()
|
||||
org_player_join(self,player)
|
||||
org_player_join(self, player)
|
||||
|
||||
ba._activity.Activity.on_player_join=on_player_join
|
||||
|
||||
ba._activity.Activity.on_player_join = on_player_join
|
||||
|
||||
|
||||
def night_mode() -> None:
|
||||
|
|
@ -174,9 +183,9 @@ def night_mode() -> None:
|
|||
|
||||
if settings['autoNightMode']['enable']:
|
||||
|
||||
start=datetime.strptime(settings['autoNightMode']['startTime'],"%H:%M")
|
||||
end=datetime.strptime(settings['autoNightMode']['endTime'],"%H:%M")
|
||||
now=datetime.now()
|
||||
start = datetime.strptime(settings['autoNightMode']['startTime'], "%H:%M")
|
||||
end = datetime.strptime(settings['autoNightMode']['endTime'], "%H:%M")
|
||||
now = datetime.now()
|
||||
|
||||
if now.time() > start.time() or now.time() < end.time():
|
||||
activity = _ba.get_foreground_host_activity()
|
||||
|
|
@ -187,8 +196,7 @@ def night_mode() -> None:
|
|||
fire_flies.factory(settings['autoNightMode']["fireflies_random_color"])
|
||||
|
||||
|
||||
|
||||
def kick_vote_started(started_by: str,started_to: str) -> None:
|
||||
def kick_vote_started(started_by: str, started_to: str) -> None:
|
||||
"""Logs the kick vote."""
|
||||
logger.log(f"{started_by} started kick vote for {started_to}.")
|
||||
|
||||
|
|
@ -203,5 +211,5 @@ def on_kick_vote_end():
|
|||
logger.log("Kick vote End")
|
||||
|
||||
|
||||
_hooks.kick_vote_started=kick_vote_started
|
||||
_hooks.on_kicked=on_kicked
|
||||
_hooks.kick_vote_started = kick_vote_started
|
||||
_hooks.on_kicked = on_kicked
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue