param([string]$Game = 'D:\SteamLibrary\steamapps\common\ProjectZomboid', [string]$Viewpoint = 'D:\SteamLibrary\steamapps\workshop\content\108600\3809306528\mods\Viewpoint\42\media\java\client\Viewpoint.jar', [string]$BuildDirectory = (Join-Path (Get-Location) 'work\MTKViewpointTurrets-build'), [switch]$Sign) $ErrorActionPreference = 'Stop' $buildDir = [System.IO.Path]::GetFullPath($BuildDirectory) New-Item -ItemType Directory -Force -Path $buildDir | Out-Null $jarDir = Join-Path $PSScriptRoot '42.20\media\java\client' New-Item -ItemType Directory -Force -Path $jarDir | Out-Null $sources = @(Get-ChildItem -LiteralPath (Join-Path $PSScriptRoot 'source') -Recurse -Filter '*.java' | ForEach-Object FullName) & javac --release 25 -classpath "$Game\projectzomboid.jar;$Game\ZombieBuddy.jar;$Viewpoint" -d $buildDir @sources if ($LASTEXITCODE -ne 0) { throw 'Java compilation failed.' } & jar --create --file "$jarDir\MTKViewpointTurrets-0.2.0.jar" -C $buildDir . if ($LASTEXITCODE -ne 0) { throw 'JAR packaging failed.' } Write-Host "Built $jarDir\MTKViewpointTurrets-0.2.0.jar" if ($Sign) { & (Join-Path $PSScriptRoot 'Sign.ps1') }