Skip to content

Commit

Permalink
Add ps1 version
Browse files Browse the repository at this point in the history
  • Loading branch information
dginovker committed Jan 6, 2024
1 parent ff61ae4 commit 1da9c7c
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions 2009scape.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Ensure PowerShell can use Net.WebClient for downloading files
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

# Function to download a file
Function Download-File([string]$url, [string]$path) {
$webClient = New-Object System.Net.WebClient
$webClient.DownloadFile($url, $path)
}

# File URLs and paths
$jarUrl = "https://gitlab.com/2009scape/rt4-client/-/jobs/5406815814/artifacts/raw/client/build/libs/rt4-client.jar"
$jarPath = "rt4-client.jar"
$javaInstallerUrl = "https://github.com/ojdkbuild/ojdkbuild/releases/download/java-1.8.0-openjdk-1.8.0.332-1.b09-x86/java-1.8.0-openjdk-1.8.0.332-1.b09.ojdkbuild.windows.x86.msi"
$javaInstallerPath = "java_installer.msi"

# Download rt4-client.jar
Download-File -url $jarUrl -path $jarPath

# Create config.json with the provided content
$configContent = @"
{
"ip_management": "play.2009scape.org",
"ip_address": "play.2009scape.org",
"world": 1,
"server_port": 43594,
"wl_port": 43595,
"js5_port": 43595,
"ui_scale": 1,
"fps": 0
}
"@
$configPath = "config.json"
$configContent | Out-File -FilePath $configPath

# Check if Java is installed
$javaVersion = (java -version 2>&1)
if($javaVersion -like "*'java' is not recognized*") {
# Java is not installed, download and install Java
Write-Host "Java is not installed. Downloading and installing Java..."
Download-File -url $javaInstallerUrl -path $javaInstallerPath
Start-Process -FilePath $javaInstallerPath -Wait
} else {
Write-Host "Java is already installed."
}

# Run rt4-client.jar with Java
java -jar $jarPath

0 comments on commit 1da9c7c

Please sign in to comment.