Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

更新: win用户只需一行命令即可安装TShock #413

Merged
merged 5 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions InstallTShock.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function Get-DownloadUrl {
}

$json = $response.Content | ConvertFrom-Json
# 验证JSON是否包含tag_name属性

if (-not ($json -and $json.assets[3].browser_download_url)) {
throw "The JSON content at '$url' does not contain a valid 'tag_name' property."
}
Expand Down Expand Up @@ -50,10 +50,12 @@ function Get-TShockZip{
#$ProgressPreference = 'SilentlyContinue'
$zipFile = "./TShock.zip"

$response = Invoke-WebRequest -Uri $url -UseBasicParsing
$response = Invoke-WebRequest -Uri $url -UseBasicParsing
# 检查HTTP状态码
if ($response.StatusCode -ne 200) {
throw "Failed to retrieve the resource at '$url'. Status code: $($response.StatusCode)"
}
[IO.File]::WriteAllBytes($zipFile, $response.Content)
#$wc = New-Object System.Net.WebClient
#$wc.DownloadFile($url, $zipFile)
Write-Host "Ready to start unzipping TShock.zip...."
Expand-Archive -Path "./TShock.zip" -DestinationPath "./TShockServer/"
Remove-Item -Path $zipFile -Force
Expand All @@ -62,9 +64,9 @@ function Get-TShockZip{
Set-Location ./TShockServer
Start-Process -FilePath ./TShock.Server.exe -ArgumentList "-lang 7"
}
}
catch{
throw "$_"
}catch [System.Net.WebException], [System.Management.Automation.PSInvocationException] {
# 处理可能的网络异常和JSON解析异常
throw "Error when attempting to get version from '$url': $_"
}
}
}
Expand All @@ -82,6 +84,4 @@ if ($proxys -ge 0 -and $index -lt $proxys.Length){
Get-TShockZip -proxy $proxys[$index - 1]
}else{
Write-Host "Input Number Error!"
}


}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
- 国内镜像: [Plugins.zip](https://github.moeyy.xyz/https://github.com/Controllerdestiny/TShockPlugin/releases/download/V1.0.0.0/Plugins.zip)
- 本仓库: [Plugins.zip](https://github.com/Controllerdestiny/TShockPlugin/releases/tag/V1.0.0.0)

## 如何安装TShock
- 如果你是Window用户可以选择使用以下命令一次性安装(在pwsh中运行此命令即可)
```
curl -o install.ps1 https://github.moeyy.xyz/https://raw.githubusercontent.com/UnrealMultiple/TShockPlugin/master/InstallTShock.ps1
powershell -ExecutionPolicy ByPass -File ./install.ps1 -verb runas
```

## 开发者注意事项

Expand Down
Loading