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:
pranav-1711 2022-03-20 19:41:59 +05:30
parent 837af6666b
commit 6ad7972a4b
7 changed files with 63 additions and 128 deletions

View file

@ -434,15 +434,6 @@
"Plugins": { "Plugins": {
"plugins.Init": { "plugins.Init": {
"enabled": true "enabled": true
},
"plugins.CharacterChooser.HeySmoothy": {
"enabled": true
},
"plugins.bombsquadhttpapi.HeySmoothy": {
"enabled": false
},
"plugins.importcustomcharacters.HeySmoothy": {
"enabled": false
} }
}, },
"Port": 43210, "Port": 43210,

View file

@ -86,6 +86,12 @@ def bootstraping():
if settings["ballistica_web"]["enable"]: if settings["ballistica_web"]["enable"]:
from plugins import bcs_plugin from plugins import bcs_plugin
bcs_plugin.enable() 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 # import features
if settings["whitelist"]: if settings["whitelist"]:

View file

@ -346,15 +346,9 @@ def _update_text(self) -> None:
self._text_node.text = text self._text_node.text = text
# ba_meta export plugin def enable() -> None:
class HeySmoothy(ba.Plugin):
def __init__(self):
_lobby.Chooser.__init__=__init__ _lobby.Chooser.__init__=__init__
_lobby.Chooser._set_ready=_set_ready _lobby.Chooser._set_ready=_set_ready
_lobby.Chooser._update_text=_update_text _lobby.Chooser._update_text=_update_text
_lobby.Chooser.handlemessage=handlemessage _lobby.Chooser.handlemessage=handlemessage

View file

@ -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")

View file

@ -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 __future__ import annotations
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import os
import ba,_ba import ba
from bastd.actor.playerspaz import PlayerSpaz import _ba
from bastd.actor.scoreboard import Scoreboard
from bastd.actor.spazappearance import Appearance
from tools.file_handle import OpenJson
if TYPE_CHECKING: if TYPE_CHECKING:
from typing import Any, Type, List, Dict, Tuple, Union, Sequence, Optional pass
import os,json
from bastd.actor.spazappearance import *
def register_character(name: str, char: dict) -> None:
"""Registers the character in the game."""
def registercharacter(name,char):
t = Appearance(name.split(".")[0]) t = Appearance(name.split(".")[0])
t.color_texture = char['color_texture'] t.color_texture = char['color_texture']
t.color_mask_texture = char['color_mask'] t.color_mask_texture = char['color_mask']
@ -43,18 +44,16 @@ def registercharacter(name,char):
t.fall_sounds = char['fall_sounds'] t.fall_sounds = char['fall_sounds']
t.style = char['style'] 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): if not os.path.isdir(path):
os.makedirs(path) os.makedirs(path)
files=os.listdir(path) files=os.listdir(path)
for file in files: for file in files:
with open(path+file, 'r') as f: if file.endswith(".json"):
character = json.load(f) with OpenJson(path + file) as json_file:
registercharacter(file,character) character = json_file.load()
register_character(file,character)

View file

@ -49,6 +49,12 @@
"ballistica_web": { "ballistica_web": {
"enable":false "enable":false
}, },
"character_chooser":{
"enable":true
},
"custom_characters": {
"enable":true
},
"elPatronPowerups":{ "elPatronPowerups":{
"enable":true, "enable":true,
"settings":{"Powers Gravity": true, "settings":{"Powers Gravity": true,