Skip to content

Dev Setup for Starters

ElitoGame edited this page Jun 9, 2024 · 13 revisions

Introcuction

This Tutorial has been created by ElitoGame and includes some personal preferences!

On This page, we will go over how to set up a complete Developing Environment from Start to Finish, including personal Server Setup, IDE Installing, Project Setup, Starting a Test Server and how to create your own Version of the plugin and help contributing to EzChestShop!

This Getting started page requires a bit of Java Knowledge, but since you are reading a tutorial about how to get started from a very basic level with this plugin, I'm sure you're interested in Java! If you have little to no experience yet, try these Tutorials by Coded Red for some Spigot plugin knowledge! If you're new to Java in general, I can recommend Sololearn, which is how I learned Java and many other languages!

1. Accounts and Software

GitHub

EzChestShop is hosted via GitHub, just like this Wiki, and to access the plugin and start developing for it, you will need to have an Account. Simply visit the GitHub Page and register a new one if you don't already have one.

Spigot

Spigot is where we publish our Plugin, you don't need to create an account, but it can be useful for Notifications or Questions. Spigot is a great source of information and if you're ever stuck on a coding problem with your Plugin, there is a good chance it has already been answered somewhere on the forum.

Intellij Community Edition

To get started with coding, a good IDE (Integrated Development Environment) is recommended. While Eclipse works too for many Java Developing projects, it is recommended to use Intellij as it offers way better support for Maven, a library management System we use. There is no need to download the Ultimate Edition, the Community Version works just fine.

GitHub Desktop (optional)

If you are uncomfortable with the Command line or have never used GitHub before, GitHub Desktop is a free program that allows you to manage your repositories, branches, and pull requests using a GUI.

What the hell is a repository and all that other nonsense?

  • Well, feel free to check out the Quick Start Guide from GitHub. If you want to try the Command line edition and are having troubles remembering the commands, here's some Cats for you!

Other

Later on we will also need to install the Spigot BuildTools and potentially Git, but that will be in a later section.

2. Creating your own Version of EzChestShop

In order to fork a project, you need to click on the Fork button, in the top right corner. If you press it, it will probably ask you for what purpose you want to create this fork. Choose for contributing to this project if you want to help developing EzChestShop!

image

Next up, you will want to clone EzChestShop to your local machine. Using GitHub Desktop, you will need to navigate to the Add button, located in the upper right area. It might be hidden by the right-most dropdown button. Next, choose Clone Repository.

GitHub Desktop add Repository

In the opened Menu, 1. choose the GitHub.com TAB. Next, (2.) select the repository you just forked e.g. YOURNAME/EzChestShop. If it is not showing up, try pressing the Refresh 🔄 Button. Then (3.) choose the Destination you want to clone this file to. Finally (4.) press Clone!

GitHub Desktop choose Cloning

Congratulations! You've just forked and downloaded a Project to your Computer!

3. Getting started with Intellij

Opening your Fork of EzChestShop

When you first open Intellij, you will be presented with the Homescreen. In there, choose Open and navigate to the Folder where you cloned EzChestShop to. Select the Project Folder and hit OK.

Open a Project in Intellij

Alternatively, if you are already in the Developing area, you can access the Open menu using File -> Open

File -> Open in Intellij

When first opening a new Project in Intellij, you might have to wait a few minutes, because the Software is indexing the project. You can see the progress bar in the bottom right. Meanwhile, look into downloading the Build tools or setting up your local Server.

Downloading Spigot Build Tools

In order to access all the Libararies used by plugins like EzChestShop it is Required to Download Build Tools. Additionally Build Tools are a nice way of looking up which Events and other classes exist in Spigot.

All the infos about Build Tools and how to get them, can be found in the Spigot Wiki! You can install Build Tools to any folder, all the important assets are going to be relocated to the ~/.m2 folder, but feel free to stay organized ;). For EzChestShop you will need these versions:

  • 1.16 R3 java -jar BuildTools.jar --rev 1.16.5
  • 1.17 R1 java -jar BuildTools.jar --rev 1.17.1
  • 1.18 R2 java -jar BuildTools.jar --rev 1.18.2
  • 1.19 R3 java -jar BuildTools.jar --rev 1.19.4
  • 1.20 R3 java -jar BuildTools.jar --rev 1.20.4 --remapped

You will need different Java version for the installs, so replace the java part of the account with the respective jdk java.exe file.

  • 1.14-1.16 -> Java 8-13
  • 1.17 -> Java 16
  • 1.18-1.19-> Java 17

Since January 2024, Build Tools also provides a GUI, so feel free to use their executable to install the versions mentioned above. You will still need to have the Java versions mentioned above installed and make sure to check the Remap option when installing!

Screenshot 2024-06-09 130629

Making your first changes

Let's start simple, by changing the Enable Message of the Plugin! Navigate to src > main > java > me > deadlight > ezchestShop > EzChestShop.java. This is the main file of the plugin, that starts all other processes. Most of them are called inside the method onEnable().

Now let's modify the Message, by adding your name after the .getVersion() method call using String concatination.

    @Override
    public void onEnable() {

        plugin = this;
        logConsole("&c[&eEzChestShop&c] &aEnabling EzChestShop - version " 
        + this.getDescription().getVersion());
        saveDefaultConfig();
        ...
    }

Once done, it should look similar to this:

    @Override
    public void onEnable() {

        plugin = this;
        logConsole("&c[&eEzChestShop&c] &aEnabling EzChestShop - version " 
        + this.getDescription().getVersion() + " ElitoGame");
        saveDefaultConfig();
        ...
    }

Exporting the plugin

You've just made a "super cool, awesome, amazing" change to the plugin! XD Now it's time to test it!

For that, we will be using Maven, a system that helps us manage libraries and exporting of the plugin.

Maven Exporting

In the top Right Corner of the Screen, you will find a Tab on the right bar called Maven. Expand the Tab and you will see EzChestShop and below Lifecycle. Expand the Lifecycle and click on package. If everything went right, the plugin should now be compiling in the Run Console down below! It should stop with the Message Process finished with exit code 0

If this does not work for you, you might be using an unsupported version of Maven, as there are issues with a dependency we use. To fix them, ensure you are using a version below 3.9. You can check via running mvn --version in the maven command panel in Intellij - see the following screenshot.

image

If you are using an unsupported version, type in the following command mvn wrapper:wrapper -Dmaven=3.8.8 - which downloads and creates a wrapper for you to build the project in an older version of maven. Grab a terminal e.g. powershell and run ./mvnw package in the root of the ECS project. This will be the pipeline you can use to build the project.

You can find the compiled version in the target folder, which should be located at the same level as your src folder, directly below it. Inside the target folder, you will find 3 versions: EzChestShop-1.x.x-shaded.jar, EzChestShop-1.x.x-original.jar and EzChestShop-1.x.x.jar. We are interested in the last of them, the others are simply created in the process of packaging.

4. Local Server

But where to test your own plugin? We will solve this problem by setting up your own Minecraft Server! (locally - so it's sadly just for you...)

Server .jar's

To create a server we'll have to download one. We can't use a vanilla server, as they can't run Plugins. So we will be using Spigot or Paper. Since Paper is more performant and offers additional features like detailed performance checks, we will be using Paper. But if you want, feel free to use Spigot.

Starting the Server

Now that you've chosen a .jar, move it into the directory where you want to keep your server files.

Command line

Depending on your System, this step will look differently, but you will need this Command, where you replace server.jar with the name of the file you just downloaded:

java -Xmx1024M -Xms1024M -jar server.jar
  • Windows: You can create a batch script like start.bat. Open it in a text Editor like Notepad++ or similar. Paste the Command, save and run it. (Alternatively, open the Command Prompt or Powershell - cmd or powershell in the Adress bar, and run the Command)

  • Linux: Create a start.sh shell script or use the terminal to run the Command.

  • MacOS: I don't know how to create Script files on Mac, so use the Terminal located under /Applications/Utilities/. Then navigate to your folder, in which you saved the server.jar file using the command cd (change directory), followed by the Path e.g. cd /Application/Minecraft.app/Contents/Server. Make sure you are in the right folder using the ls (list) command, which will print all files in the current directory to the console. Run the Command once you're in the same directory.

Eula

After you ran the command once, the console will ceate a few files and folders, but throw an error, that the eula.txt is set to false. You will need to localte the file in the server directory and set it to true (eula=true). Repeat the Command step from above and the Server should start up!

Congratiulations 🎉

Adding the Required Plugins

EzChestShop has currently 2 dependencies, which you can find on the Getting Started Wiki.

Copy the EzChestShop-1.x.x.jar from the target folder into your server folder in the plugins folder. And all the dependencies too.

Restart the server and you should be all set!

Checking for our changed code

Whenever you start the Server, the console will print a bunch of outputs that inform you of what's going on on the server. The plugins are enabled pretty late in this process, so you should see your modified line quite at the end.

Console modified plugin enable message

Further Reading

The Wiki is still a WIP, but there will be more content, like how to upload your contributions and more later on! Thanks for reading and I hope you learned something!