Initialize Infstar Paper-based server core

This commit is contained in:
Coldsmiles
2026-09-13 18:08:00 +08:00
commit 5c27681d1d
22 changed files with 1502 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
param(
[Parameter(Mandatory = $true)]
[ValidateScript({ Test-Path -LiteralPath $_ -PathType Leaf })]
[string] $JarPath,
[int] $Port = 25565
)
$projectRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
$runDirectory = Join-Path $projectRoot "run"
$targetJar = Join-Path $runDirectory "infstar.jar"
New-Item -ItemType Directory -Path $runDirectory -Force | Out-Null
Copy-Item -LiteralPath (Resolve-Path $JarPath).Path -Destination $targetJar -Force
@"
# Infstar 本地测试服务器配置
server-port=$Port
motd=Infstar Local Test Server
online-mode=false
enable-command-block=true
spawn-protection=0
view-distance=8
simulation-distance=6
enable-rcon=false
"@ | Set-Content -LiteralPath (Join-Path $runDirectory "server.properties") -Encoding utf8
"eula=true" | Set-Content -LiteralPath (Join-Path $runDirectory "eula.txt") -Encoding ascii
@"
这是 Infstar 的本地测试服务器目录,不应提交到 Git 仓库。
启动方式:
..\scripts\start-test-server.ps1
该目录包含世界、日志、配置和构建产物,已通过 .gitignore 排除。
"@ | Set-Content -LiteralPath (Join-Path $runDirectory "README.txt") -Encoding utf8
Write-Output "测试服务器已准备完成:$runDirectory"
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -euo pipefail
if [[ $# -lt 1 || $# -gt 2 ]]; then
echo "用法:$0 <服务端 JAR 路径> [端口]" >&2
exit 2
fi
project_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
run_directory="$project_root/run"
jar_path="$(realpath "$1")"
port="${2:-25565}"
mkdir -p "$run_directory"
cp -f "$jar_path" "$run_directory/infstar.jar"
cat > "$run_directory/server.properties" <<EOF
# Infstar 本地测试服务器配置
server-port=$port
motd=Infstar Local Test Server
online-mode=false
enable-command-block=true
spawn-protection=0
view-distance=8
simulation-distance=6
enable-rcon=false
EOF
printf '%s\n' 'eula=true' > "$run_directory/eula.txt"
echo "测试服务器已准备完成:$run_directory"
+28
View File
@@ -0,0 +1,28 @@
param(
[int] $MemoryMinGb = 2,
[int] $MemoryMaxGb = 4
)
$projectRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
$runDirectory = Join-Path $projectRoot "run"
$serverJar = Join-Path $runDirectory "infstar.jar"
if (-not (Test-Path -LiteralPath $serverJar -PathType Leaf)) {
throw "未找到 $serverJar。请先运行 prepare-test-server.ps1。"
}
$java = Get-Command java -ErrorAction SilentlyContinue
if ($null -eq $java) {
throw "未找到 Java。Infstar 26.2 需要 Java 25。"
}
Push-Location $runDirectory
try {
& $java.Source "-Xms${MemoryMinGb}G" "-Xmx${MemoryMaxGb}G" "-jar" $serverJar "--nogui"
if ($LASTEXITCODE -ne 0) {
throw "测试服务器退出,代码:$LASTEXITCODE"
}
}
finally {
Pop-Location
}
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -euo pipefail
project_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
run_directory="$project_root/run"
server_jar="$run_directory/infstar.jar"
java_command="${JAVA_HOME:+$JAVA_HOME/bin/}java"
memory_min_gb="${INFSTAR_MEMORY_MIN_GB:-2}"
memory_max_gb="${INFSTAR_MEMORY_MAX_GB:-4}"
if [[ ! -f "$server_jar" ]]; then
echo "未找到 $server_jar,请先运行 prepare-test-server.sh。" >&2
exit 1
fi
if ! command -v "$java_command" >/dev/null 2>&1; then
echo "未找到 Java。Infstar 26.2 需要 Java 25。" >&2
exit 1
fi
cd "$run_directory"
exec "$java_command" \
"-Xms${memory_min_gb}G" \
"-Xmx${memory_max_gb}G" \
-jar "$server_jar" \
--nogui
+15
View File
@@ -0,0 +1,15 @@
param(
[Parameter(Mandatory = $true)]
[ValidatePattern('^[0-9a-fA-F]{40}$')]
[string] $PaperCommit
)
$propertiesPath = Join-Path $PSScriptRoot "..\gradle.properties"
$properties = Get-Content -LiteralPath $propertiesPath -Raw
$updated = [regex]::Replace($properties, '(?m)^paperCommit=.*$', "paperCommit=$PaperCommit")
if ($updated -eq $properties) {
throw "paperCommit was not found in $propertiesPath"
}
Set-Content -LiteralPath $propertiesPath -Value $updated -NoNewline
Write-Output "已将 Paper 固定到 $PaperCommit。合并前请运行 applyAllPatches 和兼容性测试。"