2026-09-08 19:44:45 +03:00
|
|
|
param(
|
|
|
|
|
[string]$ServerDirectory = 'C:/Users/ScarPC/Documents/NeoForge Server 26.2',
|
|
|
|
|
[string]$Java = 'java',
|
2026-09-12 13:47:11 +03:00
|
|
|
[int]$Port = 25639,
|
|
|
|
|
[string]$PlusDirectory = ''
|
2026-09-08 19:44:45 +03:00
|
|
|
)
|
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
|
$repo = Split-Path $PSScriptRoot -Parent
|
|
|
|
|
$plus = Join-Path (Split-Path $repo -Parent) 'AstraPlus'
|
2026-09-12 13:47:11 +03:00
|
|
|
if ($PlusDirectory) { $plus = (Resolve-Path -LiteralPath $PlusDirectory).Path }
|
2026-09-08 19:44:45 +03:00
|
|
|
$run = Join-Path $repo ('build/verification-' + (Get-Date -Format 'yyyyMMdd-HHmmss') + '-' + [guid]::NewGuid().ToString('N').Substring(0,6))
|
|
|
|
|
New-Item -ItemType Directory -Path (Join-Path $run 'mods') -Force | Out-Null
|
2026-09-10 13:41:42 +03:00
|
|
|
$plusVersion = [regex]::Match((Get-Content "$plus/build.gradle.kts" -Raw), '(?m)^version = "([^"]+)"').Groups[1].Value
|
|
|
|
|
$cauldronVersion = [regex]::Match((Get-Content "$repo/build.gradle.kts" -Raw), '(?m)^version = "([^"]+)"').Groups[1].Value
|
|
|
|
|
foreach ($jar in @("$plus/build/libs/AstraPlus-$plusVersion.jar", "$repo/build/libs/AstraCauldron-$cauldronVersion.jar", "$repo/build/libs/AstraCauldron-$cauldronVersion-verification.jar")) {
|
2026-09-08 19:44:45 +03:00
|
|
|
Copy-Item -LiteralPath $jar -Destination (Join-Path $run 'mods')
|
|
|
|
|
}
|
|
|
|
|
$serverRoot = (Resolve-Path -LiteralPath $ServerDirectory).Path.Replace('\','/')
|
|
|
|
|
$argsLines = Get-Content -LiteralPath "$ServerDirectory/libraries/net/neoforged/neoforge/26.2.0.79/win_args.txt"
|
|
|
|
|
$argsText = (@(foreach ($line in $argsLines) {
|
|
|
|
|
if ($line -eq '-DlibraryDirectory=libraries') { '"-DlibraryDirectory=' + $serverRoot + '/libraries"' }
|
|
|
|
|
elseif ($line.StartsWith('libraries/')) { '"' + $line.Replace('libraries/', "$serverRoot/libraries/") + '"' }
|
|
|
|
|
else { $line }
|
|
|
|
|
}) -join "`n")
|
|
|
|
|
[IO.File]::WriteAllText((Join-Path $run 'server-args.txt'), $argsText, [Text.UTF8Encoding]::new($false))
|
|
|
|
|
[IO.File]::WriteAllText((Join-Path $run 'eula.txt'), 'eula=true')
|
|
|
|
|
$properties = @"
|
|
|
|
|
server-ip=127.0.0.1
|
|
|
|
|
server-port=$Port
|
|
|
|
|
online-mode=false
|
|
|
|
|
level-type=minecraft:flat
|
|
|
|
|
generator-settings={"layers":[{"block":"minecraft:bedrock","height":1},{"block":"minecraft:dirt","height":2},{"block":"minecraft:grass_block","height":1}],"biome":"minecraft:plains"}
|
|
|
|
|
generate-structures=false
|
|
|
|
|
spawn-protection=0
|
|
|
|
|
view-distance=2
|
|
|
|
|
simulation-distance=2
|
|
|
|
|
max-tick-time=90000
|
|
|
|
|
use-native-transport=false
|
|
|
|
|
motd=AstraCauldron isolated verification
|
|
|
|
|
"@
|
|
|
|
|
[IO.File]::WriteAllText((Join-Path $run 'server.properties'), $properties)
|
|
|
|
|
Set-Content -LiteralPath "$repo/build/active-verification.txt" -Value $run
|
|
|
|
|
Push-Location $run
|
|
|
|
|
try {
|
|
|
|
|
foreach ($phase in @('gameplay','restart')) {
|
|
|
|
|
& $Java '-Xms256M' '-Xmx1G' '-Dastracauldron.isolatedVerification=true' '@server-args.txt' nogui *> "$phase.log"
|
|
|
|
|
if ($LASTEXITCODE -ne 0) { throw "Server failed: $run/$phase.log" }
|
|
|
|
|
$result = Get-Content -LiteralPath 'verification-result.txt' -Raw
|
|
|
|
|
if ($result -match '(?m)^FAIL' -or $result -notmatch "PASS ${phase}:") { throw "Verification failed: $run/verification-result.txt" }
|
|
|
|
|
Copy-Item -LiteralPath 'verification-result.txt' -Destination "$phase-result.txt"
|
|
|
|
|
Write-Output (($result -split "`n")[-1])
|
|
|
|
|
}
|
|
|
|
|
} finally { Pop-Location }
|
|
|
|
|
Write-Output "Verified both launches: $run"
|