mirror of
https://github.com/bombsquad-community/plugin-manager.git
synced 2026-08-15 13:03:08 +00:00
Merge branch 'bombsquad-community:main' into main
This commit is contained in:
commit
bb28e48969
13 changed files with 3662 additions and 127 deletions
105
.github/workflows/ci.yml
vendored
105
.github/workflows/ci.yml
vendored
|
|
@ -1,5 +1,15 @@
|
|||
name: CI
|
||||
|
||||
# WORD OF CAUTION:
|
||||
# TO anyone modifying this
|
||||
# Things will break if you modify this
|
||||
# without understanding how it works
|
||||
|
||||
# A simple flow of this file:
|
||||
# Apply AutoPEP8 → Apply Plugin Metadata → CRITICAL COMMIT (format + plugin meta)
|
||||
# ← ← ← ← ← ↵
|
||||
# ↪ Apply Version Metadata → Commit (version meta) → Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
|
|
@ -9,48 +19,55 @@ on:
|
|||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.12"]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
ref: ${{ github.head_ref }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
python -m pip install -U pip
|
||||
python -m pip install -U pycodestyle==2.12.1 autopep8
|
||||
python -m pip install -U -r test/pip_reqs.txt
|
||||
|
||||
- name: Apply AutoPEP8
|
||||
run: |
|
||||
autopep8 --in-place --recursive --max-line-length=100 .
|
||||
|
||||
- name: Commit AutoPEP8
|
||||
uses: stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
commit_message: "[ci] auto-format"
|
||||
branch: ${{ github.head_ref }}
|
||||
|
||||
- name: Apply Version Metadata
|
||||
run: |
|
||||
python test/auto_apply_version_metadata.py $(git log --pretty=format:'%h' -n 1)
|
||||
|
||||
- name: Commit Version Metadata
|
||||
uses: stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
commit_message: "[ci] apply-version-metadata"
|
||||
branch: ${{ github.head_ref }}
|
||||
|
||||
- name: Execute Tests
|
||||
run: |
|
||||
python -m unittest discover -v
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
ref: ${{ github.head_ref }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.12"
|
||||
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
python -m pip install -U pip
|
||||
python -m pip install -U pycodestyle==2.12.1 autopep8
|
||||
python -m pip install -U -r test/pip_reqs.txt
|
||||
|
||||
- name: Apply AutoPEP8
|
||||
run: |
|
||||
autopep8 --in-place --recursive --max-line-length=100 .
|
||||
|
||||
- name: Apply Plugin Metadata
|
||||
if: github.event_name == 'pull_request_target'
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
CHANGED_FILES=$(gh api "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" --jq '.[].filename')
|
||||
python test/auto_apply_plugin_metadata.py "$CHANGED_FILES"
|
||||
|
||||
# This is a CRITICAL COMMIT for the next step
|
||||
# which bases this as the commit to get the sha to store in index.json or plugin.json
|
||||
- name: Commit Plugin Metadata and AutoPEP8
|
||||
uses: stefanzweifel/git-auto-commit-action@v7
|
||||
with:
|
||||
commit_message: "[ci] apply-plugin-metadata-and-formatting"
|
||||
branch: ${{ github.head_ref }}
|
||||
|
||||
- name: Apply Version Metadata
|
||||
run: |
|
||||
python test/auto_apply_version_metadata.py $(git log --pretty=format:'%h' -n 1)
|
||||
|
||||
- name: Commit Version Metadata
|
||||
uses: stefanzweifel/git-auto-commit-action@v7
|
||||
with:
|
||||
commit_message: "[ci] apply-version-metadata"
|
||||
branch: ${{ github.head_ref }}
|
||||
|
||||
- name: Execute Tests
|
||||
run: |
|
||||
python -m unittest discover -v
|
||||
|
|
|
|||
10
.github/workflows/release.yml
vendored
10
.github/workflows/release.yml
vendored
|
|
@ -12,9 +12,9 @@ jobs:
|
|||
name: Create Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: '3.12'
|
||||
|
||||
|
|
@ -27,14 +27,14 @@ jobs:
|
|||
|
||||
- name: set_variables
|
||||
run: |
|
||||
output1=$(python3 test/get_latest.py get_latest_version)
|
||||
output1=$(python3 test/get_latest.py get_latest_plugman_version)
|
||||
{
|
||||
echo "changelog<<EOF"
|
||||
python3 test/get_changes.py "$(python3 test/get_latest.py get_latest_version)"
|
||||
python3 test/get_changelog.py "$(python3 test/get_latest.py get_latest_version)"
|
||||
echo EOF
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
output2=$(python3 test/get_latest.py get_latest_api)
|
||||
output3=$(python3 test/version_is_lower.py ${{ steps.previoustag.outputs.tag }})
|
||||
output3=$(python3 test/versioning_tools.py ${{ steps.previoustag.outputs.tag }})
|
||||
echo "latestVersion=$output1" >> $GITHUB_OUTPUT
|
||||
echo "latestAPI=$output2" >> $GITHUB_OUTPUT
|
||||
echo "shouldRun=$output3" >> $GITHUB_OUTPUT
|
||||
|
|
|
|||
94
README.md
94
README.md
|
|
@ -84,7 +84,9 @@ There are two different ways the plugin manager can be installed:
|
|||
See [3rd party plugin sources](#3rd-party-plugin-sources) for more information.
|
||||
- New plugins are accepted through a [pull request](../../compare). Add your plugin in the minigames, utilities, or
|
||||
the category directory you feel is the most relevant to the type of plugin you're submitting, [here](plugins).
|
||||
Then add an entry to the category's JSON metadata file.
|
||||
- You also need a `plugman` dict with the plugin metadata in the plugin (see the [example](https://github.com/bombsquad-community/plugin-manager?tab=readme-ov-file#example) below).
|
||||
- The name of the plugin must be in snake_case and matching the file name.
|
||||
- Must have the plugin_name, description, external_url, authors and version keys.
|
||||
- Plugin manager will also show and execute the settings icon if your `ba.Plugin` class has methods `has_settings_ui` and `show_settings_ui`; check out the [colorscheme](https://github.com/bombsquad-community/plugin-manager/blob/eb163cf86014b2a057c4a048dcfa3d5b540b7fe1/plugins/utilities/colorscheme.py#L448-L452) plugin for an example.
|
||||
|
||||
#### Example:
|
||||
|
|
@ -94,6 +96,17 @@ Let's say you wanna submit this new utility-type plugin named as `sample_plugin.
|
|||
# ba_meta require api 9
|
||||
import babase
|
||||
|
||||
plugman = dict(
|
||||
plugin_name="sample_plugin",
|
||||
description="A test plugin for demonstration purposes blah blah.",
|
||||
external_url="https://www.youtube.com/watch?v=dQw4w9WgXcQ",
|
||||
authors=[
|
||||
{"name": "Loup", "email": "loupg450@gmail.com", "discord": "loupgarou_"},
|
||||
{"name": "brostos", "email": "", "discord": "brostos"}
|
||||
],
|
||||
version="1.0.0",
|
||||
)
|
||||
|
||||
# ba_meta export babase.Plugin
|
||||
class Main(babase.Plugin):
|
||||
def on_app_running(self):
|
||||
|
|
@ -107,49 +120,13 @@ class Main(babase.Plugin):
|
|||
```
|
||||
|
||||
You'll have to fork this repository and add your `sample_plugin.py` plugin file into the appropriate directory, which for
|
||||
utility plugin is [plugins/utilities](plugins/utilities). After that, you'll have to add an entry for your plugin
|
||||
in [plugins/utilities.json](plugins/utilities.json) so that it gets picked up by the Plugin Manager in-game.
|
||||
|
||||
To do this, you'll have to edit the file and add something like this:
|
||||
```json
|
||||
{
|
||||
"name": "Utilities",
|
||||
...
|
||||
"plugins": {
|
||||
...
|
||||
"sample_plugin": {
|
||||
"description": "Shows screenmessages!",
|
||||
"external_url": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Alex",
|
||||
"email": "alex@example.com",
|
||||
"discord": null
|
||||
}
|
||||
],
|
||||
"versions": {
|
||||
"1.0.0": null
|
||||
}
|
||||
},
|
||||
...
|
||||
}
|
||||
...
|
||||
}
|
||||
```
|
||||
You can add whatever you wanna add to these fields. However, leave the value for your version key as `null`:
|
||||
```json
|
||||
"1.0.0": null
|
||||
```
|
||||
Version values will automatically be populated through github-actions (along with formatting your code as per PEP8 style
|
||||
utility plugin is [plugins/utilities](plugins/utilities). After that, plugin details and version values will automatically be populated through github-actions in [plugins/utilities.json](plugins/utilities.json)(along with formatting your code as per PEP8 style
|
||||
guide) once you open a pull request.
|
||||
|
||||
Save `utilities.json` with your modified changes and now you can create a [pull request](../../compare) with the
|
||||
plugin you've added and the modified JSON metadata file!
|
||||
|
||||
### Updating a Plugin
|
||||
|
||||
- Make a [pull request](../../compare) with whatever changes you'd like to make to an existing plugin, and add a new
|
||||
version entry in your plugin category's JSON metadata file.
|
||||
version number in your plugin in the plugman dict.
|
||||
|
||||
#### Example
|
||||
|
||||
|
|
@ -160,39 +137,24 @@ diff --git a/plugins/utilities/sample_plugin.py b/plugins/utilities/sample_plugi
|
|||
index ebb7dcc..da2b312 100644
|
||||
--- a/plugins/utilities/sample_plugin.py
|
||||
+++ b/plugins/utilities/sample_plugin.py
|
||||
@@ -5,6 +5,7 @@ import babase
|
||||
class Main(babase.Plugin):
|
||||
def on_app_running(self):
|
||||
babase.screenmessage("Hi! I am a sample plugin!")
|
||||
|
||||
def has_settings_ui(self):
|
||||
@@ -9,7 +9,7 @@
|
||||
{"name": "Loup", "email": "loupg450@gmail.com", "discord": "loupgarou_"},
|
||||
{"name": "brostos", "email": "", "discord": "brostos"}
|
||||
],
|
||||
- version="1.0.0",
|
||||
+ version="1.1.0",
|
||||
)
|
||||
|
||||
# ba_meta export babase.Plugin
|
||||
@@ -21,4 +21,4 @@
|
||||
return True
|
||||
|
||||
|
||||
def show_settings_ui(self, source_widget):
|
||||
- babase.screenmessage("You tapped my settings!")
|
||||
+ babase.screenmessage("Hey! This is my new screenmessage!")
|
||||
```
|
||||
|
||||
To name this new version as `1.1.0`, add `"1.1.0": null,` just above the previous plugin version in `utilities.json`:
|
||||
```diff
|
||||
diff --git a/plugins/utilities.json b/plugins/utilities.json
|
||||
index d3fd5bc..34ce9ad 100644
|
||||
--- a/plugins/utilities.json
|
||||
+++ b/plugins/utilities.json
|
||||
@@ -14,7 +14,10 @@
|
||||
}
|
||||
],
|
||||
"versions": {
|
||||
- "1.0.0": null
|
||||
+ "1.1.0": null,
|
||||
+ "1.0.0": {
|
||||
+ ...
|
||||
+ }
|
||||
}
|
||||
},
|
||||
...
|
||||
```
|
||||
That's it! Now you can make a [pull request](../../compare) with both the updated `sample_plugin.py` and `utilities.json` files.
|
||||
That's it! Now you can make a [pull request](../../compare) with the updated `sample_plugin.py` file.
|
||||
|
||||
## 3rd Party Plugin Sources
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,25 @@
|
|||
"md5sum": "01fb81dc27d63789f31559140ec2bd72"
|
||||
}
|
||||
}
|
||||
},
|
||||
"forest_v2": {
|
||||
"description": "A better looking land with some trees\nNew mini games added so you can play more on this update forest",
|
||||
"external_url": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Startingbat",
|
||||
"email": "",
|
||||
"discord": "startingbat"
|
||||
}
|
||||
],
|
||||
"versions": {
|
||||
"1.0.0": {
|
||||
"api_version": 9,
|
||||
"commit_sha": "4a20493",
|
||||
"released_on": "22-01-2026",
|
||||
"md5sum": "42af7d02a8c0d03ad8aaf6da1cf2bac0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
182
plugins/maps/forest_v2.py
Normal file
182
plugins/maps/forest_v2.py
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
# ba_meta require api 9
|
||||
|
||||
from __future__ import annotations
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import bascenev1 as bs
|
||||
from bascenev1 import _map
|
||||
from bascenev1lib.gameutils import SharedObjects
|
||||
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
|
||||
plugman = dict(
|
||||
plugin_name="forest_v2",
|
||||
description="A better looking land with some trees\nNew mini games added so you can play more on this update forest",
|
||||
external_url="",
|
||||
authors=[
|
||||
{"name": "Startingbat", "email": "", "discord": "startingbat"},
|
||||
],
|
||||
version="1.0.0",
|
||||
)
|
||||
|
||||
|
||||
class ForestMapData:
|
||||
points = {}
|
||||
boxes = {}
|
||||
|
||||
boxes['area_of_interest_bounds'] = (
|
||||
(0.0, 1.185751251, 0.4326226188) + (0.0, 0.0, 0.0) + (29.8180273, 11.57249038, 18.89134176)
|
||||
)
|
||||
boxes['edge_box'] = (
|
||||
(-0.103873591, 0.4133341891, 0.4294651013)
|
||||
+ (0.0, 0.0, 0.0)
|
||||
+ (22.48295719, 1.290242794, 8.990252454)
|
||||
)
|
||||
boxes['map_bounds'] = (
|
||||
(0.0, 1.185751251, 0.4326226188) + (0.0, 0.0, 0.0) + (42.09506485, 22.81173179, 29.76723155)
|
||||
)
|
||||
points['ffa_spawn1'] = (-2.0, -2.0, -4.373674593) + (
|
||||
8.895057015,
|
||||
1.0,
|
||||
0.444350722,
|
||||
)
|
||||
points['ffa_spawn2'] = (-2.0, -2.0, 2.076288941) + (
|
||||
8.895057015,
|
||||
1.0,
|
||||
0.444350722,
|
||||
)
|
||||
|
||||
points['flag_default'] = (-2.5, -3.0, -2.0)
|
||||
points['powerup_spawn1'] = (-6.0, -2.6, -1.25)
|
||||
points['powerup_spawn2'] = (1.0, -2.6, -1.25)
|
||||
points['spawn1'] = (-10.0, -2.0, -2.0) + (0.5, 1.0, 3.2)
|
||||
points['spawn2'] = (5.0, -2.0, -2.0) + (0.5, 1.0, 3.2)
|
||||
points['race_point1'] = (0.5901776337, -2.6, 1.543598704) + (
|
||||
0.2824957007,
|
||||
3.950514538,
|
||||
2.292534365,
|
||||
)
|
||||
points['race_point2'] = (4.7526567, -2.6, 1.09551316) + (
|
||||
0.2824957007,
|
||||
3.950514538,
|
||||
2.392880724,
|
||||
)
|
||||
points['race_point3'] = (7.450800117, -2.6, -2.248040576) + (
|
||||
2.167067932,
|
||||
3.950514538,
|
||||
0.2574992262,
|
||||
)
|
||||
points['race_point4'] = (5.064768438, -2.6, -5.820463576) + (
|
||||
0.2824957007,
|
||||
3.950514538,
|
||||
2.392880724,
|
||||
)
|
||||
points['race_point5'] = (0.5901776337, -2.6, -6.165424036) + (
|
||||
0.2824957007,
|
||||
3.950514538,
|
||||
2.156382533,
|
||||
)
|
||||
points['race_point6'] = (-3.057459058, -2.6, -6.114179652) + (
|
||||
0.2824957007,
|
||||
3.950514538,
|
||||
2.323773344,
|
||||
)
|
||||
points['race_point7'] = (-5.814316926, -2.6, -2.248040576) + (
|
||||
2.0364457,
|
||||
3.950514538,
|
||||
0.2574992262,
|
||||
)
|
||||
points['race_point8'] = (-2.958397223, -2.6, 1.360005754) + (
|
||||
0.2824957007,
|
||||
3.950514538,
|
||||
2.529692681,
|
||||
)
|
||||
points['flag1'] = (-10.25842, -2.6673191, -2.2210996)
|
||||
points['flag2'] = (5.2464933, -3.2587945, -1.6802032)
|
||||
points['tnt1'] = (-0.08421587483, 0.9515026107, -0.7762602271)
|
||||
|
||||
|
||||
class ForestMap(bs.Map):
|
||||
|
||||
defs = ForestMapData()
|
||||
name = 'Forest'
|
||||
|
||||
@classmethod
|
||||
def get_play_types(cls) -> list[str]:
|
||||
return ['melee', 'keep_away', 'team_flag', 'race']
|
||||
|
||||
@classmethod
|
||||
def get_preview_texture_name(cls) -> list[str]:
|
||||
return 'natureBackgroundColor'
|
||||
|
||||
@classmethod
|
||||
def on_preload(cls) -> any:
|
||||
data: dict[str, any] = {
|
||||
'mesh': bs.getmesh('natureBackground'),
|
||||
'tex': bs.gettexture('natureBackgroundColor'),
|
||||
'mesh2': bs.getmesh('trees'),
|
||||
'tex2': bs.gettexture('treesColor'),
|
||||
'collision_mesh': bs.getcollisionmesh('natureBackgroundCollide'),
|
||||
'mesh_bg': bs.getmesh('thePadBG'),
|
||||
'mesh_bg_tex': bs.gettexture('black'),
|
||||
}
|
||||
return data
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
shared = SharedObjects.get()
|
||||
|
||||
self.node = bs.newnode(
|
||||
'terrain',
|
||||
delegate=self,
|
||||
attrs={
|
||||
'mesh': self.preloaddata['mesh'],
|
||||
'color_texture': self.preloaddata['tex'],
|
||||
'collision_mesh': self.preloaddata['collision_mesh'],
|
||||
'materials': [shared.footing_material],
|
||||
},
|
||||
)
|
||||
self.background = bs.newnode(
|
||||
'terrain',
|
||||
attrs={
|
||||
'mesh': self.preloaddata['mesh_bg'],
|
||||
'lighting': False,
|
||||
'color_texture': self.preloaddata['mesh_bg_tex'],
|
||||
},
|
||||
)
|
||||
self.trees = bs.newnode(
|
||||
'prop',
|
||||
attrs={
|
||||
'mesh': self.preloaddata['mesh2'],
|
||||
'body': 'box',
|
||||
'mesh_scale': 0.6,
|
||||
'density': 999999, # Very high density to make it immovable
|
||||
'damping': 999999,
|
||||
'position': (-2, 9, -5),
|
||||
'color_texture': self.preloaddata['tex2'],
|
||||
},
|
||||
)
|
||||
|
||||
gnode = bs.getactivity().globalsnode
|
||||
gnode.tint = (1.0, 1.10, 1.15)
|
||||
gnode.ambient_color = (0.9, 1.3, 1.1)
|
||||
gnode.shadow_ortho = True
|
||||
gnode.shadow_offset = (0, 0, -5.0)
|
||||
gnode.vignette_outer = (0.76, 0.76, 0.76)
|
||||
gnode.vignette_inner = (0.95, 0.95, 0.99)
|
||||
|
||||
def is_point_near_edge(self, point: bs.Vec3, running: bool = False) -> bool:
|
||||
xpos = point.x
|
||||
zpos = point.z
|
||||
x_adj = xpos * 0.125
|
||||
z_adj = (zpos + 3.7) * 0.2
|
||||
if running:
|
||||
x_adj *= 1.4
|
||||
z_adj *= 1.4
|
||||
return x_adj * x_adj + z_adj * z_adj > 1.0
|
||||
|
||||
|
||||
# ba_meta export babase.Plugin
|
||||
class StartingbatYT(bs.Plugin):
|
||||
_map.register_map(ForestMap)
|
||||
|
|
@ -2344,6 +2344,44 @@
|
|||
"md5sum": "01c6cb1a3d3b525c87caed389c8d03ed"
|
||||
}
|
||||
}
|
||||
},
|
||||
"floating_star": {
|
||||
"description": "Get floating stars with colorful text",
|
||||
"external_url": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "BsRush_Mod",
|
||||
"email": "",
|
||||
"discord": ""
|
||||
}
|
||||
],
|
||||
"versions": {
|
||||
"1.0.0": {
|
||||
"api_version": 9,
|
||||
"commit_sha": "be999fc",
|
||||
"released_on": "18-01-2026",
|
||||
"md5sum": "c0fc8f5d36b24977e1c997e4211601a7"
|
||||
}
|
||||
}
|
||||
},
|
||||
"powerup_manager": {
|
||||
"description": "This plugin add new modded powerups and features to manage them",
|
||||
"external_url": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "ATD",
|
||||
"email": "anasdhaoidi001@gmail.com",
|
||||
"discord": ""
|
||||
}
|
||||
],
|
||||
"versions": {
|
||||
"1.0.0": {
|
||||
"api_version": 9,
|
||||
"commit_sha": "f38a7ac",
|
||||
"released_on": "21-01-2026",
|
||||
"md5sum": "120276a8d215248888e56bfc86cc66f5"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
172
plugins/utilities/floating_star.py
Normal file
172
plugins/utilities/floating_star.py
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
# ba_meta require api 9
|
||||
|
||||
# @BsRush_Mod
|
||||
# کپی با ذکر منبع آزاد
|
||||
|
||||
from __future__ import annotations
|
||||
from bascenev1lib.mainmenu import MainMenuSession
|
||||
from bascenev1._map import Map
|
||||
import random
|
||||
import bauiv1 as bui
|
||||
import bascenev1 as bs
|
||||
import babase
|
||||
from typing import TYPE_CHECKING, cast
|
||||
|
||||
plugman = dict(
|
||||
plugin_name="floating_star",
|
||||
description="Get floating stars with colorful text",
|
||||
external_url="",
|
||||
authors=[
|
||||
{"name": "BsRush_Mod", "email": "", "discord": ""},
|
||||
],
|
||||
version="1.0.0",
|
||||
)
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Any, Sequence, Callable, List, Dict, Tuple, Optional, Union
|
||||
|
||||
# ==============================================================================#
|
||||
|
||||
# تنظیمات متن
|
||||
TEXT_CONTENT = "\ue00cBsRush Mod\ue00c"
|
||||
TEXT_SIZE = 0.01
|
||||
TEXT_COLOR = (1, 1, 1)
|
||||
|
||||
# ba_meta export babase.Plugin
|
||||
|
||||
|
||||
class UwUuser(babase.Plugin):
|
||||
Map._old_init = Map.__init__
|
||||
|
||||
def _new_init(self, vr_overlay_offset: Optional[Sequence[float]] = None) -> None:
|
||||
self._old_init(vr_overlay_offset)
|
||||
in_game = not isinstance(bs.get_foreground_host_session(), MainMenuSession)
|
||||
if not in_game:
|
||||
return
|
||||
|
||||
def path():
|
||||
|
||||
shield1 = bs.newnode("shield", attrs={
|
||||
'color': (1, 1, 1),
|
||||
'position': (-5.750, 4.3515026107, 2.0),
|
||||
'radius': 1.4
|
||||
})
|
||||
|
||||
bs.animate_array(shield1, 'color', 3, {
|
||||
0: (random.choice([1, 2, 3, 4, 5, 6, 7, 8, 9]),
|
||||
random.choice([1, 2, 3, 4, 5, 6, 7, 8, 9]),
|
||||
random.choice([1, 2, 3, 4, 5, 6, 7, 8, 9])),
|
||||
0.2: (2, 0, 2),
|
||||
0.4: (2, 2, 0),
|
||||
0.6: (0, 2, 0),
|
||||
0.8: (0, 2, 2)
|
||||
}, loop=True)
|
||||
|
||||
flash1 = bs.newnode("flash", attrs={
|
||||
'position': (0, 0, 0),
|
||||
'size': 0.6,
|
||||
'color': (1, 1, 1)
|
||||
})
|
||||
shield1.connectattr('position', flash1, 'position')
|
||||
|
||||
text_node1 = bs.newnode('text',
|
||||
attrs={
|
||||
'text': TEXT_CONTENT,
|
||||
'in_world': True,
|
||||
'shadow': 1.0,
|
||||
'flatness': 1.0,
|
||||
'color': TEXT_COLOR,
|
||||
'scale': TEXT_SIZE,
|
||||
'h_align': 'center'
|
||||
}
|
||||
)
|
||||
|
||||
text_math1 = bs.newnode('math',
|
||||
attrs={
|
||||
'input1': (0, 1.2, 0),
|
||||
'operation': 'add'
|
||||
}
|
||||
)
|
||||
shield1.connectattr('position', text_math1, 'input2')
|
||||
text_math1.connectattr('output', text_node1, 'position')
|
||||
|
||||
bs.animate_array(text_node1, 'color', 3, {
|
||||
0: (1, 0, 0), # قرمز
|
||||
0.2: (1, 1, 0), # زرد
|
||||
0.4: (0, 1, 0), # سبز
|
||||
0.6: (0, 1, 1), # آبی روشن
|
||||
0.8: (1, 0, 1), # بنفش
|
||||
}, loop=True)
|
||||
|
||||
bs.animate_array(shield1, 'position', 3, {
|
||||
0: (-10, 3, -5),
|
||||
5: (10, 6, -5),
|
||||
10: (-10, 3, 5),
|
||||
15: (10, 6, 5),
|
||||
20: (-10, 3, -5)
|
||||
}, loop=True)
|
||||
|
||||
shield2 = bs.newnode("shield", attrs={
|
||||
'color': (1, 1, 1),
|
||||
'position': (5.750, 4.3515026107, -2.0),
|
||||
'radius': 1.4
|
||||
})
|
||||
|
||||
bs.animate_array(shield2, 'color', 3, {
|
||||
0: (random.choice([1, 2, 3, 4, 5, 6, 7, 8, 9]),
|
||||
random.choice([1, 2, 3, 4, 5, 6, 7, 8, 9]),
|
||||
random.choice([1, 2, 3, 4, 5, 6, 7, 8, 9])),
|
||||
0.2: (0, 2, 2),
|
||||
0.4: (2, 0, 2),
|
||||
0.6: (2, 2, 0),
|
||||
0.8: (0, 2, 0)
|
||||
}, loop=True)
|
||||
|
||||
flash2 = bs.newnode("flash", attrs={
|
||||
'position': (0, 0, 0),
|
||||
'size': 0.6,
|
||||
'color': (1, 1, 1)
|
||||
})
|
||||
shield2.connectattr('position', flash2, 'position')
|
||||
|
||||
text_node2 = bs.newnode('text',
|
||||
attrs={
|
||||
'text': TEXT_CONTENT,
|
||||
'in_world': True,
|
||||
'shadow': 1.0,
|
||||
'flatness': 1.0,
|
||||
'color': TEXT_COLOR,
|
||||
'scale': TEXT_SIZE,
|
||||
'h_align': 'center'
|
||||
}
|
||||
)
|
||||
|
||||
text_math2 = bs.newnode('math',
|
||||
attrs={
|
||||
'input1': (0, 1.2, 0),
|
||||
'operation': 'add'
|
||||
}
|
||||
)
|
||||
shield2.connectattr('position', text_math2, 'input2')
|
||||
text_math2.connectattr('output', text_node2, 'position')
|
||||
|
||||
bs.animate_array(text_node2, 'color', 3, {
|
||||
0: (1, 0, 1), # بنفش
|
||||
0.2: (0, 1, 1), # آبی روشن
|
||||
0.4: (0, 1, 0), # سبز
|
||||
0.6: (1, 1, 0), # زرد
|
||||
0.8: (1, 0, 0), # قرمز
|
||||
}, loop=True)
|
||||
|
||||
bs.animate_array(shield2, 'position', 3, {
|
||||
0: (10, 6, 5),
|
||||
5: (-10, 3, 5),
|
||||
10: (10, 6, -5),
|
||||
15: (-10, 3, -5),
|
||||
20: (10, 6, 5)
|
||||
}, loop=True)
|
||||
|
||||
bs.timer(0.1, path)
|
||||
|
||||
Map.__init__ = _new_init
|
||||
2985
plugins/utilities/powerup_manager.py
Normal file
2985
plugins/utilities/powerup_manager.py
Normal file
File diff suppressed because it is too large
Load diff
144
test/auto_apply_plugin_metadata.py
Normal file
144
test/auto_apply_plugin_metadata.py
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
import sys
|
||||
import json
|
||||
import ast
|
||||
import os
|
||||
import get_latest
|
||||
import versioning_tools
|
||||
|
||||
DEBUG = True
|
||||
|
||||
print("DOES THIS RUN AUTO APPLY PLUGIN METADATA?")
|
||||
|
||||
|
||||
def debug_print(*args, **kwargs):
|
||||
if DEBUG:
|
||||
print(*args, **kwargs)
|
||||
|
||||
|
||||
def get_latest_version(plugin_name, category) -> str:
|
||||
filepaths = {
|
||||
"minigames": "plugins/minigames.json",
|
||||
"utilities": "plugins/utilities.json",
|
||||
"maps": "plugins/maps.json",
|
||||
"plugman": "index.json",
|
||||
}
|
||||
|
||||
try:
|
||||
if category != "plugman":
|
||||
return get_latest.get_latest_plugin_version(plugin_name, filepaths[category])
|
||||
return get_latest.get_latest_plugman_version()
|
||||
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
|
||||
def update_plugman_json(version):
|
||||
with open("index.json", "r+") as file:
|
||||
data = json.load(file)
|
||||
plugman_version = int(get_latest_version("plugin_manager", "plugman").replace(".", ""))
|
||||
current_version = int(version["version"].replace(".", ""))
|
||||
|
||||
if current_version > plugman_version:
|
||||
with open("index.json", "r+") as file:
|
||||
data = json.load(file)
|
||||
data[current_version] = None
|
||||
data["versions"] = dict(sorted(data["versions"].items(), reverse=True))
|
||||
|
||||
|
||||
def update_plugin_json(plugin_info, category):
|
||||
name = plugin_info["plugin_name"]
|
||||
|
||||
with open(f"plugins/{category}.json", "r+") as file:
|
||||
data = json.load(file)
|
||||
try:
|
||||
# Check if plugin is already in the json
|
||||
plugin = data["plugins"][name]
|
||||
plugman_version = int(
|
||||
versioning_tools.semantic_to_str(get_latest_version(name, category))
|
||||
)
|
||||
current_version = int(versioning_tools.semantic_to_str(plugin_info["version"]))
|
||||
# Ensure the version is always greater from the already released version
|
||||
if current_version > plugman_version:
|
||||
plugin["versions"][plugin_info["version"]] = None
|
||||
# Ensure latest version appears first
|
||||
plugin["versions"] = dict(sorted(plugin["versions"].items(), reverse=True))
|
||||
plugin["description"] = plugin_info["description"]
|
||||
plugin["external_url"] = plugin_info["external_url"]
|
||||
plugin["authors"] = plugin_info["authors"]
|
||||
# In future
|
||||
# We can clear the version metadata for if current_version = plugman_version for PRs
|
||||
# So that its easier to update the plugin after review without changing version
|
||||
elif current_version <= plugman_version:
|
||||
raise Exception("Version cant be lower or equal than the previous version.")
|
||||
except KeyError:
|
||||
data["plugins"][name] = {
|
||||
"description": plugin_info["description"],
|
||||
"external_url": plugin_info["external_url"],
|
||||
"authors": plugin_info["authors"],
|
||||
"versions": {plugin_info["version"]: None},
|
||||
}
|
||||
|
||||
file.seek(0)
|
||||
json.dump(data, file, indent=2, ensure_ascii=False)
|
||||
# Ensure old content is removed
|
||||
file.truncate()
|
||||
|
||||
|
||||
def extract_plugman(plugins):
|
||||
for plugin in plugins:
|
||||
if "plugins" + os.sep in plugin and plugin.endswith(".py"):
|
||||
|
||||
print(f"Processing plugin file: {plugin}")
|
||||
try:
|
||||
# Split the path and get the part after 'plugins/'
|
||||
parts = plugin.split("plugins" + os.sep)[1].split(os.sep)
|
||||
file_name_no_extension = plugin.split(os.sep)[-1].replace(".py", "")
|
||||
category = parts[0] # First part after plugins/
|
||||
debug_print(f"Determined category: {category}")
|
||||
except ValueError:
|
||||
if "plugin_manager" in plugin:
|
||||
continue
|
||||
with open(plugin, "r") as f:
|
||||
tree = ast.parse(f.read())
|
||||
|
||||
for node in ast.walk(tree):
|
||||
if isinstance(node, ast.Assign) and len(node.targets) == 1:
|
||||
target = node.targets[0]
|
||||
if isinstance(target, ast.Name) and target.id == "plugman":
|
||||
if isinstance(node.value, ast.Dict):
|
||||
# i dont want to support multiple formats for now
|
||||
# because its harder to parse and maintain
|
||||
# ill leave this here for now, though not supported
|
||||
# Standard dictionary format {key: value}
|
||||
return ast.literal_eval(node.value)
|
||||
elif (
|
||||
isinstance(node.value, ast.Call)
|
||||
and isinstance(node.value.func, ast.Name)
|
||||
and node.value.func.id == "dict"
|
||||
):
|
||||
# dict() constructor format
|
||||
result = {}
|
||||
for kw in node.value.keywords:
|
||||
if kw.arg == "plugin_name":
|
||||
plugin_name = ast.literal_eval(kw.value)
|
||||
# some basic validation specific to plugin manager
|
||||
if plugin_name != plugin_name.lower():
|
||||
raise ValueError(
|
||||
"Plugin name in plugman must be in snakecase."
|
||||
)
|
||||
if plugin_name != file_name_no_extension:
|
||||
raise ValueError(
|
||||
"Plugin name in plugman does not match the file name."
|
||||
)
|
||||
result[kw.arg] = ast.literal_eval(kw.value)
|
||||
if category:
|
||||
update_plugin_json(result, category=category)
|
||||
else:
|
||||
update_plugman_json(result)
|
||||
# raise ValueError("Variable plugman not found in the file or has unsupported format.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
plugins = sys.argv[1].split('\n')
|
||||
debug_print(plugins)
|
||||
extract_plugman(plugins)
|
||||
|
|
@ -2,7 +2,7 @@ import json
|
|||
import sys
|
||||
|
||||
|
||||
def get_latest_version():
|
||||
def get_latest_plugman_version() -> str:
|
||||
"""Get latest version entry from index.json"""
|
||||
with open('index.json', 'r') as file:
|
||||
content = json.loads(file.read())
|
||||
|
|
@ -10,16 +10,28 @@ def get_latest_version():
|
|||
return latest_version
|
||||
|
||||
|
||||
def get_latest_plugin_version(plugin_name, json_path) -> str:
|
||||
"""Get latest version entry from json file for a specific plugin"""
|
||||
with open(json_path, 'r') as file:
|
||||
content = json.loads(file.read())
|
||||
latest_version = list(content["plugins"][plugin_name]["versions"].keys())[0]
|
||||
return latest_version
|
||||
|
||||
|
||||
def get_latest_api():
|
||||
"""Get latest api entry from index.json"""
|
||||
with open('index.json', 'r') as file:
|
||||
content = json.loads(file.read())
|
||||
latest_api = content["versions"][get_latest_version()]["api_version"]
|
||||
latest_api = content["versions"][get_latest_plugman_version()]["api_version"]
|
||||
return latest_api
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print(f"Usage: python3 {__file__.split('/')[-1]} function")
|
||||
print(f"Usage: python3 {__file__.split('/')[-1]} function [args...]")
|
||||
sys.exit(1)
|
||||
print(globals()[sys.argv[1]]()) # used to call the fucntion passed as cli parameter
|
||||
function_name = sys.argv[1]
|
||||
function_args = sys.argv[2:]
|
||||
print(
|
||||
globals()[function_name](*function_args)
|
||||
) # used to call the function passed as cli parameter with additional arguments
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ class BaseCategoryMetadataTestCases:
|
|||
|
||||
if md5sum != version_metadata["md5sum"]:
|
||||
self.fail(
|
||||
f"{plugin} checksum changed;\n"
|
||||
f"{plugin} checksum changed for version {version_name};\n"
|
||||
f"{version_metadata['md5sum']} (mentioned in {self.category_metadata_file}) ->\n"
|
||||
f"{md5sum} (actual)"
|
||||
)
|
||||
|
|
@ -177,6 +177,7 @@ class BaseCategoryMetadataTestCases:
|
|||
|
||||
if md5sum != latest_version_metadata["md5sum"]:
|
||||
self.fail(
|
||||
f"Latest version {latest_version_name} of "
|
||||
f"{plugin} checksum changed;\n"
|
||||
f"{latest_version_metadata['md5sum']} (mentioned in {self.category_metadata_file}) ->\n"
|
||||
f"{md5sum} (actual)"
|
||||
|
|
|
|||
|
|
@ -1,22 +1,25 @@
|
|||
import sys
|
||||
from get_latest import get_latest_version
|
||||
from get_latest import get_latest_plugman_version
|
||||
|
||||
"""if called directly from command line, it will check if given version is lower
|
||||
than latest version in index.json"""
|
||||
|
||||
|
||||
def semantic_to_str(semantic_version: str):
|
||||
"""Convert version in the form of v1.2.3 to 001002003
|
||||
for comparing 2 version in semantic versioning format"""
|
||||
out = ""
|
||||
for i in (semantic_version.split(".")):
|
||||
for i in semantic_version.split("."):
|
||||
if len(i) == 1:
|
||||
out += "00"+i
|
||||
out += "00" + i
|
||||
if len(i) == 2:
|
||||
out += "0"+i
|
||||
out += "0" + i
|
||||
return out
|
||||
|
||||
|
||||
def version_is_lower(version: str):
|
||||
def plugman_version_is_lower_than(version: str):
|
||||
"""Check if given version is lower than the latest entry in index.json"""
|
||||
latest = semantic_to_str(get_latest_version())
|
||||
latest = semantic_to_str(get_latest_plugman_version())
|
||||
version = semantic_to_str(version)
|
||||
if latest > version:
|
||||
return True
|
||||
|
|
@ -30,5 +33,5 @@ if __name__ == "__main__":
|
|||
sys.exit(1)
|
||||
|
||||
version = sys.argv[1].replace("v", "", 1)
|
||||
out = version_is_lower(version)
|
||||
out = plugman_version_is_lower_than(version)
|
||||
print(int(out))
|
||||
Loading…
Add table
Add a link
Reference in a new issue