跳转至

服务器

服务器是Mindustry的重要组成部分,它们提供了与其他人一起玩游戏的能力。主要有两种类型的服务器:专用服务器和本地LAN服务器。

专用服务器

专用服务器是独立的、无头版本的游戏,专注于为人们提供多人游戏的方式。它们通常作为单独的程序在计算机上运行,而不是在游戏内运行,并通过终端操作。这些服务器通常比本地LAN服务器更强大,因为它们有更多资源可用于支持两三个以上的玩家,并且可以全天候运行。它们也更加多功能和强大,因为它们有许多命令为管理员提供更多控制权,并且可以轻松地根据管理员的需求进行修改。

您可以使用"游戏"菜单下的"加入游戏"按钮连接到一个服务器。与本地LAN服务器不同,您必须输入主机的IP地址和端口。同样与本地LAN服务器不同,一旦您添加了服务器,它将在您打开服务器列表时自动显示,并且游戏将自动检查服务器的状态。

要建立专用服务器,强烈推荐使用专用的Linux或Windows机器。

  1. 如果您尚未安装Java,请安装它。
  2. itch.ioGithub发布页下载所需的服务器版本。文件名应为server.jarserver-release.jar,尽管如果您使用的是Windows,它可能只显示为serverserver-release
  3. 将服务器文件移动到您想要的文件夹中。建议将其放在桌面上的新目录中。
  4. 打开一个新的终端窗口(如果您使用的是Windows,则为CMD)。使用"cd"命令导航到您放置服务器文件的目录,例如cd Desktop然后cd Server。运行java -jar [server].jar,将[server]替换为您的服务器文件名。
  5. 您的服务器应该启动。输入help获取所有控制台命令的列表。如果您收到类似于"无法访问文件server.jar"的消息,您可能在错误的目录中。
  6. 使用命令host <mapname> [mode]开始托管地图。
  7. 如果您使用Windows运行服务器,请使用您喜欢的搜索引擎查找如何向Windows防火墙添加规则,因为它大多数时候会阻止必要的端口。确保允许端口6567 TCP和UDP
  8. 要关闭服务器,可以关闭终端窗口或在终端窗口上按Ctrl+C。

除非您已经启用了端口转发,否则只有您本地网络内的客户端才能连接到您的专用服务器。如果您想让您的服务器全球可用,请阅读下文。

什么是IP以及如何找出我的IP是什么?

简单来说,IP地址是一个标识您在互联网上的计算机的数字。如果您知道别人的IP地址,您可以连接到他们的Mindustry服务器。有两种类型:公共地址和本地地址。

  • 对于本地IP,例如当您想与与您在同一网络上的朋友一起玩时,每个设备都有自己的显示方式。您可以谷歌搜索如何为您的设备找到它,例如"在Mac上找到本地ip"。
  • 对于公共IP,您可以直接谷歌搜索"我的ip是什么"。

在家中运行专用服务器

大多数情况下,您应该记住这一点:如果您在家中托管服务器,请勿将您的公共IP与公众共享,除非您了解这样做的影响!您的公共IP与您的家庭关联,如果它落入了错误的人手中,当被放入错误的人手中时,可能会使您的网络面临漏洞和危险。谨慎行事,做好研究,如果可能的话使用VPN或网络主机。

同样建议您为公共服务器使用域名或DNS服务来掩盖您的IP以便于使用,或者更好的是,使用云服务,例如Amazon AWS或来自Linode或DigitalOcean等托管提供商的专用服务器/VM,这样更安全。做好研究,确定哪个选项最适合您的需求。

  1. 找出您的路由器的品牌/型号。这通常在路由器底部或背面的贴纸上。
  2. 使用您喜欢的搜索引擎搜索"端口转发ASUS RT-ACRH17"并使用指南转发端口6567 TCP和UDP。这些指令对每个路由器都不同,所以请确保彻底阅读您的指南!
  3. 您可以使用You Get Signal等服务来检查您是否已正确进行端口转发。

本地LAN及Steam服务器

本地LAN或Steam服务器是内置于游戏中的服务器,可以使用游戏内菜单中的"主持多人游戏"按钮启动。它旨在简单直接,用于LAN网络(即您家庭WiFi网络)下的几个玩家之间的会话。它并不真正适合多个玩家,因为它会从您的设备中占用越来越多的资源;为此,您需要上面提到的专用服务器。它只能在游戏打开时运行,关闭游戏后立即终止。

您可以使用"游戏"菜单下的"加入游戏"按钮连接到一个服务器。与专用服务器不同,您的设备将自动找到主机设备,并且它通常会在您不必输入主机IP地址的情况下出现在服务器列表中。

专用服务器命令

  • help [command]: Display the command list, or get help for a specific command.
  • version: Displays server version info.
  • exit: Exit the server application.
  • stop: Stop hosting the server.
  • host [mapname] [mode]: Open the server. Will default to survival and a random map if not specified.
  • maps [all/custom/default]: Display available maps. Displays only custom maps by default.
  • reloadmaps: Reload all maps from disk.
  • status: Display server status.
  • mods: Display all loaded mods.
  • mod <name...>: Display information about a loaded plugin.
  • js <script...>: Run arbitrary Javascript.
  • say <message...>: Send a message to all players.
  • pause <on/off>: Pause or unpause the game.
  • rules [remove/add] [name] [value...]: List, remove or add global rules. These will apply regardless of map.
  • fillitems [team]: Fill the core with items.
  • playerlimit [off/somenumber]: Set the server player limit.
  • config [name] [value...]: Configure server settings.
  • subnet-ban [add/remove] [address]: Ban a subnet. This simply rejects all connections with IPs starting with some string.
  • whitelist [add/remove] [ID]: Add/remove players from the whitelist using their ID.
  • shuffle [none/all/custom/builtin]: Set map shuffling mode.
  • nextmap <mapname...>: Set the next map to be played after a game-over. Overrides shuffling.
  • kick <username...>: Kick a person by name.
  • ban <type-id/name/ip> <username/IP/ID...>: Ban a person.
  • bans: List all banned IPs and IDs.
  • unban <ip/ID>: Completely unban a person by IP or ID.
  • pardon <ID>: Pardons a votekicked player by ID and allows them to join again.
  • admin <add/remove> <username/ID...>: Make an online user admin
  • admins: List all admins.
  • players: List all players currently in game.
  • runwave: Trigger the next wave.
  • loadautosave: Loads the last auto-save.
  • load <slot>: Load a save from a slot.
  • save <slot>: Save game state to a slot.
  • saves: List all saves in the save directory.
  • gameover: Force a game over.
  • info <IP/UUID/name...>: Find player info(s). Can optionally check for all names or IPs a player has had.
  • search <name...>: Search players who have used part of a name.
  • gc: Trigger a garbage collection. Testing only.
  • yes: Run the last suggested incorrect command.

专用服务器配置选项

  • name: The server name as displayed on clients.
  • desc: The server description, displayed under the name. Max 100 characters.
  • port: The port to host on.
  • autoUpdate: Whether to auto-update and exit when a new bleeding-edge update arrives.
  • showConnectMessages: Whether to display connect/disconnect messages.
  • enableVotekick: Whether votekick is enabled.
  • startCommands: Commands run at startup. This should be a comma-separated list.
  • logging: Whether to log everything to files.
  • strict: Whether strict mode is on - corrects positions and prevents duplicate UUIDs.
  • antiSpam: Whether spammers are automatically kicked and rate-limited.
  • interactRateWindow: Block interaction rate limit window, in seconds.
  • interactRateLimit: Block interaction rate limit.
  • interactRateKick: How many times a player must interact inside the window to get kicked.
  • messageRateLimit: Message rate limit in seconds. 0 to disable.
  • messageSpamKick: How many times a player must send a message before the cooldown to get kicked. 0 to disable.
  • packetSpamLimit: Limit for packet count sent within 3sec that will lead to a blacklist + kick.
  • chatSpamLimit: Limit for chat packet count sent within 2sec that will lead to a blacklist + kick. Not the same as a rate limit.
  • socketInput: Allows a local application to control this server through a local TCP socket.
  • socketInputPort: The port for socket input.
  • socketInputAddress: The bind address for socket input.
  • allowCustomClients: Whether custom clients are allowed to connect.
  • whitelist: Whether the whitelist is used.
  • motd: The message displayed to people on connection.
  • autosave: Whether the periodically save the map when playing.
  • autosaveAmount: The maximum amount of autosaves. Older ones get replaced.
  • autosaveSpacing: Spacing between autosaves in seconds.
  • debug: Enable debug logging.
  • snapshotInterval: Client entity snapshot interval in ms.
  • autoPause: Whether the game should pause when nobody is online.
  • roundExtraTime: Time before loading a new map after the gameover, in seconds.
  • maxLogLength: The Maximum log file size, in bytes.
  • logCommands: Whether player commands should be logged.