diff --git a/mc-java/start.ps1 b/mc-java/start.ps1 index 6e472d4..212304a 100644 --- a/mc-java/start.ps1 +++ b/mc-java/start.ps1 @@ -1,9 +1,27 @@ $basedir=(Get-Location) $buildtools=$basedir.Path + "\..\.tools\buildtools" $version="1.19.4" +$java=$env:JAVA_HOME +if ( $args.count -eq 0 ) { Set-Location ($basedir.Path+"\server") -A:\scoop\apps\zulu-jdk\current\bin\java.exe -jar (".\spigot-"+$version+".jar") --nogui +& $java\bin\java.exe -jar (".\spigot-"+$version+".jar") --nogui +} +elseif ($args[0] -eq "background") { +$serverProcess = New-Object System.Diagnostics.ProcessStartInfo; +$serverProcess.FileName = ($java + "\bin\java.exe"); #process file +$serverProcess.Arguments = ("-jar " + $basedir.Path + "\server\spigot-"+$version+".jar --nogui"); +$serverProcess.WorkingDirectory = ($basedir.Path+"\server"); +$serverProcess.UseShellExecute = $false; #start the process from it's own executable file +$serverProcess.RedirectStandardInput = $true; #enable the process to read from standard input + +$p = [System.Diagnostics.Process]::Start($serverProcess); + +Start-Sleep -s 50 #wait 2 seconds so that the process can be up and running + +$p.StandardInput.WriteLine("stop"); #StandardInput property of the Process is a .NET StreamWriter object + +} Set-Location $basedir \ No newline at end of file diff --git a/mc-java/update.ps1 b/mc-java/update.ps1 index c71f345..0705a72 100644 --- a/mc-java/update.ps1 +++ b/mc-java/update.ps1 @@ -1,9 +1,10 @@ $basedir=(Get-Location) $buildtools=$basedir.Path + "\..\.tools\buildtools" $version="1.19.4" +$java=$env:JAVA_HOME Set-Location $buildtools -A:\scoop\apps\zulu-jdk\current\bin\java.exe -jar .\BuildTools.jar --rev $version +& $java\bin\java.exe -jar .\BuildTools.jar --rev $version Set-Location $basedir Move-Item ($buildtools + "\spigot-" + $version + ".jar") .\server\.