The story of building a Java version of Minecraft server with GCP (and also set a whitelist)

Introduction

This is a memo when I built the Java version of Minecraft server as it is on the ubuntu server I built last time. I will not write about Java tuning, so please check it separately ┏ (<:)

Since the memory size of "f1-micro" of AlwaysFree (free for a lifetime) is too small, I expanded it to "n1-standard-1" in advance.

1. Build a Java version of Minecraft server

1.1. Java installation

Ssh to the server and switch to the root user.

su

After logging in as the root user, use the mkdir command to create a directory to install the server. Once created, move it with the cd command.

mkdir /mcjava
cd /mcjava

I thought I'd install a Minecraft server, but Java doesn't seem to be included, so let's install Java first.

apt install default-jre

When asked what the disk capacity is, type y (yes). This completes the Java installation.

1.2. Minecraft server installation

Next is the installation of the Minecraft server. Find out the download URL in advance. [MINECRAFT]https://www.minecraft.net/ja-jp/download/server/

javadl.png

Copy the link and download it.

wget https://launcher.mojang.com/v1/objects/bb2b6b1aefcd70dfd1892149ac3a215f6c636b07/server.jar

After downloading, start the server once. It should end with an error. root@mcapsv01_ _mcjava - Google Chrome 2020_03_24 1_06_51_2.png There should be a text file called eula.txt in the directory where you downloaded the server, so open it and edit the contents. It is a file that asks whether or not you agree with the EULA (End User License Agreement), so if you agree, replace eula = false with eula = true. root@mcapsv01_ _mcjava - Google Chrome 2020_03_24 1_06_27_2.png

eula=true

This completes the installation. I forgot. The Java version of the Minecraft server uses the tcp / 25565 port by default, so let's open the port in the firewall rule settings of GCP. port2.png

1.3. Start Minecraft Server

Move to the created directory and enter the command to start the server. You can create a dedicated user to start the server, but this time, start it as the root user. If the name of the downloaded file is "server.jar", start it with the following command.

cd /mcjava
java -Xmx1024M -Xms1024M -jar server.jar nogui

It will start up.

As an aside, the Java version of the Minecraft server starts on the Java virtual machine JVM, up to a preset amount of memory. So, just looking at the load on the ubuntu server doesn't tell you if Minecraft is working well. If you think that the number of people is increasing and you are running out of memory, try increasing the numbers of -Xmx and -Xms in the server startup command. Tuning is not discussed here.

1.4. Connecting to Minecraft server

Since it is the same as the integrated version, the explanation is omitted.

1.5. Stop Minecraft server

Since it is the same as the integrated version, the explanation is omitted.

1.6. Whitelist settings

I tried to set the whitelist together, but the specifications are a little different from the integrated version, so make a note of it. I was free to whitelist player names that didn't exist in the integrated version, but it seems that the Java version can't. Johniki Joestar2 could not be registered as below. root@mcapsv01_ _mcjava - Google Chrome 2020_03_24 1_24_05_2.png So I decided to edit whitelist.json directly. root@mcapsv01_ _mcjava - Google Chrome 2020_03_24 2_02_04_2.png There are more traps here as well. In the integrated whitelist, you can register whitelist.json if you know only the user's name, but in the Java version, uuid seems to be a required item. I intended to be an integrated version, so I was addicted to it for about 10 minutes. You can see the uuid by looking at the log on the server side, but there is no log of new users logging in from now on. However, Mojang provides a Mojang API to look up uuids.

[Mojang API] https://api.mojang.com/users/profiles/minecraft/JohnikiJoestar

{"id":"1f843a4609ae4715a3b062a522193fa0","name":"JohnikiJoestar"}

Now that you know Jonathan Joestar's uuid, whitelist it. The format of whitelist.json is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, so modify the id a little and edit the file.

[
  {
    "uuid": "1f843a46-09ae-4715-a3b0-62a522193fa0",
    "name": "JohnikiJoestar"
  }
]

If you edited the file directly, reload the whitelist.

whitelist reload

that's all. Right? It was easy, wasn't it? (I was addicted to it) start2.png

Recommended Posts

The story of building a Java version of Minecraft server with GCP (and also set a whitelist)
Set Java version 11 of Docker Minecraft Paper server
[Java version] The story of serialization
A story about hitting the League Of Legends API with JAVA
Build a container version of Minecraft server and use https-enabled Dynmap
The story of forgetting to close a file in Java and failing
The story of making a reverse proxy with ProxyServlet
The story of making dto, dao-like with java, sqlite
[Java] Cut out a part of the character string with Matcher and regular expression
Story of making a task management application with swing, java
The story of pushing a Docker container to GitHub Package Registry and Docker Hub with GitHub Actions
A story packed with the basics of Spring Boot (solved)
Graph the sensor information of Raspberry Pi in Java and check it with a web browser
Create a simple web server with the Java standard library com.sun.net.httpserver
The story of the first Rails app refactored with a self-made helper
A story of connecting to a CentOS 8 server with an old Ansible
A story that struggled with the introduction of Web Apple Pay
Is the version of Elasticsearch you are using compatible with Java 11?
A story that I wanted to write a process equivalent to a while statement with the Stream API of Java8
A collection of phrases that impresses the "different feeling" of Java and JavaScript
Make a daily build of the TOPPERS kernel with Gitlab and Docker
Let's express the result of analyzing Java bytecode with a class diagram
[Java] Create a jar file with both compressed and uncompressed with the jar command
How to find out the Java version of a compiled class file
<java> Split the address before and after the street address with a regular expression
(Note) Get a set of dependent library jars with the help of Gradle
The story of writing Java in Emacs
Easy JSON database experience with Docker ~ Try the latest version of Couchbase Server
Send a notification to slack with the free version of sentry (using lambda)
A story confirming the implementation of the SendGrid Java library when mail delivery fails
Validate the identity token of a user authenticated with AWS Cognito in Java
How to build a Jenkins server with a Docker container on CentOS 7 of VirtualBox and access the Jenkins server from a local PC
Check the version of the JDK installed and the version of the JDK enabled
The story of low-level string comparison in Java
The story of making ordinary Othello in Java
A story about the JDK in the Java 11 era
[Java] Set the time from the browser with jsoup
[Java] Access the signed URL of s3 (signed version 2)
The story of learning Java in the first programming
Measure the size of a folder in Java
[Java] The confusing part of String and StringBuilder
Set the time of LocalDateTime to a specific time
I compared the characteristics of Java and .NET
Manage the version of Ruby itself with rbenv
Calculate the similarity score of strings with JAVA
Try the free version of Progate [Java II]
Prepare a scraping environment with Docker and Java
Set up a CentOS virtual server with Vagrant
Try the free version of Progate [Java I]
[Android development] Get an image from the server in Java and set it in ImageView! !!
[Jackson] A story about converting the return value of BigDecimal type with a custom serializer.
A memo about the types of Java O/R mappers and how to select them
Write a test by implementing the story of Mr. Nabeats in the world with ruby
Learn the meaning of "passing the PATH" by building a Java development environment on Mac
How to set the retry limit of sidekiq and notify dead queues with slack
[Java] The problem that true was returned as a result of comparing Integer with ==
Summary of how to use the proxy set in IE when connecting with Java
A story that solved the problem that the Java (jdk) version was too high to use the h2o library in R and R Studio.