制作启动脚本
写一个启动脚本
首先打开文本编辑器,比如 Atom、Sublime Text、或者记事本;然后写下(或者粘贴)用于你服务器的启动脚本。对于 Windows、macOS、以及 Linux,下文给出了范例,但还请谨记你的机器的内存限制。
备注
下面的例子是通用的,对于Forge服务器,将文中的 forge-1.12.2-XYZ-universal.jar 换成你使用的Forge版本。对于原版Sponge服务器,将 forge-1.12.2-XYZ-universal.jar 换成你使用的 SpongeVanilla.jar 文件的名字。
Windows
java -Xms1G -Xmx2G -jar forge-1.12.2-XYZ-universal.jar
pause
将你的 Windows 脚本保存为 launch.bat 。
警告
Launching your server in a Command Prompt or PowerShell environment can lead to the server hanging due to the
Quick Edit Mode of these shells. This mode freezes the process when you highlight something or click inside the
console window. During this time, messages captured in the log will state that the server skipped many seconds or
minutes worth of ticks. You can prevent this from occurring by not highlighting any text on the screen and not
clicking inside the window, or by disabling the Quick Edit Mode in the Properties dialogue.
macOS
#!/bin/bash
cd "$(dirname "$0")"
java -Xms1G -Xmx2G -jar forge-1.12.2-XYZ-universal.jar
将你的 Mac 启动脚本保存为 launch.command 。
Linux
#!/bin/sh
cd "$(dirname "$(readlink -fn "$0")")"
java -Xms1G -Xmx2G -jar forge-1.12.2-XYZ-universal.jar
将你的 Linux 启动脚本保存为launch.sh。