Installing a new Spigot server
We will start from scratch to set up this new server. If you wish to use a preexisting world, you will be able to do so after creating a new Spigot server. To start, let's create a new empty folder named Bukkit Server
. We will run the Spigot server from this newly created folder.
The main file that you will need to start a new server is spigot.jar
. A JAR file is an executable Java file. Minecraft, Spigot, and every plugin that we will create are all written in Java and therefore are run from a JAR
file. The Spigot team updates the spigot.jar
file as Mojang releases new versions of Minecraft. Typically, when connecting to a Minecraft server, you must be playing on the same version. In case you are unsure of your Minecraft version, it is displayed in the bottom-left corner of the Minecraft client. A client is the program that you use to play Minecraft, as shown in the following screenshot:
You can choose the version of Minecraft that you want to play by creating a new profile in the Minecraft launcher, as shown in the following screenshot:
For legal reasons, the Spigot team is not allowed to let you download spigot.jar
. However, it does provide you with tools and instructions so that you can build the JAR
file yourself. The Spigot team continues to improve this process by providing the latest instructions as well as a troubleshooting guide at https://www.spigotmc.org/threads/buildtools-updates-information.42865/. This chapter includes simplified instructions on how to obtain the needed JAR
file. However, in case you run into problems while building these jar
files, refer to the instructions provided on spigotmc.org.
You will need Git for Windows in order to run the build tools. You can download it from http://msysgit.github.io/. When installing Git for Windows, the default installation settings will be fine. You will also need to download the build tools JAR
file, which can be found at https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar. Create a new folder to place BuildTools.jar
in. Name this folder Spigot Build Tools
. Also create a new text file within the same folder. Name this text file update.txt
. Open the text
file and write the following line of code in it:
<java bin path>
should be replaced with the location of the Java installation. The java path depends on the version of Java that you have on your computer. Look for the Java
folder inside the Program Files
or Program Files (x86)
directory. The Program Files
directory can be found at the root of the main hard drive, which is typically C:\
. If you do not see the Java folder, then you will have to install Java. You can download it at https://java.com/download/.
Once you are in the Java
folder, you will see one or more java installation folders, such as jre7
or jre8
. Open the installation folder. In case you see more than one, open the one with the higher version number. Within the java installation folder, open the bin
directory. Here you should see java.exe
, though it may be displayed as simply java. Copy the path from the top of the explorer window; this is the java bin path, as shown in the following screenshot:
If you have Java 8, then the line of code in the update file will be similar to the following code:
Tip
On most PCs, you can reference the java variable in place of the java.exe path. Therefore the line of code in the update file will be as follows: java -jar BuildTools.jar
Save the file and then rename it from update.txt
to update.sh
. If you don't see the .txt
extension on the file, then you will have to adjust your folder options by performing the following steps:
- Open the View tab to the upper left
- Select Folder and search options
- Uncheck Hide extensions for known file types
- Click on OK
Now, you can rename update.txt
to update.sh
. Run update.sh
by double-clicking on it. This will execute the build tools, downloading all the code and applying changes until it is up to date. It will take several minutes to complete. Once it's complete, you will have spigot.jar
, craftbukkit.jar
, and bukkit.jar
. The two server jars, namely spigot and craftbukkit, will be found in the Spigot Build Tools
directory, where you placed BuildTools.jar
. The bukkit.jar file
is located in the Bukkit/target
directory in the same folder. Each file will have a version number appended to it, such as spigot-1.8.8.jar
and bukkit-1.8.8-R0.1-SNAPSHOT.jar
. Note the location of these files, as you will need them within this chapter as well as throughout the book.
Note
It is recommended to run update.sh once a week so that you have the latest version of Spigot.
Copy the spigot.jar
file and place it in the Bukkit Server
folder that was created by you at the beginning of this segment. For simplicity, we will remove the version number and rename the file spigot.jar
.
Now, we will create a batch file that we can double-click on every time we wish to start the server. In a new text document, type the following two lines:
1024
tells how much of the computer's RAM the server will be allowed to use. You can change this number if you want the server to use more or less RAM. spigot.jar
is the name of the spigot.jar
file. This must match the name of your file. We renamed the file to exclude the version number so that we will not need to edit this batch file every time we update the Spigot server to the latest version. java
indicates that we are using Java to run the server. In case the server does not start during the following step, you may need to replace java
with the full java path that you copied earlier. The rest of the code in the batch file should not concern you, and it should remain unchanged.
Save the text document as Start Server.bat
and ensure that it is in the same folder as that of spigot.jar
. Now, you will be able to run the server. Double-click on the batch file that you just created. It will open the command prompt and start creating server files. It will look like the following screenshot and should display the Minecraft server version that you are using:
If you do not see the Starting minecraft server message, then there may be something wrong with the batch file. If a window similar to what's shown in the previous screenshot does not appear, then make sure that the batch file is named Start Server.bat
and not Start Server.bat.txt
. When you first start the server, you will see a few warnings. Most of them shouldn't worry you as they are expected. However, you may see a message that explains that you need to agree to the EULA in order to run the server. If you look in the Bukkit Server
folder, you will now see a new file named eula.txt
. Open this file, set eula=true
, and save it to agree to the terms, which are outlined by Mojang at https://account.mojang.com/documents/minecraft_eula. Once you do so, you can start the server again. This time, you will see the server loading and generating a new world.