#!/bin/bash
set -e

cd $HOME/hlserver/tf2/tf

# SteamWorks
wget -nv "https://github.com/KyleSanderson/SteamWorks/releases/download/1.2.3c/package-lin.tgz" -O "steamworks.tar.gz"
tar -xf steamworks.tar.gz --strip-components 1
rm steamworks.tar.gz

# SOAP-DM
wget -nv "https://github.com/sapphonie/SOAP-TF2DM/releases/download/v4.4.8/soap.zip" -O "soap-dm.zip"
unzip -o soap-dm.zip
rm soap-dm.zip

# Improved-Match-Timer
wget -nv "https://github.com/b4nnyBot/Progressive-Ruleset-Timer-Plugins/archive/master.zip" -O "improved-match-timer.zip"
unzip -o improved-match-timer.zip
cp -r Progressive-Ruleset-Timer-Plugins-main/* ./
rm -r Progressive-Ruleset-Timer-Plugins-main
rm improved-match-timer.zip

# Socket

cp /socket_3.0.1.zip socket.zip
unzip -o socket.zip
rm socket.zip

# tf2-comp-fixes

wget -nv https://github.com/ldesgoui/tf2-comp-fixes/releases/download/v1.18.0/tf2-comp-fixes.zip
unzip -o tf2-comp-fixes.zip
rm tf2-comp-fixes.zip

# srctvplus
cd $HOME/hlserver/tf2/tf/addons

wget -nv https://github.com/dalegaard/srctvplus/releases/download/v3.0/srctvplus.vdf
wget -nv https://github.com/dalegaard/srctvplus/releases/download/v3.0/srctvplus.so

# Curl
cd $HOME/hlserver/tf2/tf/addons/sourcemod

wget -nv "https://github.com/sapphonie/SM-neocurl-ext/releases/download/v2.0.1-beta1/sm-neocurl-repack.zip" -O "sm-neocurl.zip"
unzip -o sm-neocurl.zip
rm sm-neocurl.zip

# Websockets

wget -nv "https://github.com/peace-maker/sm-websocket/archive/master.zip" -O "sm-websocket.zip"
unzip -o sm-websocket.zip
cp -r sm-websocket-master/* ./
rm -r sm-websocket-master
rm sm-websocket.zip

# Medic stats, SupStats, LogsTF, RecordSTV, WaitForStv, AFK, RestoreScore, FixStvSlot and Updater
cd $HOME/hlserver/tf2/tf/addons/sourcemod/plugins

wget -nv "https://github.com/F2/F2s-sourcemod-plugins/releases/download/20250908-1757334414124/f2-sourcemod-plugins.zip" -O "f2-sourcemod-plugins.zip"
unzip -o f2-sourcemod-plugins.zip
rm f2-sourcemod-plugins.zip

# WebRCON
wget -nv https://codeberg.org/spire/webrcon/raw/master/plugin/webrcon.smx

# whitelist.tf downloader
wget -nv https://codeberg.org/spire/sm_whitelist/raw/branch/master/plugin/whitelisttf.smx

# map downloader
wget -nv https://codeberg.org/spire/mapdownloader/raw/master/plugin/mapdownloader.smx

# demos.tf uploader
wget -nv https://codeberg.org/demostf/plugin/raw/ba1b642b92585af142a885af7159fa652916c6e7/demostf.smx

# autoexec
wget -nv https://codeberg.org/spire/autoexec/raw/master/plugin/autoexec.smx

## Pause
wget -nv https://codeberg.org/spire/docker-comp-server/raw/master/pause.smx

## NoCheats
wget -nv https://codeberg.org/spire/nocheats/raw/master/plugin/nocheats.smx

## NoChat
wget -nv https://codeberg.org/spire/nochat/raw/main/plugin/nochat.smx

## SdrConnect
wget -nv https://codeberg.org/spire/sdrconnect/raw/main/plugin/sdrconnect.smx

## SetTeam
wget -nv https://codeberg.org/spire/setteam/raw/master/plugin/setteam.smx

## Who
wget -nv https://codeberg.org/spire/who/raw/main/plugin/who.smx

## Banned
wget -nv https://codeberg.org/spire/banned/raw/branch/main/plugin/banned.smx

# proper-pregame
wget -nv https://github.com/AJagger/ProperPregame/raw/master/addons/sourcemod/plugins/properpregame.smx

# ExtendHumiliation

cp /ExtendHumiliation.smx .

chmod 0664 *.smx

printf "\nsm plugins unload properpregame\n" >> $HOME/hlserver/tf2/tf/cfg/sourcemod/soap_live.cfg
printf "\nsm plugins load properpregame\n" >> $HOME/hlserver/tf2/tf/cfg/sourcemod/soap_notlive.cfg

cd $HOME/hlserver/tf2/tf
