建立啟動腳本

備註

這些指示僅適用於想要在自己的主機上架設 Minecraft 伺服器的人。大部分 Minecraft 伺服器主機商都會幫你建立啟動腳本。

撰寫啟動腳本

首先開啟文字編輯器(像是 Atom、Sublime Text、記事本等),然後為伺服器撰寫(或貼上)啟動腳本,以下為適用於各主流作業系統(Windows、macOS、Linux)的啟動腳本範例。請注意你主機的記憶體限制。

備註

以下的範例是通用的。對於使用 Sponge(核心模組)的 Forge 伺服器,請將 forge-1.12.2-XYZ-universal.jar 替換為伺服器目錄中的 Forge jar 檔案名稱。如果是 SpongeVanilla 伺服器,請替換成 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

執行啟動腳本

為了你的方便,請確保在專門為伺服器建立的資料夾中執行你的啟動腳本。很不幸的,就算你沒這樣做,Spongie 也沒辦法吸乾你的眼淚。

你可以透過點兩下你的啟動腳本來執行它。如果你使用 Console 或終端機,切換到腳本存放的目錄並執行它。請注意,你必須同意 Mojang 的 EULA(最終用戶授權協定)才能啟動伺服器。

備註

Sponge 停用預設的 Minecraft 伺服器 GUI 主控台 ,因為它非常佔用處理器資源。

警告

如果你在 Mac 上啟動伺服器時遇到權限錯誤,試試這個指令:

  • 開啟終端機。

  • 在終端機內輸入 chmod a+x,然後在行尾多打一個空格。

  • 將你的啟動腳本拖移至終端機內。

  • 按 Enter 鍵。