This blog is about the game Minecraft. In this blog I will go about the steps involved in setting up a spigot minecraft server on a Mac with plugins that allow you to connect to the server through Python3 programming language. It is not that difficult as you will see in this tutorial. 

First, we need to download the latest build tools from the spigot site. I will be doing this on the command line in terminal. Create a folder somewhere that will hold all of your files for the server. I created a folder on my Desktop called spigotServer. In terminal, cd to Desktop. Then type, mkdir spigotServer. Then cd to spigotServer.  Then enter mkdir build and press enter. Then cd into the build directory you just made. Next we will download the latest BuildTools.jar using curl.

In terminal type, curl -o BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar

and press enter. This will download the latest successful build of BuildTools.jar to your computer.

 

Now we will run the BuildTools.jar. In terminal, type the following commands pressing enter after each one;

export MAVEN_OPTS="-Xmx2G"

java -Xmx2G -jar BuildTools.jar --rev 1.16.1 (<- or whatever the newest version of Minecraft is)

This will start the program building the jars for you. The spigot server jar will be in the same directory you ran BuildTools in. For my build this was spigot-1.16.1.jar. 

Now, you need to get back to the spigotServer directory and create a new directory simply called server. Then copy the spigot-x.xx.x.jar file into the server directory. 

Next, we'll create a start.command file that will be used to run the server. 

Using vi or your favorite editor, create the file start.command and type in the following lines;

#!/bin/sh

cd "$(dirname"$0")"

java -Xms2G -Xmx2G -jar spigot-1.16.1.jar nogui

 

Save the file. 

Next, we have to make it runable by typing the commands;

chmod a+x start.command

The first time we run the server it will fail and give error message ;

You need to agree to the EULA in order to run the server. Go to the eula.txt file and change the line

eula=false to eula=true, save the file.

The run the server again, this will create all the necessary files and folders in the server folder.

Stop the server now by typing in stop in the terminal and pressing enter.

 

Now we need to get the raspberryJuice and SetSpawn plugins. 

Go to dev.bukkit.org/projects/raspberryjuice to download the latest version of this plugin. Click on the Download Latest File button. The latest version at time of this writing was 1.12.1

The go to dev.bukkit.org/projects/setspawn to download the latest version of this plugin. Click on the Download Latest File button. The latest version at time of this writing was 2.2.1

Copy those two jar files to the spigotServer/server/plugins directory. 

Then make sure you have the mcpi python module installed to your python by going to the terminal and typing in pip3 install mcpi and press enter. It doesn't matter where you are at in the file system when you type that command, it will put the mcpi module where it needs to go. 

 

Now, start your spigot server again. You will see in the console output that it loads RaspberryJuice and SetSpawn plugins. 

 

Now we can test the python functionality and make sure that is working. Start a separate terminal but don't close the one running the server.

I created a pythonScripts folder in my spigotServer folder. 

Then in the pythonScripts folder create a py file named MCPythonTest.py with the following contents;

# Connect to Minecraft

from mcpi.minecraft import Minecraft

mc = Minecraft.create()

mc.postToChat("Hello, python testing connection...!")

 

Save the file and then run it using python MCPythonTest.py

Look in the server console window and you should see the message. 

If you connect with your Minecraft client and are in the game, you will see the message in the chat window. 

You are now setup to program Minecraft with python on your very own private server. 

You can also connect a client from another computer on your local network. 

I connect to mine from a Windows 10 machine.

Enjoy!!!