Add pre-launch and post-exit powershell scripts (#307)

* Add files via upload

* cleanup

* a

* Update post-exit.ps1

* parity

* Update pre-launch.ps1

Co-authored-by: Madis Otenurm <Madis0@users.noreply.github.com>
This commit is contained in:
Ultrasonic1209 2022-05-23 18:56:20 +01:00 committed by GitHub
parent a0376577bb
commit 9bc287f27f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 52 additions and 0 deletions

12
Packwiz/post-exit.ps1 Normal file
View file

@ -0,0 +1,12 @@
# By Ultrasonic1209
# Restore packwiz disabled mods to prevent useless redownload
Write-Output "Restoring overridden mods for future launches..."
Set-Location ".\mods"
$mods = Get-ChildItem *.jar.disabled
foreach ( $mod in $mods ) {
Move-Item -Path $mod.name -Destination ($mod.FullName).Replace(".disabled","") -Force
Write-Output "$($mod.name.Replace(".disabled", '')) restored successfully!"
}

40
Packwiz/pre-launch.ps1 Normal file
View file

@ -0,0 +1,40 @@
# By Ultrasonic1209
$mods = @(
'ModYouDislike.jar'
'AnotherMod.jar'
)
# Upgrading Fabulously Optimized
Write-Output "Checking for FO updates..."
Set-Location ..
$json = Get-Content "mmc-pack.json" | ConvertFrom-Json
$table = $json.components | Where-Object { $_.cachedName -eq "Minecraft" }
$mcVersion = $table.version
if (Test-Path -Path ".\.minecraft") {
Set-Location ".\.minecraft"
} else {
Set-Location ".\minecraft"
}
$processOptions = @{
FilePath = $Env:INST_JAVA
ArgumentList = "-jar packwiz-installer-bootstrap.jar",
"https://raw.githubusercontent.com/Fabulously-Optimized/fabulously-optimized/main/Packwiz/$mcVersion/pack.toml"
}
Start-Process @processOptions -Wait
# Disabling the mods
Write-Output "Disabling mods..."
Set-Location ".\mods"
foreach ($mod in $mods) {
Move-Item -Path $mod -Destination "$mod.disabled" -Force
if ($?) {
Write-Output "$mod disabled successfully!"
}
}