mirror of
https://github.com/imayushsaini/Bombsquad-Ballistica-Modded-Server.git
synced 2026-08-15 13:04:30 +00:00
final whitelist
This commit is contained in:
parent
755f481421
commit
ed973afd38
15 changed files with 271 additions and 79 deletions
26
dist/ba_root/mods/setting.json
vendored
26
dist/ba_root/mods/setting.json
vendored
|
|
@ -1,11 +1,19 @@
|
|||
{
|
||||
"textonmap":
|
||||
{
|
||||
"top watermark":"Welcome to server \n ip 192.168.0.1",
|
||||
"bottom left watermark":"join discord for fun",
|
||||
"center highlights":["message 1","message 2","message 3"]
|
||||
},
|
||||
"enabletags":true,
|
||||
"enablerank":true,
|
||||
"enableeffects":false
|
||||
"white_list": {
|
||||
"whitelist_on": true,
|
||||
"spectators": false,
|
||||
"lobbychecktime": 3
|
||||
},
|
||||
"textonmap": {
|
||||
"top watermark": "Welcome to server \n ip 192.168.0.1",
|
||||
"bottom left watermark": "join discord for fun",
|
||||
"center highlights": [
|
||||
"message 1",
|
||||
"message 2",
|
||||
"message 3"
|
||||
]
|
||||
},
|
||||
"enabletags": true,
|
||||
"enablerank": true,
|
||||
"enableeffects": false
|
||||
}
|
||||
40
dist/ba_root/mods/setting.py
vendored
40
dist/ba_root/mods/setting.py
vendored
|
|
@ -1,23 +1,27 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
import ba,_ba,json,os
|
||||
settingjson = os.path.join(_ba.env()['python_directory_user'],"setting.json")
|
||||
import _ba, json
|
||||
|
||||
def get_setting():
|
||||
s = {}
|
||||
f=open(settingjson,"r")
|
||||
d = json.loads(f.read())
|
||||
f.close()
|
||||
return d
|
||||
settings_path = _ba.env()["python_directory_user"]+"/setting.json"
|
||||
|
||||
def commit(updated_settings: dict):
|
||||
if updated_settings == {}: return
|
||||
f=open(settingjson,'w')
|
||||
json.dump(updated_settings,f,indent=4)
|
||||
f.close()
|
||||
|
||||
def sendError(msg: str, ID: int = None):
|
||||
if ID is not None:
|
||||
ba.screenmessage(msg, color=(1,0,0), clients=[ID], transient=True)
|
||||
else:
|
||||
ba.screenmessage(msg, color=(1,0,0), transient=True)
|
||||
|
||||
|
||||
def get_settings_data():
|
||||
with open(settings_path, "r") as f:
|
||||
data = json.load(f)
|
||||
return data
|
||||
|
||||
|
||||
|
||||
def commit(data):
|
||||
with open(settings_path, "w") as f:
|
||||
json.dump(data, f, indent=4)
|
||||
|
||||
|
||||
|
||||
def sendError(msg : str, client_id : int = None):
|
||||
if client_id == None:
|
||||
_ba.screenmessage(msg, color=(1,0,0))
|
||||
else:
|
||||
_ba.screenmessage(msg, color=(1,0,0), transient=True, clients=[client_id])
|
||||
|
||||
|
|
|
|||
2
dist/ba_root/mods/spazmod/modifyspaz.py
vendored
2
dist/ba_root/mods/spazmod/modifyspaz.py
vendored
|
|
@ -4,7 +4,7 @@ import setting
|
|||
|
||||
# all activites related to modify spaz by any how will be here
|
||||
def main(node,player):
|
||||
_setting=setting.get_setting()
|
||||
_setting=setting.get_settings_data()
|
||||
|
||||
if _setting['enabletags']:
|
||||
tag.addtag(node,player)
|
||||
|
|
|
|||
BIN
dist/ba_root/mods/stats/__pycache__/__init__.cpython-38.opt-1.pyc
vendored
Normal file
BIN
dist/ba_root/mods/stats/__pycache__/__init__.cpython-38.opt-1.pyc
vendored
Normal file
Binary file not shown.
BIN
dist/ba_root/mods/stats/__pycache__/mystats.cpython-38.opt-1.pyc
vendored
Normal file
BIN
dist/ba_root/mods/stats/__pycache__/mystats.cpython-38.opt-1.pyc
vendored
Normal file
Binary file not shown.
2
dist/ba_root/mods/stats/mystats.py
vendored
2
dist/ba_root/mods/stats/mystats.py
vendored
|
|
@ -16,7 +16,7 @@ from typing import Any, Dict, Optional
|
|||
from ba._lobby import JoinInfo
|
||||
from ba import _activitytypes as ba_actypes
|
||||
from ba._activitytypes import *
|
||||
our_settings = setting.get_setting()
|
||||
our_settings = setting.get_settings_data()
|
||||
# where our stats file and pretty html output will go
|
||||
base_path = os.path.join(_ba.env()['python_directory_user'],"stats" + os.sep)
|
||||
statsfile = base_path + 'stats.json'
|
||||
|
|
|
|||
14
dist/ba_root/mods/stats/stats.json
vendored
14
dist/ba_root/mods/stats/stats.json
vendored
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"pb-IF4VAk4a": {
|
||||
"rank": 1,
|
||||
"name_html": "pb-IF4VAk4a",
|
||||
"scores": 0,
|
||||
"total_damage": 0.0,
|
||||
"kills": 0,
|
||||
"deaths": 0,
|
||||
"games": 18,
|
||||
"kd": 0.0,
|
||||
"avg_score": 0.0,
|
||||
"aid": "pb-IF4VAk4a"
|
||||
}
|
||||
}
|
||||
30
dist/ba_root/mods/stats/stats_page.html
vendored
Normal file
30
dist/ba_root/mods/stats/stats_page.html
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Test Server</title>
|
||||
<style>table{width:100%;border: 3px solid black;border-spacing: 5px;border-collapse:collapse;text-align:center;background-color:#fff} th{border: 3px solid black;text-align:center;}</style>
|
||||
</head>
|
||||
<body>
|
||||
<h3 style="text-align:center">Top 200 Players </h3>
|
||||
<table border=1>
|
||||
<tr>
|
||||
<th><b>Rank</b></th>
|
||||
<th style="text-align:center"><b>Name</b></th>
|
||||
<th><b>Score</b></th>
|
||||
<th><b>Kills</b></th>
|
||||
<th><b>Deaths</b></th>
|
||||
<th><b>Games Played</b></th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td style="text-align:center">pb-IF4VAk4a</td>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
<td>18</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
BIN
dist/ba_root/mods/tools/__pycache__/__init__.cpython-38.opt-1.pyc
vendored
Normal file
BIN
dist/ba_root/mods/tools/__pycache__/__init__.cpython-38.opt-1.pyc
vendored
Normal file
Binary file not shown.
BIN
dist/ba_root/mods/tools/__pycache__/textonmap.cpython-38.opt-1.pyc
vendored
Normal file
BIN
dist/ba_root/mods/tools/__pycache__/textonmap.cpython-38.opt-1.pyc
vendored
Normal file
Binary file not shown.
BIN
dist/ba_root/mods/tools/__pycache__/whitelist.cpython-38.opt-1.pyc
vendored
Normal file
BIN
dist/ba_root/mods/tools/__pycache__/whitelist.cpython-38.opt-1.pyc
vendored
Normal file
Binary file not shown.
0
dist/ba_root/mods/tools/logs.txt
vendored
Normal file
0
dist/ba_root/mods/tools/logs.txt
vendored
Normal file
102
dist/ba_root/mods/tools/textonmap.py
vendored
102
dist/ba_root/mods/tools/textonmap.py
vendored
|
|
@ -1,59 +1,61 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
|
||||
#TODO need to set coordinates of text node , move timer values to settings.json
|
||||
""" TODO need to set coordinates of text node , move timer values to settings.json """
|
||||
|
||||
from ba._enums import TimeType
|
||||
import ba,_ba
|
||||
import ba, _ba
|
||||
import setting
|
||||
|
||||
class textonmap:
|
||||
|
||||
def __init__(self):
|
||||
self.index=0;
|
||||
_textonmap=setting.get_setting()['textonmap']
|
||||
self.highlights=_textonmap['center highlights']
|
||||
left=_textonmap['bottom left watermark']
|
||||
top=_textonmap['top watermark']
|
||||
|
||||
self.timerr=ba.Timer(8,ba.Call(self.highlights),repeat=True)
|
||||
|
||||
|
||||
data = setting.get_settings_data()['textonmap']
|
||||
left = data['bottom left watermark']
|
||||
top = data['top watermark']
|
||||
|
||||
self.index = 0
|
||||
self.highlights = data['center highlights']
|
||||
self.left_watermark(left)
|
||||
self.top_message(top)
|
||||
self.timer = ba.timer(8, ba.Call(self.highlights), repeat=True)
|
||||
|
||||
|
||||
def highlights(self):
|
||||
hg=_ba.newnode('text',
|
||||
attrs={
|
||||
'text': self.highlights[self.index],
|
||||
|
||||
'flatness': 1.0,
|
||||
'h_align': 'center',
|
||||
'v_attach':'bottom',
|
||||
'scale':1,
|
||||
'position':(0,138),
|
||||
'color':(1,1,1)
|
||||
})
|
||||
self.delt=ba.Timer(7,hg.delete)
|
||||
self.index=int((self.index+1)%len(self.highlights))
|
||||
|
||||
def left_watermark(self,text):
|
||||
hg=_ba.newnode('text',
|
||||
attrs={
|
||||
'text': text,
|
||||
|
||||
'flatness': 1.0,
|
||||
'h_align': 'left',
|
||||
'v_attach':'bottom',
|
||||
'scale':1,
|
||||
'position':(0,138),
|
||||
'color':(1,1,1)
|
||||
})
|
||||
def top_message(self,text):
|
||||
txt=_ba.newnode('text',
|
||||
attrs={
|
||||
'text': text,
|
||||
|
||||
'flatness': 1.0,
|
||||
'h_align': 'center',
|
||||
'v_attach':'top',
|
||||
'scale':1,
|
||||
'position':(0,138),
|
||||
'color':(1,1,1)
|
||||
})
|
||||
def highlights_(self):
|
||||
node = _ba.newnode('text',
|
||||
attrs={
|
||||
'text': self.highlights[self.index],
|
||||
'flatness': 1.0,
|
||||
'h_align': 'center',
|
||||
'v_attach':'bottom',
|
||||
'scale':1,
|
||||
'position':(0,138),
|
||||
'color':(1,1,1)
|
||||
})
|
||||
|
||||
self.delt = ba.timer(7,node.delete)
|
||||
self.index = int((self.index+1)%len(self.highlights))
|
||||
|
||||
def left_watermark(self, text):
|
||||
node = _ba.newnode('text',
|
||||
attrs={
|
||||
'text': text,
|
||||
'flatness': 1.0,
|
||||
'h_align': 'left',
|
||||
'v_attach':'bottom',
|
||||
'scale':1,
|
||||
'position':(0,138),
|
||||
'color':(1,1,1)
|
||||
})
|
||||
|
||||
def top_message(self, text):
|
||||
node = _ba.newnode('text',
|
||||
attrs={
|
||||
'text': text,
|
||||
'flatness': 1.0,
|
||||
'h_align': 'center',
|
||||
'v_attach':'top',
|
||||
'scale':1,
|
||||
'position':(0,138),
|
||||
'color':(1,1,1)
|
||||
})
|
||||
|
||||
5
dist/ba_root/mods/tools/whitelist.json
vendored
Normal file
5
dist/ba_root/mods/tools/whitelist.json
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"pb-IF4VAk4a": [
|
||||
"\ue030Server127089"
|
||||
]
|
||||
}
|
||||
129
dist/ba_root/mods/tools/whitelist.py
vendored
129
dist/ba_root/mods/tools/whitelist.py
vendored
|
|
@ -0,0 +1,129 @@
|
|||
"""
|
||||
Private Server whitelist by Mr.Smoothy
|
||||
|
||||
* don't dare to remove credits or I will bite you
|
||||
|
||||
GitHub : https://github.com/imayushsaini/Bombsquad-Ballistica-Modded-Server
|
||||
"""
|
||||
# Released under the MIT License. See LICENSE for details.
|
||||
|
||||
|
||||
# ba_meta require api 6
|
||||
from __future__ import annotations
|
||||
from typing import TYPE_CHECKING
|
||||
from ba._enums import TimeType
|
||||
|
||||
import ba, _ba, time, json, datetime, setting
|
||||
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
white_logs_path = _ba.env()["python_directory_user"]+"/tools/whitelist.json"
|
||||
logs_paths = _ba.env()["python_directory_user"]+"/tools/logs.txt"
|
||||
|
||||
|
||||
def commit(data):
|
||||
with open(white_logs_path, "w") as f:
|
||||
json.dump(data, f, indent=4)
|
||||
|
||||
|
||||
def add_commit_to_logs(commit : str):
|
||||
with open(logs_path, "a") as f:
|
||||
f.write(commit+"\n")
|
||||
|
||||
|
||||
def get_whitelist_data():
|
||||
with open(white_logs_path, "r") as f:
|
||||
data = json.load(f)
|
||||
return data
|
||||
|
||||
|
||||
def in_white_list(accountid : str):
|
||||
data = get_whitelist_data()
|
||||
|
||||
if str(accountid) in data:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def add_to_white_list(accountid : str, display_string : str):
|
||||
data = get_whitelist_data()
|
||||
|
||||
if accountid not in data:
|
||||
data[str(accountid)] = [str(display_string)]
|
||||
|
||||
else:
|
||||
data[str(accountid)].append(str(display_string))
|
||||
|
||||
commit(data)
|
||||
|
||||
|
||||
def handle_player_request(player):
|
||||
data = get_whitelist_data()
|
||||
settings = setting.get_settings_data()["white_list"]
|
||||
accountid = player.get_account_id()
|
||||
|
||||
if settings["whitelist_on"]:
|
||||
if in_white_list(accountid):
|
||||
return
|
||||
else:
|
||||
rost = _ba.get_game_roster()
|
||||
|
||||
for i in rost:
|
||||
if i["account_id"] == accountid:
|
||||
_ba.disconnect_client(int(i['client_id']))
|
||||
|
||||
|
||||
def display_string_in_white_list(display_string : str):
|
||||
return any(display_string in i for i in data.values())
|
||||
|
||||
|
||||
class _whitelist_:
|
||||
def __init__(self):
|
||||
|
||||
settings = setting.get_settings_data()["white_list"]
|
||||
whitelist_on = settings["whitelist_on"]
|
||||
spectators = settings["spectators"]
|
||||
lobbychecktime = settings["lobbychecktime"]
|
||||
_ba.chatmessage(f"{settings} {whitelist_on} {spectators} {lobbychecktime}")
|
||||
|
||||
try:
|
||||
data = get_whitelist_data()
|
||||
|
||||
except:
|
||||
print("No Whitelist Detected , Creating One")
|
||||
self.whitelst = {}
|
||||
self.whitelst['pb-JiNJARBaXEFBVF9HFkNXXF1EF0ZaRlZE']=['smoothyki-id','mr.smoothy']
|
||||
commit(whitelst)
|
||||
|
||||
if whitelist_on and not spectators:
|
||||
self.timer = ba.timer(lobbychecktime, self.checklobby, repeat=True, timetype=TimeType.REAL)
|
||||
|
||||
def checklobby(self):
|
||||
|
||||
settings = setting.get_settings_data()["white_list"]
|
||||
whitelist_on = settings["whitelist_on"]
|
||||
spectators = settings["spectators"]
|
||||
lobbychecktime = settings["lobbychecktime"]
|
||||
|
||||
if whitelist_on and not spectators:
|
||||
try:
|
||||
|
||||
rost = _ba.get_game_roster()
|
||||
for i in rost:
|
||||
if i['account_id'] in whitelist and i['account_id'] != '' or i['client_id'] == -1:
|
||||
return
|
||||
|
||||
else:
|
||||
add_commit_to_logs("Kicked from lobby "+i['account_id']+" "+i['spec_string'])
|
||||
_ba.disconnect_client(i['client_id'])
|
||||
|
||||
except:
|
||||
return
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue