-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_test_server.ps1
More file actions
40 lines (34 loc) · 1.4 KB
/
setup_test_server.ps1
File metadata and controls
40 lines (34 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Configuration
$PAPER_VERSION = "1.21.10"
$SERVER_DIR = "test-server"
$JAR_NAME = "paper-$PAPER_VERSION.jar"
$PLUGIN_JAR = "target/oneclear-1.0-SNAPSHOT.jar"
# Create directories
if (!(Test-Path $SERVER_DIR)) {
New-Item -ItemType Directory -Path $SERVER_DIR
}
if (!(Test-Path "$SERVER_DIR/plugins")) {
New-Item -ItemType Directory -Path "$SERVER_DIR/plugins"
}
# Download Paper
if (!(Test-Path "$SERVER_DIR/$JAR_NAME")) {
Write-Host "Downloading Paper $PAPER_VERSION..."
$Builds = Invoke-RestMethod -Uri "https://api.papermc.io/v2/projects/paper/versions/$PAPER_VERSION"
$LatestBuild = $Builds.builds[-1]
$DownloadUrl = "https://api.papermc.io/v2/projects/paper/versions/$PAPER_VERSION/builds/$LatestBuild/downloads/paper-$PAPER_VERSION-$LatestBuild.jar"
Invoke-WebRequest -Uri $DownloadUrl -OutFile "$SERVER_DIR/$JAR_NAME"
}
# Set EULA to true
Set-Content -Path "$SERVER_DIR/eula.txt" -Value "eula=true"
# Copy Plugin
if (Test-Path $PLUGIN_JAR) {
Copy-Item -Path $PLUGIN_JAR -Destination "$SERVER_DIR/plugins/Oneclear.jar" -Force
Write-Host "Plugin copied to test server."
} else {
Write-Error "Plugin JAR not found! Run 'mvn package' first."
}
# Create start script
$StartScript = "java -Xmx2G -jar $JAR_NAME nogui"
Set-Content -Path "$SERVER_DIR/start.ps1" -Value $StartScript
Write-Host "Test server setup complete in /$SERVER_DIR"
Write-Host "To start: cd $SERVER_DIR; ./start.ps1"