Many people who are using the maven-shade-plugin commonly set <createDependencyReducedPom> to false for reasons beyond my grasp. This is generally a bad idea, as it can lead to problems if you’re writing a library, and has absolutely no advantages. Here’s a rule of thumbs: If your project shades dependencies, it should create a dependency-reduced-pom.xml. The…
Maven Multi-Module setup for supporting different NMS versions
Hi there! Today I’m going to explain how to setup a multi-module project using maven to support different NMS versions. Important notes about this tutorial: Every step will have detailled screenshots using IntelliJ. I explicitly chose not to include everything as copy/pastable source code, but normal screenshots (you can click on them to show them…
How to read or block Spigot’s console output
Spigot uses Log4j to log console output, hence making it easy to listen to incoming console messages, or to block certain console messages from appearing. Prequisities You need to have Log4J on your classpath. We simply add the dependency to our pom.xml using the provided scope, as Spigot already contains those classes on runtime: Create…
Why IntelliJ complains about your pom.xml file
Sometimes, people suggest you to change something in your pom.xml, and then IntelliJ starts to complain: That is totally normal. You simply have to click the “maven reload button” in IntelliJ. Maven will then continue to download the required dependency/plugin, if it’s available. After a few seconds, everything should be fine. You can find the…
How to make maven automatically put your plugin’s .jar into your test server’s plugins folder
If you’re using maven for your Spigot plugins (which you should do), it’s easy to make maven automatically save your plugin’s .jar in your plugins folder. There’s two ways of doing this: 1. The lazy way (not recommended) If you only work alone on one computer, you can just directly declare the output location in…
Use Consumers when spawning custom entities
When you want to spawn a custom entity, e.g. with a custom name or certain items equipped, you must use the method World#spawn(Location, Class<T extends Entity>, Consumer<T>) unless you give a shit about compatibility with other plugins. I’ll explain why. The shitty way Usually, you can easily spawn entities like this: That is fine, as…
Java’s init blocks
Java allows you to use the so called “init blocks”. You can declare static and instance init blocks. The static init blocks will run exactly once, when the ClassLoader loads the class that declares it, and the instance init blocks run everytime you construct a new object, after the actual constructor ran. The general order…
Bukkit vs. Spigot-API vs. CraftBukkit vs. Spigot
Some people are confused about what the difference between Bukkit, Spigot-API, CraftBukkit and Spigot is, so I’ll try to explain. Bukkit is the basic API Bukkit contains all the usual interfaces and enums, like org.bukkit.entity.Player or org.bukkit.Material. For most plugins, this is all you need. It does not contain any implementations, meaning: you cannot “run”…
Switching from Spigot mappings to Mojang mappings
If you are switching from Spigot’s mappings (with class names like EntityZombie, WorldServer, PacketPlayOutSpawnEntity…) to Mojang mappings, you will notice that many of the classes you were using can’t be found anymore, since they now have different names. You will have to change all your references to those classes to their new names. Setup Mojang…
Creating custom heads in Spigot 1.18.1+
Spigot 1.18.1 added the new PlayerProfiles class, which finally allows us to use custom heads without needing any reflection! You can obtain them as normal items, or actually place them down into the world. I’ll show you how both works: Creating a new PlayerProfile First, we gotta create a new PlayerProfile object. To do so,…