Spigot is an open-source Java project that allows users to run their Minecraft server. It also allows users to add plugins to extend server features. Note that there are more than 100,000 Spigot servers today. This makes Spigot one of the most stable and diverse Minecraft servers available. In this article, you can review Introduction Spigot and Setup on Ubuntu 21.04 step by step.

Learn Spigot and Setup on Ubuntu Linux

What is Spigot?

Spigot is a modified Minecraft server based on CraftBukkit which provides additional performance optimizations, configuration options, and features, whilst still remaining compatible with all existing plugins and consistent with Vanilla Minecraft game mechanics.

Interestingly, there are more than 150 enhancements in Spigot alone, including BungeeCord support, the configuration of many internal server values such as crop growth rates, hunger, entity tracking, map seeds; enhanced watchdog and timings profiling to catch plugin issues; further configuration to heavy elements such as entity activation and hoppers; rewritten chunk loading, unloading and saving; and some useful API additions for developers.

Spigot allows you to customize the server, as Spigot optimizes server resources and is compatible with most CraftBukkit changes. Spigot is a modification of Minecraft server software, CraftBukkit.

Prerequisites to Install Spigot on Ubuntu 21.04

First, you need to install the Spigot prerequisites on the Ubuntu.

You need to create a Sudo user. Follow the steps below to create a Sudo user. You can create a Sudo user using the following command:

adduser example_user

By executing the above command, you will see the following output, in which you must set a password for yourself:

Adding user `example_user' ...
Adding new group `example_user' (1001) ...
Adding new user `example_user' (1001) with group `example_user' ...
Creating home directory `/home/example_user' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for example_user
Enter the new value, or press ENTER for the default
Full Name []: Example User
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y

Now you can easily add a new user to the Sudo group by running the following command:

usermod -aG sudo example_user

You can switch to the new user using the following command:

su - example_user

Finally, you should verify that you are the new user. Then, you can test Sudo access, which should return root:

whoami 

example_user 

sudo whoami 

[sudo] password for example_user: 

root

Now, you should update your Ubuntu server using the following commands:

sudo apt update
sudo apt upgrade

How to Setup Spigot on Ubuntu 21.04

To install the required utilities, you must enter the following command:

sudo apt-get install wget apt-transport-https gnupg

Import the AdoptOpenJDK GPG key using the command below:

wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -

Now run the following command to configure AdoptOpenJDK’s apt repository:

echo "deb https://adoptopenjdk.jfrog.io/adoptopenjdk/deb $(cat /etc/os-release | grep UBUNTU_CODENAME | cut -d = -f 2) main" | sudo tee /etc/apt/sources.list.d/adoptopenjdk.list

Enter the following command to refresh the package index:

sudo apt-get update

Run the following command to install AdoptOpenJDK:

sudo apt-get install adoptopenjdk-11-hotspot -y

How to Create a Swapfile

In this step, you must setup a swap file according to your needs:

sudo fallocate -l 1G /swapfile

Now it’s time to setup swap file permissions:

sudo chmod 600 /swapfile

You must allocate the swap space by executing the following command:

sudo mkswap /swapfile

In this step, you must turn on the swap:

sudo swapon /swapfile

You can now swap files permanently by modifying the fstab file:

sudo nano /etc/fstab

You must add the following command to the bottom of the file:

/swapfile none swap sw 0 0

How to Download and run BuildTools

It’s time to download and run BuildTools. Note that you are in the home directory of the user used to build Spigot:

cd ~

To build the latest build, first create a folder for Spigot. If the version you want to create is not Spigot 1.16.5, replace it in the following commands:

mkdir buildtools && cd buildtools
wget -O BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
java -jar BuildTools.jar --rev 1.16.5

Now you need to write down the file name of the spigot jar:

ls

Enter the following command to create a server directory:

cd ~ && mkdir server && cd server

Enter the following command to move the Spigot jar to your server directory. Enter the name of your file instead of spigotname.jar:

mv ~/buildtools/spigotname.jar ~/server/spigot.jar

Create a startup script for your server to start the server:

$ nano start.sh

The 4G parameters in -Xms4G -Xmx4G configure the Java heapspace for 4 GB of RAM. . Change its value to the amount of Spigot dedicated RAM. You do not have to allocate all available RAM to Spigot. You must paste the following in the start.sh:

#!/bin/sh
while true
do
java -Xms4G -Xmx4G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar spigot.jar nogui
echo "restarting in 10"
sleep 10
done

Now you should make start.sh executable:

chmod +x start.sh

In this step, you must start your server with the following command:

./start.sh

You must accept EULA, the first time it loads. You must type CTRL+C to exit the script from loop mode.

How to Start your Server

You can accept EULA with the following command:

nano eula.txt

Now you need to change eula= from false to true and then save the file and exit it. Finally, restart your server:

./start.sh

Install the screen with the following command:

sudo apt-get install screen -y

You can open an instance of the screen with the following command:

screen -S "spigot"

Use the following command to start the server script:

cd ~/spigot && ./start.sh

Finally, configure your server settings and install plugins.

If your spigot jar does not work, you will need to swap the larger file.

Conclusion

In this article, Spigot was introduced, and how to setup it was taught step by step. If you want to setup Spigot but do not know how to do it, you can easily do it with this tutorial.