From 5a014d02b825fd13f6a34d23c852bd8f741a2ecf Mon Sep 17 00:00:00 2001 From: uprightbass360 Date: Sun, 2 Nov 2025 21:03:05 -0500 Subject: [PATCH] fix(module): statbooster --- config/modules.json | 2 +- scripts/hooks/fix-statbooster-api | 45 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100755 scripts/hooks/fix-statbooster-api diff --git a/config/modules.json b/config/modules.json index 336fff3..327fc4d 100644 --- a/config/modules.json +++ b/config/modules.json @@ -425,7 +425,7 @@ "repo": "https://github.com/AnchyDev/StatBooster.git", "needs_build": true, "type": "cpp", - "post_install_hooks": [], + "post_install_hooks": ["fix-statbooster-api"], "depends_on": [] }, { diff --git a/scripts/hooks/fix-statbooster-api b/scripts/hooks/fix-statbooster-api new file mode 100755 index 0000000..fd40578 --- /dev/null +++ b/scripts/hooks/fix-statbooster-api @@ -0,0 +1,45 @@ +#!/bin/bash +# Post-install hook to fix StatBooster API compatibility +set -e + +MODULE_DIR="${MODULE_DIR:-}" +MODULE_NAME="${MODULE_NAME:-}" + +if [ -z "$MODULE_DIR" ] || [ ! -d "$MODULE_DIR" ]; then + echo "❌ fix-statbooster-api: Invalid module directory: $MODULE_DIR" + exit 2 +fi + +echo "🔧 fix-statbooster-api: Patching API compatibility for $MODULE_NAME" + +HEADER_FILE="$MODULE_DIR/src/StatBoost.h" +CPP_FILE="$MODULE_DIR/src/StatBoost.cpp" + +if [ ! -f "$HEADER_FILE" ]; then + echo " â„šī¸ Header file not found, skipping: $HEADER_FILE" + exit 0 +fi + +# Check if already patched +if grep -q "OnPlayerLogin" "$HEADER_FILE" 2>/dev/null; then + echo " ✅ Module already patched" + exit 0 +fi + +# Apply API compatibility patches +echo " 📝 Patching OnLogin -> OnPlayerLogin" + +# Patch header file +if [ -f "$HEADER_FILE" ]; then + sed -i 's/void OnLogin(Player\* player) override;/void OnPlayerLogin(Player* player) override;/g' "$HEADER_FILE" && \ + echo " ✅ Patched $HEADER_FILE" +fi + +# Patch cpp file +if [ -f "$CPP_FILE" ]; then + sed -i 's/void StatBoosterPlayer::OnLogin(Player\* player)/void StatBoosterPlayer::OnPlayerLogin(Player* player)/g' "$CPP_FILE" && \ + echo " ✅ Patched $CPP_FILE" +fi + +echo " ✅ API compatibility patches applied" +exit 0