mirror of
https://github.com/imayushsaini/Bombsquad-Ballistica-Modded-Server.git
synced 2025-11-14 17:46:03 +00:00
Custom characters intigration and plugin switches.
Custom characters plugin. true/false switch in settings for character chooser and custom characters. (defaulty true) Fixed path of bcs_plugin. Removed duplicate of bcs plugin.
This commit is contained in:
parent
837af6666b
commit
6ad7972a4b
7 changed files with 63 additions and 128 deletions
9
dist/ba_root/config.json
vendored
9
dist/ba_root/config.json
vendored
|
|
@ -434,15 +434,6 @@
|
|||
"Plugins": {
|
||||
"plugins.Init": {
|
||||
"enabled": true
|
||||
},
|
||||
"plugins.CharacterChooser.HeySmoothy": {
|
||||
"enabled": true
|
||||
},
|
||||
"plugins.bombsquadhttpapi.HeySmoothy": {
|
||||
"enabled": false
|
||||
},
|
||||
"plugins.importcustomcharacters.HeySmoothy": {
|
||||
"enabled": false
|
||||
}
|
||||
},
|
||||
"Port": 43210,
|
||||
|
|
|
|||
6
dist/ba_root/mods/custom_hooks.py
vendored
6
dist/ba_root/mods/custom_hooks.py
vendored
|
|
@ -86,6 +86,12 @@ def bootstraping():
|
|||
if settings["ballistica_web"]["enable"]:
|
||||
from plugins import bcs_plugin
|
||||
bcs_plugin.enable()
|
||||
if settings["character_chooser"]["enable"]:
|
||||
from plugins import CharacterChooser
|
||||
CharacterChooser.enable()
|
||||
if settings["custom_characters"]["enable"]:
|
||||
from plugins import importcustomcharacters
|
||||
importcustomcharacters.enable()
|
||||
|
||||
# import features
|
||||
if settings["whitelist"]:
|
||||
|
|
|
|||
|
|
@ -346,15 +346,9 @@ def _update_text(self) -> None:
|
|||
|
||||
self._text_node.text = text
|
||||
|
||||
# ba_meta export plugin
|
||||
class HeySmoothy(ba.Plugin):
|
||||
|
||||
def __init__(self):
|
||||
def enable() -> None:
|
||||
_lobby.Chooser.__init__=__init__
|
||||
_lobby.Chooser._set_ready=_set_ready
|
||||
|
||||
_lobby.Chooser._update_text=_update_text
|
||||
_lobby.Chooser.handlemessage=handlemessage
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
61
dist/ba_root/mods/plugins/bombsquadhttpapi.py
vendored
61
dist/ba_root/mods/plugins/bombsquadhttpapi.py
vendored
|
|
@ -1,61 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# coding: utf-8
|
||||
|
||||
# ba_meta require api 6
|
||||
import ba,_ba
|
||||
import json
|
||||
|
||||
# for flask app ==================
|
||||
import os
|
||||
import flask
|
||||
|
||||
from flask import request , jsonify
|
||||
import _thread
|
||||
|
||||
|
||||
|
||||
stats=[{},[],{"cpu":0,"ram":0}]
|
||||
|
||||
class livestats(object):
|
||||
def __init__(self):
|
||||
self.timer=ba.Timer(5,ba.Call(self.getinfo),timetype=ba.TimeType.REAL,repeat=True)
|
||||
|
||||
def getinfo(self):
|
||||
liveplayer={}
|
||||
global stats
|
||||
for i in _ba.get_game_roster():
|
||||
id=json.loads(i['spec_string'])["n"]
|
||||
try:
|
||||
liveplayer[id]={'name': i['players'][0]['name_full'],
|
||||
'clientid':i['client_id']}
|
||||
except:
|
||||
liveplayer[id]-{'name': "<in-lobby>", 'clientid':i['client_id']}
|
||||
stats[0] = liveplayer
|
||||
stats[1] = _ba.get_chat_messages()
|
||||
# stats[2]["cpu"]= p.cpu_percent()
|
||||
# stats[2]["ram"]=p.virtual_memory().percent
|
||||
|
||||
|
||||
livestats()
|
||||
|
||||
#========= flask app ============
|
||||
os.environ['FLASK_APP']='bombsquadflaskapp.py'
|
||||
os.environ['FLASK_ENV']= 'development'
|
||||
|
||||
app = flask.Flask(_name_)
|
||||
app.config["DEBUG"]=False
|
||||
|
||||
@app.route("/",methods=['GET'])
|
||||
def home():
|
||||
return "any message here"
|
||||
|
||||
@app.route('/live',methods=['GET'])
|
||||
def livestat():
|
||||
return jsonify(stats)
|
||||
|
||||
# ba_meta export plugin
|
||||
class HeySmoothy(ba.Plugin):
|
||||
def __init__(self):
|
||||
flask=_thread.start_new_thread(app.run,("0,0,0,0",80,False))
|
||||
|
||||
print("flask service")
|
||||
|
|
@ -1,24 +1,25 @@
|
|||
# ba_meta require api 6
|
||||
"""Module to update `setting.json`."""
|
||||
|
||||
# ba_meta require api 6
|
||||
# (see https://ballistica.net/wiki/meta-tag-system)
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
import os
|
||||
|
||||
import ba,_ba
|
||||
from bastd.actor.playerspaz import PlayerSpaz
|
||||
from bastd.actor.scoreboard import Scoreboard
|
||||
import ba
|
||||
import _ba
|
||||
|
||||
from bastd.actor.spazappearance import Appearance
|
||||
from tools.file_handle import OpenJson
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Any, Type, List, Dict, Tuple, Union, Sequence, Optional
|
||||
|
||||
import os,json
|
||||
from bastd.actor.spazappearance import *
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
def registercharacter(name,char):
|
||||
def register_character(name: str, char: dict) -> None:
|
||||
"""Registers the character in the game."""
|
||||
t = Appearance(name.split(".")[0])
|
||||
t.color_texture = char['color_texture']
|
||||
t.color_mask_texture = char['color_mask']
|
||||
|
|
@ -43,18 +44,16 @@ def registercharacter(name,char):
|
|||
t.fall_sounds = char['fall_sounds']
|
||||
t.style = char['style']
|
||||
|
||||
def enable() -> None:
|
||||
path=os.path.join(_ba.env()["python_directory_user"],"custom_characters" + os.sep)
|
||||
|
||||
# ba_meta export plugin
|
||||
class HeySmoothy(ba.Plugin):
|
||||
|
||||
def __init__(self):
|
||||
|
||||
|
||||
path=os.path.join(_ba.env()["python_directory_user"],"CustomCharacters" + os.sep)
|
||||
if not os.path.isdir(path):
|
||||
os.makedirs(path)
|
||||
|
||||
files=os.listdir(path)
|
||||
|
||||
for file in files:
|
||||
with open(path+file, 'r') as f:
|
||||
character = json.load(f)
|
||||
registercharacter(file,character)
|
||||
if file.endswith(".json"):
|
||||
with OpenJson(path + file) as json_file:
|
||||
character = json_file.load()
|
||||
register_character(file,character)
|
||||
|
|
|
|||
6
dist/ba_root/mods/setting.json
vendored
6
dist/ba_root/mods/setting.json
vendored
|
|
@ -49,6 +49,12 @@
|
|||
"ballistica_web": {
|
||||
"enable":false
|
||||
},
|
||||
"character_chooser":{
|
||||
"enable":true
|
||||
},
|
||||
"custom_characters": {
|
||||
"enable":true
|
||||
},
|
||||
"elPatronPowerups":{
|
||||
"enable":true,
|
||||
"settings":{"Powers Gravity": true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue