From c1e7a8614afa0283d6a60496a078f77765f4f468 Mon Sep 17 00:00:00 2001 From: Yannik Bretschneider Date: Tue, 20 Jul 2021 23:48:50 +0200 Subject: [PATCH] script: added and updated scripts for more fanciness --- startServerLocally.ps1 | 55 +++++++++++++++++++++++++++++++++--------- updateSubmodule.bat | 1 + updateSubmodule.ps1 | 35 ++++++++++++++++++++++----- 3 files changed, 73 insertions(+), 18 deletions(-) diff --git a/startServerLocally.ps1 b/startServerLocally.ps1 index e6d3343..751e3b4 100644 --- a/startServerLocally.ps1 +++ b/startServerLocally.ps1 @@ -1,23 +1,54 @@ -Write-Host "Trying to start server locally" -if ($Args[0] -eq "-r") { - Write-Host "Rebuilding application" - $build = $true -} else { - Write-Host "No rebuild flag (-r) given. Starting directly..." - $build = $false +#if ($Args[0] -eq "-r") { +# Write-Host "Rebuilding application" +# $build = $true +#} else { +# Write-Host "No rebuild flag (-r) given. Starting directly..." +# $build = $false +#} + +param ( + [string]$port = 1218, + [string]$path = "Server/build/libs/Server.jar", + [switch]$r = $false, + [switch]$h = $false +) + +if ($h) { + Write-Host "Script to start the server on the local machine."; + Write-Host " Flags: -h (help), -r (rebuild from source using Gradle),"; + Write-Host " -path [somePath] (start jarfile at non-standard location)"; + Write-Host " -port [somePortNumber] (start server at the given port)"; + exit; } -if ($build) { +Write-Host "Starting server locally" + +if ($r) { + Write-Host "Rebuild flag (-r) given. Rebuilding from source..."; try { - .\gradlew Server:jar + .\gradlew Server:jar; } catch { - Write-Host "Gradle doesn't seem to be installed." + Write-Host "There was a problem with the gradle build. Trying to start server anyways..."; } } +# Check for the server directory + +if (-not(Test-Path $path)) { + Write-Host "The jarfile that was requested doesn't seem to exist. Terminating..."; + exit; +} + try { - java -jar Server/build/libs/Server.jar -c .\configs\marvelheros.character.json -m.\configs\matchconfig_1.game.json -s .\configs\asgard.scenario.json -v + Write-Host "Starting server at location $($path) on port $($port)" + java -jar Server/build/libs/Server.jar ` + -c .\configs\marvelheros.character.json ` + -m.\configs\matchconfig_1.game.json ` + -s .\configs\asgard.scenario.json ` + -v ` + -p $port } catch { Write-Host "Couldn't execute. Is Java installed?" -} \ No newline at end of file +} + diff --git a/updateSubmodule.bat b/updateSubmodule.bat index 5085b15..613f0f8 100644 --- a/updateSubmodule.bat +++ b/updateSubmodule.bat @@ -1,4 +1,5 @@ @echo off +echo WARN: This file is DEPRECATED. Please use the powershell script (updateSubmodule.ps1) instead! git submodule update --init cd .\Gamelib git fetch diff --git a/updateSubmodule.ps1 b/updateSubmodule.ps1 index 004c776..79d1100 100644 --- a/updateSubmodule.ps1 +++ b/updateSubmodule.ps1 @@ -1,6 +1,29 @@ -git submodule update --init -cd .\Gamelib -git fetch -git checkout gamelib -git pull -cd .. +param ( + [switch]$md = $false +) + +Write-Host "Checking for submodule path..." +if (-not(Test-Path Gamelib)) { + Write-Host "Path Gamelib doesn't exist."; + if (-not($md)) { + Write-Host "Exiting."; + Write-Host "If you want to automatically create the subdirectory,"; + Write-Host "please pass the flag -md"; + exit; + } + New-Item -Path Gamelib -Type Directory; +} + +Write-Host "Updating submodule..." +try { + git submodule update --init; + Set-Location Gamelib; + git fetch; + git status; + git checkout gamelib; + git pull; + Set-Location ..; + Write-Host "Update done."; +} catch { + Write-Host "There's been an error. Is Git installed?"; +}