param( [Parameter(Mandatory=$false)] [switch]$ManualInstallation ) $UrlList_URL = 'https://gist.githubusercontent.com/thecats1105/65d710516b19732f2b0d96e61b151d6b/raw/ebf88509c816e53355c580b5a925e7bb498a7f37/url_list.txt' $Modpack_URL = 'https://mediafilez.forgecdn.net/files/6766/749/Better%20MC%20%5BNEOFORGE%5D%201.21.1%20v35.zip' function Save-UrlList { param ( [Parameter(Mandatory=$true)] [string]$UrlListPath ) # Download the URL list from the specified URL try { Invoke-RestMethod -Uri $UrlList_URL -OutFile $UrlListPath -ErrorAction Stop Write-Host "URL list saved to $UrlListPath" } catch { Write-Error "Failed to download URL list: $($_.Exception.Message)" } } $UrlListPath = Join-Path $Env:TEMP 'url_list.txt' Save-UrlList -UrlListPath $UrlListPath function Get-DownloadFolderPath { $downloadFolderPath = (Get-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders").PSObject.Properties["{374DE290-123F-4565-9164-39C4925E467B}"].Value return $downloadFolderPath } function Show-LoadingBar { param ( [Parameter(Mandatory=$true)] [int]$DurationSeconds ) $steps = 50 $barLength = 30 Write-Host -NoNewline "[" for ($i = 1; $i -le $steps; $i++) { $progress = [math]::Floor(($i / $steps) * $barLength) $bar = ('=' * $progress).PadRight($barLength) Write-Host -NoNewline "`r[$bar]" Start-Sleep -Milliseconds ([math]::Round(($DurationSeconds * 1000) / $steps)) } Write-Host "]" } function Downloader { param( [Parameter(Mandatory=$true)] [string]$UrlListPath, [string]$OutPath ) # Load System.Web Assembly if (-not ("System.Web" -in [AppDomain]::CurrentDomain.GetAssemblies().Location)) { try { Add-Type -AssemblyName System.Web } catch { Write-Warning "Failed to load System.Web assembly. It may already be loaded or there may be another issue." } } if (-Not (Test-Path $UrlListPath)) { Write-Error "`"url_list.txt`" does not exist" exit 1 } if (-Not (Test-Path $OutPath)) { mkdir $OutPath | Out-Null } $urls = Get-Content $UrlListPath | Where-Object { $_.Trim() -ne "" } function DownloadFile { param( [Parameter(Mandatory=$true, Position=0)] [string]$Url, [Parameter(Mandatory=$true, Position=1)] [string]$OutPath ) # Get the file name from the URL $uri = New-Object System.Uri($Url) $encodedFileName = $uri.Segments[-1] # Decode the file name $decodedFileName = [System.Web.HttpUtility]::UrlDecode($encodedFileName) # File Download Write-Host "Download Started: $Url" Write-Host "Saved file name: $decodedFileName" $outFilePath = Join-Path $OutPath $decodedFileName try { Invoke-WebRequest -Uri $Url -OutFile (Join-Path $OutPath 'temp') -ErrorAction Stop Move-Item -LiteralPath (Join-Path $OutPath 'temp') -Destination $outFilePath -Force Write-Host "File download completed: $decodedFileName" } catch { Write-Error "An error occurred while downloading the file: $($_.Exception.Message)" } } foreach ($url in $urls) { Write-Host "Downloading: $url" DownloadFile -Url $url -OutPath $OutPath } } function Test-AdminPrivileges { $currentUser = [Security.Principal.WindowsIdentity]::GetCurrent() $principal = New-Object Security.Principal.WindowsPrincipal($currentUser) $isAdmin = $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) if ($isAdmin) { Write-Output '이 스크립트는 관리자 권한으로 실행하면 안 됩니다.' Write-Output '일반 사용자 권한으로 다시 실행해주세요.' if ($IS_EXECUTED_FROM_IEX) { break } else { exit 1 } } } function Test-LanguageMode { if ($ExecutionContext.SessionState.LanguageMode -ne 'FullLanguage') { Write-Output '이 설치 프로그램은 PowerShell FullLanguage 모드에서 실행되어야 합니다. 현재 PowerShell 환경은 제한되어 있습니다.' Write-Output '중단합니다.' if ($IS_EXECUTED_FROM_IEX) { break } else { exit $errorCode } } } function Install-PrismLauncher { winget.exe install --id "PrismLauncher.PrismLauncher" -e --source winget --accept-source-agreements --accept-package-agreements # Check if the installation was successful if ($LASTEXITCODE -eq 0) { Write-Output 'Prism Launcher가 성공적으로 설치되었습니다.' } elseif ($LASTEXITCODE -eq -1978335189) { Write-Output 'Prism Launcher가 이미 설치되어 있습니다.' } else { Write-Output 'Prism Launcher 설치에 실패했습니다.' if ($IS_EXECUTED_FROM_IEX) { break } else { exit $errorCode } } } function Install-Modpack { $PrismLauncher_Path = Join-Path -Path $Env:LOCALAPPDATA -ChildPath 'Programs\PrismLauncher\prismlauncher.exe' cmd /c "start `"`" `"$PrismLauncher_Path`" --import `"$Modpack_URL`"" } # Prepare variables $IS_EXECUTED_FROM_IEX = ($null -eq $MyInvocation.MyCommand.Path) # Abort when the language mode is restricted Test-LanguageMode # Install Prism Launcher Install-PrismLauncher # Select Installation Mode if ($ManualInstallation) { # Show a message about the installation of Prism Launcher Write-Output '모드팩 설치를 계속합니다.' Show-LoadingBar -DurationSeconds 2 Start-Sleep -Seconds 1 # Show a message about assets that cannot be installed by Prism Launcher Clear-Host Write-Output '해당 모드팩의 일부 에셋들은 Prism Launcher에서 설치할 수 없습니다.' Write-Output '그럼으로 자동으로 사용자의 "다운로드" 폴더에 해당 파일들을 다운로드 합니다.' Write-Output '이에 동의하시면 Enter 키를 누르세요' Read-Host # Show a message about downloading files Clear-Host Write-Output '잠시 기다려주세요, 곧 파일들이 다운로드 폴더에 다운로드 될 것입니다.' Write-Output '다운로더를 불러오는 중입니다...' Show-LoadingBar -DurationSeconds 5 Clear-Host Write-Output '파일을 다운로드하는 중입니다...' $OutPath = Get-DownloadFolderPath Downloader -UrlListPath $UrlListPath -OutPath $OutPath # Show a message about the completion of the download Write-Output '모든 파일이 성공적으로 다운로드 되었습니다.' Write-Output 'Enter 키를 눌러 다음 단계로 넘어가세요.' Read-Host # Show a message about Manual Instance Creation Clear-Host Write-Output '1. Prism Launcher를 실행하고, 아직 초기 설정을 진행하지 않으셨다면 마무리하세요.' Write-Output '2. 메인 메뉴 상단의 인스턴스 추가를 누르세요.' Write-Output '3. "불러오기" 탭을 선택하고, 아래 URL을 복사하여 입력하세요.' Write-Output '' Write-Output " $Modpack_URL" Write-Output '' Write-Output '4. 확인을 누르세요.' Write-Output '5. "차단된 모드를 찾았습니다." 창이 표시되면 확인을 누르세요.' Write-Output ' - 만약 모드들을 찾지 못한다면, "다운로드 폴더 추가" 버튼을 누르고 본인의 다운로드 폴더를 선택하세요.' Write-Output '' Write-Output '모두 완료하였다면 Enter 키를 눌러 다음 단계로 넘어가세요.' Read-Host # Set memory allocation Clear-Host Write-Output '[거의 다 왔어요!]' Write-Output '1. 메인 메뉴에 표시된 인스턴스를 우클릭 하고, 편집을 누르세요.' Write-Output '2. 설정 탭에 들어가, 메모리 부분을 체크한 뒤, 자신에게 맞는 메모리 양을 할당하세요.' Write-Output '' Write-Output '[올바른 메모리 할당량]' Write-Output '- 자신의 시스템 메모리 여유가 8GB 미만' Write-Output ' - 최소/최대 메모리 할당량: 5120 MiB' Write-Output '- 자신의 시스템 메모리 여유가 8~10GB 이상' Write-Output ' - 최소/최대 메모리 할당량: 8192 MiB' Write-Output '' Write-Output '완료하셨나요? Enter 키를 눌러 설치를 종료하세요!' Read-Host if ($IS_EXECUTED_FROM_IEX) { break } else { exit 0 } } else { # Abort when the script is run with administrator privileges Test-AdminPrivileges # Show a message about the installation of Prism Launcher Write-Output '모드팩 설치를 계속합니다.' Show-LoadingBar -DurationSeconds 2 Start-Sleep -Seconds 1 # Show a message about assets that cannot be installed by Prism Launcher Clear-Host Write-Output '해당 모드팩의 일부 에셋들은 Prism Launcher에서 설치할 수 없습니다.' Write-Output '그럼으로 자동으로 사용자의 "다운로드" 폴더에 해당 파일들을 다운로드 합니다.' Write-Output '이에 동의하시면 Enter 키를 누르세요.' Read-Host # Show a message about downloading files Clear-Host Write-Output '잠시 기다려주세요, 곧 파일들이 다운로드 폴더에 다운로드 될 것입니다.' Write-Output '다운로더를 불러오는 중입니다...' Show-LoadingBar -DurationSeconds 5 Clear-Host Write-Output '파일을 다운로드하는 중입니다...' $OutPath = Get-DownloadFolderPath Downloader -UrlListPath $UrlListPath -OutPath $OutPath # Show a message about the completion of the download Write-Output '모든 파일이 성공적으로 다운로드 되었습니다.' Write-Output 'Enter 키를 눌러 모드팩 설치를 시작하세요.' Read-Host # Start the modpack installation Clear-Host Install-Modpack Write-Output '모드팩 설치 프로그램이 실행되었습니다. 설치를 마치고 인스턴스가 메인 메뉴에 표시되면 Enter 키를 눌러 다음 단계로 넘어가세요.' Write-Output '- 설치 중 "차단된 모드를 찾았습니다" 메시지가 표시되시나요?' Write-Output ' - 확인을 눌러 계속 진행하세요.' Write-Output ' - 만약 모드들을 찾지 못한다면, "다운로드 폴더 추가" 버튼을 누르고 본인의 다운로드 폴더를 선택하세요.' Read-Host # Set memory allocation Clear-Host Write-Output '[거의 다 왔어요!]' Write-Output '1. 메인 메뉴에 표시된 인스턴스를 우클릭 하고, 편집을 누르세요.' Write-Output '2. 설정 탭에 들어가, 메모리 부분을 체크한 뒤, 자신에게 맞는 메모리 양을 할당하세요.' Write-Output '' Write-Output '[올바른 메모리 할당량]' Write-Output '- 자신의 시스템 메모리 여유가 8GB 미만' Write-Output ' - 최소/최대 메모리 할당량: 5120 MiB' Write-Output '- 자신의 시스템 메모리 여유가 8~10GB 이상' Write-Output ' - 최소/최대 메모리 할당량: 8192 MiB' Write-Output '' Write-Output '완료하셨나요? Enter 키를 눌러 설치를 종료하세요!' Read-Host if ($IS_EXECUTED_FROM_IEX) { break } else { exit 0 } }