Skip to content

Commit 842490e

Browse files
committed
feat(start-file): Add verification to all PowerNukkitX start files
1 parent 21ae43e commit 842490e

File tree

4 files changed

+105
-8
lines changed

4 files changed

+105
-8
lines changed

start.bat

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
11
@echo off
22

3+
TITLE PowerNukkitX server software for Minecraft: Bedrock Edition
4+
5+
REM Check if Java is installed
6+
java -version >nul 2>&1
7+
IF %ERRORLEVEL% NEQ 0 (
8+
echo Java is not installed. Please install Java 21 or higher.
9+
echo You can refer to the installation instructions at https://docs-pnx.pages.dev/requirements
10+
pause
11+
exit 1
12+
)
13+
14+
REM Check if powernukkitx.jar exists
15+
IF NOT EXIST "powernukkitx.jar" (
16+
echo PowerNukkitX.jar not found
17+
echo You can download the file from https://github.com/PowerNukkitX/PowerNukkitX/releases
18+
pause
19+
exit 1
20+
)
21+
22+
REM Check if libs directory exists
23+
IF NOT EXIST "libs" (
24+
echo The libs directory was not found. Please ensure the directory is in the current directory.
25+
echo You can download the directory from https://github.com/PowerNukkitX/PowerNukkitX/releases
26+
pause
27+
exit 1
28+
)
29+
330
set JAVA_CMD="java"
431
set JAR_NAME="powernukkitx.jar"
532

@@ -13,4 +40,4 @@ set JAR_NAME="powernukkitx.jar"
1340
--add-opens java.base/java.io=ALL-UNNAMED ^
1441
--add-opens java.base/java.net=ALL-UNNAMED ^
1542
-cp %JAR_NAME%;./libs/* ^
16-
cn.nukkit.Nukkit
43+
cn.nukkit.Nukkit

start.cmd

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
11
@echo off
22

3+
TITLE PowerNukkitX server software for Minecraft: Bedrock Edition
4+
5+
REM Check if Java is installed
6+
java -version >nul 2>&1
7+
IF %ERRORLEVEL% NEQ 0 (
8+
echo Java is not installed. Please install Java 21 or higher.
9+
echo You can refer to the installation instructions at https://docs-pnx.pages.dev/requirements
10+
pause
11+
exit 1
12+
)
13+
14+
REM Check if powernukkitx.jar exists
15+
IF NOT EXIST "powernukkitx.jar" (
16+
echo PowerNukkitX.jar not found
17+
echo You can download the file from https://github.com/PowerNukkitX/PowerNukkitX/releases
18+
pause
19+
exit 1
20+
)
21+
22+
REM Check if libs directory exists
23+
IF NOT EXIST "libs" (
24+
echo The libs directory was not found
25+
echo You can download the directory from https://github.com/PowerNukkitX/PowerNukkitX/releases
26+
pause
27+
exit 1
28+
)
29+
330
set JAVA_CMD="java"
431
set JAR_NAME="powernukkitx.jar"
532

@@ -13,4 +40,4 @@ set JAR_NAME="powernukkitx.jar"
1340
--add-opens java.base/java.io=ALL-UNNAMED ^
1441
--add-opens java.base/java.net=ALL-UNNAMED ^
1542
-cp %JAR_NAME%;./libs/* ^
16-
cn.nukkit.Nukkit
43+
cn.nukkit.Nukkit

start.ps1

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
# Check if Java is installed
2+
if (-not (Get-Command java -ErrorAction SilentlyContinue)) {
3+
Write-Host "Java is not installed. Please install Java 21 or higher."
4+
Write-Host "You can refer to the installation instructions at https://docs-pnx.pages.dev/requirements"
5+
exit 1
6+
}
7+
8+
# Check if powernukkitx.jar exists
9+
if (-not (Test-Path -Path "powernukkitx.jar")) {
10+
Write-Host "PowerNukkitX.jar not found"
11+
Write-Host "You can download the file from https://github.com/PowerNukkitX/PowerNukkitX/releases"
12+
exit 1
13+
}
14+
15+
# Check if libs directory exists
16+
if (-not (Test-Path -Path "libs" -PathType Container)) {
17+
Write-Host "The libs directory was not found. Please ensure the directory is in the current directory."
18+
Write-Host "You can download the directory from https://github.com/PowerNukkitX/PowerNukkitX/releases"
19+
exit 1
20+
}
21+
122
$JAVA_CMD = "java"
223
$JAR_NAME = "powernukkitx.jar"
324

@@ -11,4 +32,4 @@ $JAR_NAME = "powernukkitx.jar"
1132
--add-opens java.base/java.io=ALL-UNNAMED `
1233
--add-opens java.base/java.net=ALL-UNNAMED `
1334
-cp "$JAR_NAME;./libs/*" `
14-
cn.nukkit.Nukkit
35+
cn.nukkit.Nukkit

start.sh

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
11
#!/bin/bash
22

3-
# Construct the full path to the Java executable
3+
echo "PowerNukkitX server software for Minecraft: Bedrock Edition"
4+
5+
# Check if Java is installed
6+
if ! java -version &> /dev/null
7+
then
8+
echo "Java is not installed. Please install Java 21 or higher."
9+
echo "You can refer to the installation instructions at https://docs-pnx.pages.dev/requirements"
10+
exit 1
11+
fi
12+
13+
# Check if powernukkitx.jar exists
14+
if [ ! -f "powernukkitx.jar" ]; then
15+
echo "PowerNukkitX.jar not found"
16+
echo "You can download the file from https://github.com/PowerNukkitX/PowerNukkitX/releases"
17+
exit 1
18+
fi
19+
20+
# Check if libs directory exists
21+
if [ ! -d "libs" ]; then
22+
echo "The libs directory was not found. Please ensure the directory is in the current directory."
23+
echo "You can download the directory from https://github.com/PowerNukkitX/PowerNukkitX/releases"
24+
exit 1
25+
fi
26+
427
JAVA_CMD="java"
528
JAR_NAME="powernukkitx.jar"
629

7-
# Execute the Java command
8-
"$JAVA_CMD" -Dfile.encoding=UTF-8 \
30+
$JAVA_CMD -Dfile.encoding=UTF-8 \
931
-Djansi.passthrough=true \
1032
-Dterminal.ansi=true \
1133
-XX:+UseZGC \
@@ -14,5 +36,5 @@ JAR_NAME="powernukkitx.jar"
1436
--add-opens java.base/java.lang=ALL-UNNAMED \
1537
--add-opens java.base/java.io=ALL-UNNAMED \
1638
--add-opens java.base/java.net=ALL-UNNAMED \
17-
-cp "$JAR_NAME:./libs/*" \
18-
cn.nukkit.Nukkit
39+
-cp $JAR_NAME:./libs/* \
40+
cn.nukkit.Nukkit

0 commit comments

Comments
 (0)