User description

The author selected the Tech Education Fund to receive a donation as part of the Write for DOnations program. Introduction Minecraft is a popular sandbox game. Originally released in 2009, it allows players to build, explore, craft, and survive in a block 3D generated world. It was the second most popular video game in late 2019 This tutorial will show how to create a Minecraft server that you and your friend can use. Specifically, you will install the necessary software packages to run Minecraft, configure the server to run, and then deploy the game. Alternately there is DigitalOcean’s One Click Minecraft: Java Edition Server. This tutorial uses Java Minecraft. If you purchased your version of Minecraft through the Microsoft App Store, you will be unable to connect to this server. Most Minecraft versions purchased on gaming consoles, such as the PlayStation 4 or Xbox One, are also compatible with the Microsoft version. These consoles are not able to connect to this tutorial's server. The Java version of Minecraft can be downloaded here. Prerequisites To follow this guide, you will need: - A server running Ubuntu 20.04 with sudo privileges and SSH enabled. To initialize your server, follow this guide. Minecraft can be resource-intensive. Keep this in mind when you select your server size. DigitalOcean may require more resources. You can always resize Droplets to add more CPUs or RAM. - Minecraft Java Edition on a local Mac, Windows or Linux. Step 1 - Installing the Necessary Software Packages and Configure the Firewall Once you have your server up and running, it's time to install Java. Java is required to run Minecraft. Update the package index for the APT package manager: sudo apt upgrade Next, install OpenJDK 16 of Java, specifically, the headless JRE. This is a minimal Java version that does not support GUI applications. This makes it ideal to run Java applications on a server. sudo apt install openjdk-16-jre-headless You also need to use a software called screen to create detachable server sessions. screen allows the creation of a terminal session and its detachment, while still allowing the process to run. This is important, as if the session were to close and you tried to restart your server, it would kill it and cause your server to stop. Install screen now: sudo apt installation screen Now that you have the packages installed we need to enable the firewall to allow traffic to come in to our Minecraft server. You allowed traffic only from SSH in the initial server setup. Now you must allow traffic to come in via port 25565, which is the default port Minecraft uses to allow connections. The following command will add the firewall rule. sudo ufw allow 25565 Now that you have Java installed and your firewall properly configured, you will download the Minecraft server from the Minecraft website. Step 2 - Downloading the Latest Version of Minecraft Now you need to download the current version of the Minecraft server. You can do this by navigating to Minecraft's Website and copying the link that says Download minecraft_server.X.X.X.jar, where the X's are the latest version of the server. To download the server, you can use wget or the copied link. wget https://launcher.mojang.com/v1/objects/bb2b6b1aefcd70dfd1892149ac3a215f6c636b07/server.jar If you intend to upgrade your Minecraft server, or if you want to run different versions of Minecraft, rename the downloaded server.jar to minecraft_server_1.15.2.jar, matching the highlighted version numbers to whatever version you just downloaded: mv server.jar minecraft_server_1.15.2.jar You can find older versions archived at mcversions.net if you wish to download Minecraft. But this tutorial will focus on the current latest release. Now that you have your download let's start configuring your Minecraft server. Step 3 - Configuring and Running the Minecraft Server Now that you have the Minecraft jar downloaded, you are ready to run it. First, start a screen session by running the screen command: Screen Once you have read the banner that has appeared, press the SPACE bar. This will open a terminal session, just as usual. This session is now detachable, which means that you'll be able to start a command here and leave it running. Now you can perform your initial configuration. If the next command throws errors, don't panic. Minecraft's installation is designed so that users have to agree to the company licensing agreement. You will do this next. 1. java -Xms1024M -Xmx1024M -jar minecraft_server_1.15.2.jar nogui Before examining this command's output, let's take a closer look at all these command-line arguments, which are tuning your server: - Xms1024M This will allow the server to be started with either 1024MB or 1GB RAM. You can raise this limit if you want your server to start with more RAM. MINECRAFT SERVERS Both M for megabytes and G for gigabytes are supported options. For example, Xms2G would start the server with two gigabytes worth of RAM. - Xmx1024M: This tells the server that it can only use 1024M of RAM. You can raise this limit if you want your server to run at a larger size, allow for more players, or if you feel that your server is running slowly. - jar This flag specifies which server file to run. - nogui - This tells the server not to launch a GUI since this is a server, and you don't have a graphical user interface. The first time you run this command, which normally starts your server, it will instead generate the following error: These errors were generated by the server failing to find the two required files for execution: the EULA, End User License Agreement, found in eula.txt. and the configuration.properties. Fortunately, since the server was unable to find these files, it created them in your current working directory. First, open eula.txt using nano or your favorite text editor. nano eula.txt This file contains a link to the Minecraft EULA. Copy the URL: Open the URL in your browser and read the agreement. Next, return to your text editor. Find the last line of eula.txt. This will change eula=false into eula=true. Save the file and close it. Now that you have accepted the EULA it is time for you to configure the server according to your specifications. In your current working directory, you will also find the newly created server.properties file. This file contains all of the configuration options for your Minecraft server. You can find a complete list on the Official Minecraft Wiki of all server property information. This file can be modified with your preferred settings, before you start your server. This tutorial will cover the fundamental properties: nano server.properties Your file will look something like this: Let's take a closer look at some of the most important properties in this list: - difficulty (default easy) - This sets the difficulty of the game, such as how much damage is dealt and how the elements affect your player. There are four choices: easy, normal and hard. - Gamemode (default survival) – This determines the game mode. There are three options: survival, creative, adventure, and spectator. - level-name (default universe) - This is the name of the server that will be displayed in the client. Characters such a apostrophe will need to be escaped using a backslash. - motd (default A Minecraft Server) - The message that is displayed in the server list of the Minecraft client. - pvp (default true) - Enables Player versus Player combat. If true, players will have the ability to damage and engage in combat. After you've set the options you want, save the file. Now that you have set the EULA to true as well as your settings, you are ready to start your server. Let's continue the same way as last time and start our server with 1024M of RAM. Only now, let's also grant Minecraft the ability to use up to 4G of RAM if it needs it. This number can be adjusted to meet your server's limitations or user's needs. 1. java -Xms1024M -Xmx4G -jar minecraft_server_1.15.2.jar nogui Give the initialization a moment. Soon your new Minecraft server will start producing an output similar to this: After the server is up, you will see this output: You have been dropped into the server administrator panel. Your server is now up and running. Now type help. Help This output will be available: From this terminal you can execute administrator commands and control your Minecraft server. Let's now use screen to continue the operation of your server even after you log off. Next, you can connect to Minecraft and start a new Minecraft server.MINECRAFT SERVERS Step 4 - Keep the server running Now that you have your server up, you want it to remain running even after you disconnect from your SSH session. Since you used screen earlier, you can detach from this session by pressing Ctrl + A + D. Now you're back in your original shell. To see all of your screen sessions, run this command: screen –list You'll receive an output with the session ID, which you will need to resume that session. Pass the -r flag on the screen command to resume your session. Then enter your session ID. screen -r 266553 You can log out of your server by detaching from the session using Ctrl +A + D, and then log out. Step 5 - Connecting to the Minecraft Server from the Minecraft Client Now that your server has been set up, let's connect it using the Minecraft client. Now you can start playing! Start Minecraft Java Edition. Select Multiplayer from the menu. Next, add a server to connect. Click on the Add Server button. The Edit Server Info screen will open. Give your server a name and enter the IP address of the server. This is the IP address that you used for SSH connection. Once you've entered your server name or IP address, you'll return to the Multiplayer screen. Here your server will be listed. From now on, your server will always appear in this list. Select it and click Join Server. You are now ready to play! You now have a Minecraft server running on Ubuntu 20.04 for you and all of your friends to play on! Enjoy exploring, crafting, and surviving within a primitive 3D world. Beware of griefers.