Lambdas and Method references can be used to make your code way shorter, and (sometimes) more readable by getting rid of anonymous classes. What are Anonymous Classes? Anonymous classes are like local classes without a name. Imagine you have the following code: We hereby declare and instantiate a class implementing java.lang.Runnable that just prints some…
NMS: Use Mojang mappings for your Spigot plugins with Maven
If you need to access NMS classes from inside your Spigot plugin, it is a very good idea to use the so called Mojang mappings. Disclaimer: This post is obviously written for 1.18.2. If you use another version, you of course have to replace every occurance of “1.18.2” with the version you actually use. What…
Give your variables descriptive names, FFS!
Most people who get started with Spigot development somehow think it’s a good idea to make everything as short as possible (at least in terms of naming variables). This is considered bad practice for a good reason. What’s the problem? Let’s imagine this is your code: In this example, it is obvious in line 4…
Avoiding the arrow anti-pattern
When you read this, chances are high that someone saw your code and decided that you did something that is considered horribly bad: using the arrow anti-pattern. What the arrow anti-pattern is Look at the following code: It looks like a huge arrow (>) symbol. It’s ugly, unreadable and hard to maintain. Now, let’s say…
Using NMS classes with Maven
Many people are confused on how to use NMS classes when they’re new to writing Bukkit/Spigot plugins because their IDE doesn’t find those classes. Don’t worry. What is NMS? NMS refers to net.minecraft.server. This package contains all the classes that Mojang wrote for the vanilla Minecraft Server. You can use them to change the server’s…
Persistent Data Container: the better alternative to NBT Tags
or: Why you should NEVER use NBT tags again! Spigot 1.14.1 added the biggest improvement that (in my opinion) ever made it into the Bukkit API: The Persistent Data Container (PDC). It can be used to store custom data on Entities, TileEntities, and ItemStacks. Using a bit of math, it can also be used to…
Static Methods and Fields: When to use them and when to avoid them
Many people are going crazy whenever they see the static keywoard inside some source code. That’s ridiculous, because it alleges the people who developed Java were totally stupid. It is true that the static keyword gets abused by many people, but there’s a difference between static abuse and proper use of the keywoard. What does…
Data classes using Records or Lombok
Data classes are your way to go when you want to store information, but they have been very tedious to create, but you can easily avoid that!
How to create your first Minecraft plugin using the Spigot API and Maven
Learn how to create your first Minecraft for Bukkit/Spigot!
Obfuscate plugins using allatori
Maven can easily run allatori to obfuscate your .jar files when packaging them. If you haven’t bought allatori, you can also use their demo version available on their website. It’s also helpful to read their documentation. Simply create a new folder in your project’s base directory, called allatori, and move the allatori.jar and allatori-annotations.jar from…