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…
Author: mfnalex
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,…
Three Common Maven Questions
People just getting started with maven always ask me the same 3 questions, so here’s a a short FAQ! How to change the output directory / file name? Changing the file name and output directory of your .jar file simply requires some changes in the maven-jar-plugin. If you don’t have it inside your pom.xml yet,…
Don’t jump off bridges, or: Why you shouldn’t use Exceptions to control code flow
Exceptions are a wonderful thing. They can let your code recover from unexpected situations in a nice and clean way, if you use them properly. That does not mean that you should always rely on them though. For example, imagine this: Most highways have guardrails in the middle to avoid cars going into oncoming traffic….
Manually installing .jar files to your local Maven repository
Sometimes you have a certain .jar file that you need as dependency, but the author of that .jar was too lazy to properly upload it to a public repository. That’s bad, but not a problem. There are two ways to solve this, but only one proper way. The proper way: install the dependency The proper…