Minecraft Server: Difference between revisions

updated flags and some other reordering/rewriting
Line 2: Line 2:
{{tip/unfree}}
{{tip/unfree}}


[https://minecraft.wiki/w/Server Minecraft Server] is a server for the blocky sandbox game [[Minecraft]]. Currently only servers for the [https://www.minecraft.net/en-us/article/java-or-bedrock-edition Java Edition] of the game are supported.
[https://minecraft.wiki/w/Server Minecraft Server] is a server for the sandbox game [[Minecraft]]. Currently, only servers for the [https://www.minecraft.net/en-us/article/java-or-bedrock-edition Java Edition] of Minecraft are supported.


== Setup ==
== Setup ==
Line 24: Line 24:
   declarative = true;
   declarative = true;
   whitelist = {
   whitelist = {
     # This is a mapping from Minecraft usernames to UUIDs. You can use https://mcuuid.net/ to get a Minecraft UUID for a username
     # This is a mapping of Minecraft usernames to to the players' UUIDs
     username1 = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
     username1 = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
     username2 = "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy";
     username2 = "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy";
Line 37: Line 37:
     allow-cheats = true;
     allow-cheats = true;
   };
   };
   jvmOpts = "-Xms2048M -Xmx4096M";
   jvmOpts = "-Xms2048M -Xmx2048M";
};
};
</nowiki>}}
</nowiki>}}
You might want to view the [https://minecraft.wiki/w/Server.properties#Keys list of all available server properties for the vanilla server].
You might want to view the [https://minecraft.wiki/w/Server.properties#Keys list of all available server properties for the vanilla server].


See [[#jvm-flags|See also]] for recommended flags for the <code>jvmOpts</code> option.
== Tips and tricks ==
== Tips and tricks ==
=== Use a different server version/package ===
To use a specific server version, or another Minecraft server—such as [https://papermc.io/ PaperMC]—change <code>services.minecraft-server.package</code> to a nix package that represents your desired server.
For example:
<code>services.minecraft-server.package = pkgs.minecraftServers.vanilla-1-12;</code>
or
<code>services.minecraft-server.package = pkgs.papermc;</code>


=== Accessing the Minecraft server console ===
=== Accessing the Minecraft server console ===


The Minecraft server console allows you to view server logs and issue [https://minecraft.wiki/w/Commands commands] to the server interactively. The Minecraft server console is <strong>not</strong> directly accessible on NixOS—unlike on imperative systems, where running the server through a shell command provides the interactive console to the current terminal session.
The Minecraft server console allows you to view server logs and issue [https://minecraft.wiki/w/Commands commands] to the server interactively. The Minecraft server console is <strong>not</strong> directly accessible on NixOS—unlike on non-declarative systems, where running the server through a shell command provides the interactive console to the current terminal.


==== Accessing logs ====
==== Accessing logs ====
Line 85: Line 74:
  };
  };
</nowiki>}}
</nowiki>}}
=== Use a different server ===
To use a specific server version, or another Minecraft server—such as [https://papermc.io/ PaperMC]—change <code>services.minecraft-server.package</code> to a nix package that represents your desired server.
For example:
<code>services.minecraft-server.package = pkgs.minecraftServers.vanilla-1-12;</code>
or
<code>services.minecraft-server.package = pkgs.papermc;</code>


=== Prefer IPv4 ===
=== Prefer IPv4 ===
Line 93: Line 94:


* [https://github.com/Infinidoge/nix-minecraft nix-minecraft], a [[flake]] based attempt to better support Minecraft related content for the Nix ecosystem. It can be used for more complex server setups, including mods and plugins.
* [https://github.com/Infinidoge/nix-minecraft nix-minecraft], a [[flake]] based attempt to better support Minecraft related content for the Nix ecosystem. It can be used for more complex server setups, including mods and plugins.
* [https://docs.papermc.io/paper/aikars-flags/ Aikar's flags] or the [https://github.com/Mukul1127/Minecraft-Java-Flags Minecraft performance flags benchmark] for setting additional JVM options in the <code>jvmOpts</code> option.
<span id="jvm-flags"></span>
 
* https://exa.y2k.diy/garden/jvm-args for setting additional JVM options in the <code>jvmOpts</code> option. Some server-related software —like the Velocity proxy—have their own recommended flags list.
* https://mcuuid.net to get a player's UUID from their current username or vice versa.
[[Category: Applications]]
[[Category: Applications]]
[[Category: Gaming]]
[[Category: Gaming]]