From f8aef38907fbd2716df98699772e15780034d7f8 Mon Sep 17 00:00:00 2001 From: Griefed Date: Sun, 11 Aug 2024 18:46:58 +0200 Subject: [PATCH] fix: Remove unnecessary int cast and check for expected version format to better handle custom versions like GraalVM --- .../resources/server_files/default_template.ps1 | 11 +++++++++-- .../resources/server_files/default_template.sh | 6 +++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/serverpackcreator-api/src/main/resources/de/griefed/resources/server_files/default_template.ps1 b/serverpackcreator-api/src/main/resources/de/griefed/resources/server_files/default_template.ps1 index 3aad1f117..8b09a0a5f 100644 --- a/serverpackcreator-api/src/main/resources/de/griefed/resources/server_files/default_template.ps1 +++ b/serverpackcreator-api/src/main/resources/de/griefed/resources/server_files/default_template.ps1 @@ -613,7 +613,14 @@ else else { GetJavaVersion - if ([int]$script:JavaVersion -ne [int]$RecommendedJavaVersion) + if ($script:JavaVersion -match '[0-9]+') + { + if ($script:JavaVersion -ne $RecommendedJavaVersion) + { + InstallJava + } + } + else { InstallJava } @@ -623,7 +630,7 @@ else { GetJavaVersion Write-Host "Detected $($Semantics[0]).$($Semantics[1]).$($Semantics[2]) - Java $($JavaVersion)" - if ([int]$script:JavaVersion -ne [int]$RecommendedJavaVersion) + if ($script:JavaVersion -ne $RecommendedJavaVersion) { $script:Java = "java" InstallJava diff --git a/serverpackcreator-api/src/main/resources/de/griefed/resources/server_files/default_template.sh b/serverpackcreator-api/src/main/resources/de/griefed/resources/server_files/default_template.sh index 61d30416f..9a10760e5 100644 --- a/serverpackcreator-api/src/main/resources/de/griefed/resources/server_files/default_template.sh +++ b/serverpackcreator-api/src/main/resources/de/griefed/resources/server_files/default_template.sh @@ -416,7 +416,11 @@ else installJava else getJavaVersion - if [[ "$JAVA_VERSION" != "$RECOMMENDED_JAVA_VERSION" ]];then + if [[ "$JAVA_VERSION" =~ [0-9]+ ]];then + if [[ "$JAVA_VERSION" != "$RECOMMENDED_JAVA_VERSION" ]];then + installJava + fi + else installJava fi fi