This repository has been archived by the owner on Feb 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LCFilesInstaller.ps1
52 lines (49 loc) · 2.29 KB
/
LCFilesInstaller.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
$WarningPreference = 'SilentlyContinue'
$VersionFile = iwr -Uri "https://launcherupdates.lunarclientcdn.com/latest.yml" -OutFile "$env:Temp\Version.txt"
$Version = cat "$env:Temp\Version.txt" | Select-Object -First 1
$Version = $Version.Trim("version: ")
$GameVersion = $args[0]
$params = @{
"hwid"="0";
"hwid_private"="0";
"os"="win32";
"arch"="x64";
"launcher_version"="$Version";
"version"="$GameVersion";
"branch"="master";
"launch_type"="0";
"classifier"="0";
}
$Index = iwr "https://api.lunarclientprod.com/launcher/launch" -Method POST -Body ($params|ConvertTo-Json) -ContentType "application/json" -OutFile "$env:Temp\Index.txt"
$Index = cat "$env:Temp\index.txt"
$Files=($Index | ConvertFrom-Json).launchTypeData.artifacts
$Licenses=($Index | ConvertFrom-Json).licenses
$JRE=($Index | ConvertFrom-Json).jre.download.url
$JRE_Name=($Index | ConvertFrom-Json).jre.executablePathInArchive[0]
$null = New-Item -Path ".lunarclient_files" -ItemType "Directory"
$null = New-Item -Path ".lunarclient_files\licenses" -Type "Directory"
$null = New-Item -Path ".lunarclient_files\offline\$GameVersion" -Type "Directory"
$null = New-Item -Path ".lunarclient_files\jre" -Type "Directory"
cls
Write-Output "Getting Licenses..."
foreach ($file in $Licenses) {
curl.exe -# -L -o ".lunarclient_files\licenses\$($file.file)" $file.url
}
Write-Output "Downloading LC ($GameVersion)..."
Write-Output "Getting LC Jars, Natives & Optifine..."
foreach ($file in $Files) {
if ($file.name.EndsWith(".jar")) {
curl.exe -# -L -o ".lunarclient_files\offline\$GameVersion\$($file.name)" $file.url
}
if ($file.name.EndsWith(".zip")) {
curl.exe -# -L -o ".lunarclient_files\offline\$GameVersion\$($file.name)" $file.url
Expand-Archive -Path ".lunarclient_files\offline\$GameVersion\$($file.name)" -DestinationPath ".lunarclient_files\offline\$GameVersion\natives" -Force
}
}
if (!(Test-Path -LiteralPath ".lunarclient_files\jre\$JRE_Name")){
Remove-Item -Path ".lunarclient_files\jre" -Force -Recurse | Out-Null
Write-Output "Downloading JRE..."
$null = New-Item -Path ".lunarclient_files\jre\$JRE_Name" -Type "Directory"
curl.exe -# -L -o "$env:Temp\$JRE_Name.zip" $JRE
Expand-Archive -Path "$env:Temp\$JRE_Name.zip" -DestinationPath ".lunarclient_files\jre" -Force
}