From 2f4d1b5fb8efb84c2c89a773ef987675023634b1 Mon Sep 17 00:00:00 2001 From: Patrick Albus <34771575+Narua2010@users.noreply.github.com> Date: Wed, 31 Mar 2021 19:04:15 +0200 Subject: [PATCH] Update structure --- ClickMe.cmd => source/ClickMe.cmd | 0 update.ps1 => source/update.ps1 | 232 +++++++++++++++--------------- 2 files changed, 116 insertions(+), 116 deletions(-) rename ClickMe.cmd => source/ClickMe.cmd (100%) rename update.ps1 => source/update.ps1 (96%) diff --git a/ClickMe.cmd b/source/ClickMe.cmd similarity index 100% rename from ClickMe.cmd rename to source/ClickMe.cmd diff --git a/update.ps1 b/source/update.ps1 similarity index 96% rename from update.ps1 rename to source/update.ps1 index 40227b2..65e52e8 100644 --- a/update.ps1 +++ b/source/update.ps1 @@ -1,117 +1,117 @@ -Add-Type -AssemblyName System.IO.Compression.FileSystem - -$request = 'https://api.github.com/repos/Eisbison/TheOtherRoles/releases/latest' -$Jsontest = Invoke-RestMethod $request -$JSONDownload = Write-Output $Jsontest.assets.browser_download_url -$id = Write-Output $Jsontest.id -$exefile = "" - -function Unzip -{ - param([string]$zipfile, [string]$outpath) - Expand-Archive -Path $zipfile -DestinationPath $outpath -Force -} - -function ClearOtherMods -{ - if (Test-Path "./mono") { - Remove-Item "./mono" -Recurse - } - if(Test-Path "./BepInEx"){ - if(Test-Path "./BepInEx/core"){ - Remove-Item "./BepInEx/core" -Recurse - } - if(Test-Path "./BepInEx/plugin"){ - Remove-Item "./BepInEx/plugin" -Recurse - } - if(Test-Path "./BepInEx/unity-libs"){ - Remove-Item "./BepInEx/unity-libs" -Recurse - } - if(Test-Path "./BepInEx"){ - if(Test-Path "./BepInEx/cache"){ - Remove-Item "./BepInEx/cache" -Recurse - } - if(Test-Path "./BepInEx/patchers"){ - Remove-Item "./BepInEx/patchers" -Recurse - } - if(Test-Path "./BepInEx/plugins"){ - Remove-Item "./BepInEx/plugins" -Recurse - } - if(Test-Path "./BepInEx/config"){ - if(Test-Path "./BepInEx/config/BepInEx.cfg") { - Remove-Item "./BepInEx/config/BepInEx.cfg" -Recurse - } - if(Test-Path "./BepInEx/config/gg.reactor.api.cfg"){ - Remove-Item "./BepInEx/config/gg.reactor.api.cfg" -Recurse - } - if(Test-Path "./BepInEx/config/me.eisbison.theotherroles.cfg"){ - Remove-Item "./BepInEx/config/me.eisbison.theotherroles.cfg" -Recurse - } - } - } - } - -} - -function getOtherMods { - ClearOtherMods - if(Test-Path ".\otherroles.zip"){ - Remove-Item ".\otherroles.zip" -force - } - Invoke-WebRequest -Uri $JSONDownload -OutFile .\otherroles.zip - (get-item .\otherroles.zip).Attributes += 'Hidden' - Write-Host "Please Wait ..." - - Unzip ".\otherroles.zip" "." -} - -function overwriteVersion { - if(Test-Path .\version.txt){ - Remove-Item .\version.txt -force - Write-Output $Jsontest.id | Out-File -FilePath .\version.txt - (get-item .\version.txt).Attributes += 'Hidden' - } else { - Write-Output $Jsontest.id | Out-File -FilePath .\version.txt - (get-item .\version.txt).Attributes += 'Hidden' - } -} - - -Write-Host "Among Us Mod Updater created by Jolle & Narua" - - -if(Test-Path ".\version.txt"){ - $idfile = Get-Content -Path .\version.txt - if("$($idfile)" -ne "$($id)") { - overwriteVersion - Write-Host "Old files will be deleted ..." - Write-Host "`n `n `n `n `n `n `n `n `n Please Wait ..." - getOtherMods - } else { - if (((Test-Path "./mono") -eq $False) -or ((Test-Path "./BepInEx") -eq $False)) { - echo "Cannot find Mono or BepInEx directories ..." - getOtherMods - } - } -} else { - overwriteVersion - Write-Host "`n `n `n `n `n `n `n `n `n Please Wait ..." - getOtherMods -} - -Try{ - $exefile = Get-Childitem -Path ".\Among Us.exe" -ErrorAction Stop -Include *.exe -Recurse - } - catch [System.Exception]{ - Write-Host "Among Us.exe not found ... Check game directory for Among Us.exe ..." - Start-Sleep 10 -} - -if("$($exefile)" -ne ""){ - Write-Host "$($exefile)" - Start-Process -FilePath "$($exefile)" - Write-Host "Game is starting..." - Start-Sleep 10 - Write-Host "After fresh update game loads slower ..." - Start-Sleep 25 +Add-Type -AssemblyName System.IO.Compression.FileSystem + +$request = 'https://api.github.com/repos/Eisbison/TheOtherRoles/releases/latest' +$Jsontest = Invoke-RestMethod $request +$JSONDownload = Write-Output $Jsontest.assets.browser_download_url +$id = Write-Output $Jsontest.id +$exefile = "" + +function Unzip +{ + param([string]$zipfile, [string]$outpath) + Expand-Archive -Path $zipfile -DestinationPath $outpath -Force +} + +function ClearOtherMods +{ + if (Test-Path "./mono") { + Remove-Item "./mono" -Recurse + } + if(Test-Path "./BepInEx"){ + if(Test-Path "./BepInEx/core"){ + Remove-Item "./BepInEx/core" -Recurse + } + if(Test-Path "./BepInEx/plugin"){ + Remove-Item "./BepInEx/plugin" -Recurse + } + if(Test-Path "./BepInEx/unity-libs"){ + Remove-Item "./BepInEx/unity-libs" -Recurse + } + if(Test-Path "./BepInEx"){ + if(Test-Path "./BepInEx/cache"){ + Remove-Item "./BepInEx/cache" -Recurse + } + if(Test-Path "./BepInEx/patchers"){ + Remove-Item "./BepInEx/patchers" -Recurse + } + if(Test-Path "./BepInEx/plugins"){ + Remove-Item "./BepInEx/plugins" -Recurse + } + if(Test-Path "./BepInEx/config"){ + if(Test-Path "./BepInEx/config/BepInEx.cfg") { + Remove-Item "./BepInEx/config/BepInEx.cfg" -Recurse + } + if(Test-Path "./BepInEx/config/gg.reactor.api.cfg"){ + Remove-Item "./BepInEx/config/gg.reactor.api.cfg" -Recurse + } + if(Test-Path "./BepInEx/config/me.eisbison.theotherroles.cfg"){ + Remove-Item "./BepInEx/config/me.eisbison.theotherroles.cfg" -Recurse + } + } + } + } + +} + +function getOtherMods { + ClearOtherMods + if(Test-Path ".\otherroles.zip"){ + Remove-Item ".\otherroles.zip" -force + } + Invoke-WebRequest -Uri $JSONDownload -OutFile .\otherroles.zip + (get-item .\otherroles.zip).Attributes += 'Hidden' + Write-Host "Please Wait ..." + + Unzip ".\otherroles.zip" "." +} + +function overwriteVersion { + if(Test-Path .\version.txt){ + Remove-Item .\version.txt -force + Write-Output $Jsontest.id | Out-File -FilePath .\version.txt + (get-item .\version.txt).Attributes += 'Hidden' + } else { + Write-Output $Jsontest.id | Out-File -FilePath .\version.txt + (get-item .\version.txt).Attributes += 'Hidden' + } +} + + +Write-Host "Among Us Mod Updater created by Jolle & Narua" + + +if(Test-Path ".\version.txt"){ + $idfile = Get-Content -Path .\version.txt + if("$($idfile)" -ne "$($id)") { + overwriteVersion + Write-Host "Old files will be deleted ..." + Write-Host "`n `n `n `n `n `n `n `n `n Please Wait ..." + getOtherMods + } else { + if (((Test-Path "./mono") -eq $False) -or ((Test-Path "./BepInEx") -eq $False)) { + echo "Cannot find Mono or BepInEx directories ..." + getOtherMods + } + } +} else { + overwriteVersion + Write-Host "`n `n `n `n `n `n `n `n `n Please Wait ..." + getOtherMods +} + +Try{ + $exefile = Get-Childitem -Path ".\Among Us.exe" -ErrorAction Stop -Include *.exe -Recurse + } + catch [System.Exception]{ + Write-Host "Among Us.exe not found ... Check game directory for Among Us.exe ..." + Start-Sleep 10 +} + +if("$($exefile)" -ne ""){ + Write-Host "$($exefile)" + Start-Process -FilePath "$($exefile)" + Write-Host "Game is starting..." + Start-Sleep 10 + Write-Host "After fresh update game loads slower ..." + Start-Sleep 25 } \ No newline at end of file