A Minecraft Server Sent Me Source Diving

Good Morning from my Robotics Lab! This is Shadow_8472, and today, I am building a private Minecraft server for plugin testing. Let’s get started!

Minecraft Paper Server

Any sufficiently popular computer game will eventually attract someone with the ability and drive to modify it. Others will come along and make tools to lower the barrier of entry so even more people can customize their experiences. Barring legal action from parent companies or a drop in popularity, the cycle continues to the point someone with basic computer literacy can find the resources he needs to join the modding community as I did almost ten years ago after my friend introduced me to Minecraft Bukkit servers. Shortly afterwards, I had myself a Last Airbender inspired Minecraft server.

In the year I was gone from Minecraft, my mother and sister have been helping on the moderation team for DS9Fireblade on PhoenixCraft. DS9 has selected a number of plugins to manage the chaos that often accompanies publicly available servers, but it’s hard to master all the commands when you have to worry about not breaking stuff.

Server Building

Little has changed about the fundimentals of Minecraft server construction. A modded server provides a stable platform imitating the vanilla game while providing plugin or mod makers a space to hook into without interfering with other plugins.

DS9’s server is running Paper, a version of Spiggot from the Bukkit modded server family. Ideally, I would take the time to track down the exact version for 100% compatibility, but I was having trouble finding the download. I made the executive decision to just use the newest version of each piece of software and adjust things if needed.

I loaded the server onto ButtonMash even though it’s still technically on Photo Trunk duty until that project is done, idle as it is. I remembered a series of topics I covered a while ago on how Minecraft doesn’t do well with the default settings and that G1GC (Generation 1 Garbage Collection) makes things go more smoothly in terms of long-term problems. I wasn’t fond of doing all that research again, so I reviewed this sight [1] which I do not look forward to citing, but offers a a list of Java flags to use and what each one does.

Months of idling were not kind to Button’s RAM, as it was about maxed out with Xorg (graphical server), even when I closed everything. I rebooted. It defaulted to its internal Minecraft server drive I have slated for a future Linux install some day. Around ten minutes of digital technical taps to the BIOS and removing a bent thumb drive later, I got it back into Debian.

The server still refused to start. Java was up to date with the repositories at Java 11 but it wanted Java 16. I just so happen to have solved the exact same issue with a Minecraft client earlier week. I downloaded an appropriate version of GraalVM [2]. Since I don’t plan on this server going anywhere, I saved it within the server’s main directory and edited my serverstart command accordingly.

The server was a bit more cooperative after that. I signed the EULA and modified a comment about tacos supposedly being the best food (why is that even in there?). Once I confirmed the server was running I started adding plugins, starting with the modern bending plugin and following it up with tools from PhoenixCraft.

mv Goof

My workflow settled into a pattern of looking up a plugin from the list, going to the download page, copying the actual download link, then using wget to download it onto ButtonMash as I’m working over SSH. I wasn’t impressed when I had to rename each file as it came in, but I figured it wasn’t worth my time to immediately puzzle it out, but I made a Downloads directory to isolate incoming files so they didn’t get lost.

Things were going well until I found one that didn’t want to be downloaded via command line. I waited a few minutes, but it still said it was temporaily unavalible. I was able to download in Firefox though, so I saved it to GoldenOakLibry, my family’s network storage. Soon I was copying its containing directory over into plugins.

Oops.

The containing directory was gigabytes of information at the least. I at least knew my Unsteam games project was in there, but I also found an old backup from my laptop. The connections are all hard wire, but I didn’t feel like waiting an unknown amount of time for the half way point, so I canceled the command with CTRL+C to assess damages.

It had only really started: two visible files at the very least. They appeared to still be in their original spot, but I wanted to be sure. I looked up the mv command’s inner workings, but my search results were filled with helpful information for someone learning normal terminal operations, not an unusual situation like my own.

With few places left to turn, I went source code diving. The hardest part was finding the code, but dpkg -S is the tool for that job. I zeroed in on the mv source and found the exact file [3] on the Debian website, a file written in C. My mission at this point was to answer this basic question: does mv do anything to directory trees its moving between physical disks as it goes or does it copy everything and clean up at the end?

I found what appeared to be a loop structure at line 364 in main(), but it didn’t appear to be trying to traverse any sort of file system structure. Further study led me to line 173, in do_move() where it copies the file in question before flagging the whole thing for deletion on line 224. And with that, I had answered my own question: cleanup is done after everything is safely moved.

Takeaway

This post was entertaining to make. It was supposed to be a boring, but quick and easy job I didn’t need to research much for after a week of stalling for topics. It was also the first time I went looking into the Linux source code, and while it makes poor skimming material, it was insightful. Find In Page was my best friend.

Cleaning up in post makes sense though. Everything in Linux is a file, even directories that contain other files.

Final Question

Have you ever studied the laid out inner workings of anything?

Works Cited

[1] lechowski (I think… Author is unclear), <March 5 OR May 3> 2021. [Online]. Available: https://lechowski.info/gry/minecraft/modded-mc-and-memory-usage-history-crappy-graph [Accessed Sept. 12, 2021]

[2] GraalVM, 2018-2021. [Online]. Available: https://www.graalvm.org/ [Accessed Sept. 12, 2021]

[3] M. Parker, D. MacKenzie, and J. Meyering, “mv.c” 1986-2018. [Source code]. Available: https://sources.debian.org/src/coreutils/8.30-3/src/mv.c/ [Accessed Sept. 12, 2021]

Leave a Reply