Lesson 11 of 13 · 16m
Playing Nice: Services, softdepend, and Vault
Load-order contracts, ServicesManager and Vault-style interfaces, and shade-and-relocate discipline for libraries.
Your plugin will not live alone. The average Paper server runs thirty of you, and the professional move is exposing what you do for other plugins — and consuming what they expose — without hard-requiring jars your users may not have.
Loading order as API
plugin.yml carries three ordering keys. depend: [Vault] refuses to enable unless Vault is present — a hard contract for plugins that cannot function without it. softdepend: [Vault] means "load after it if installed" — the right default for optional integrations. loadbefore is the inverse for things that must exist earlier. Ordering matters because onEnable is when you look other plugins up: a plugin that enables after you is not a Plugin instance yet while your onEnable runs.
Guard optional integrations:
Plugin vault = getServer().getPluginManager().getPlugin("Vault");
if (vault != null && vault.isEnabled()) {
RegisteredServiceProvider<Economy> rsp =
getServer().getServicesManager().getRegistration(Economy.class);
if (rsp != null) this.economy = rsp.getProvider();
}Check isEnabled(), not just non-null — a jar on disk can be disabled by the time you look.
The ServicesManager pattern
Bukkit's own integration mechanism is ServicesManager. Publish with getServer().getServicesManager().register(YourApi.class, impl, plugin, ServicePriority.Normal); consume with .load(YourApi.class). The consumer never sees your classes — only the interface you both compile against.
Vault is the canonical example worth knowing by name: a single API surface (net.milkbowl.vault, pulled through JitPack as com.github.MilkBowl:VaultAPI) that fronts every economy, permission, and chat plugin written in the last decade. When your kit plugin needs to charge 500 coins, you write economy.withdrawPlayer(player, 500) and whatever the server actually runs — EssentialsX, a custom econ, a homebrew ledger — satisfies the interface. EconomyResponse.transactionSuccess() tells you whether the charge landed.
LuckPerms exposes a real API too (net.luckperms:api on its own Maven repo): LuckPermsProvider.get() returns the provider after a Vault-style lookup, and its Node model is what real permission checks resolve to when hasPermission is too coarse.
Shading and relocating
When the dependency is a library rather than a plugin, you ship it inside your jar — "shading" — through the Shadow Gradle plugin (com.gradleup.shadow):
tasks.shadowJar {
relocate("com.zaxxer.hikari", "org.sudosecurity.sudotools.libs.hikari")
minimize()
}Two rules keep you out of other plugins' stack traces:
compileOnlyeverything the server already provides — the API, Adventure, Guava.relocateeverything you shade. Unrelocated shaded classes collide with every other plugin that shaded a different version of the same library, and the failure is aNoSuchMethodErrorin someone else's jar that nobody traces back to you.
libraries: in plugin.yml is the third path — Maven coordinates Paper downloads at startup:
libraries:
- com.zaxxer:HikariCP:5.1.0
- org.xerial:sqlite-jdbc:3.46.1.3Smaller jar, shared downloads, no relocation debt; the cost is a network fetch on first boot, so it fits libraries on Maven Central and fails for private artifacts behind auth. Air-gapped or firewalled servers also can't fetch — shade for those audiences, libraries: for everyone else.
One integration trap worth naming: compileOnly against the highest Vault-API version you tolerate, then guard the lookup. getPlugin("Vault") returning non-null doesn't mean the Economy service is registered — Vault ships the interfaces; the economy plugin registers the provider.
Field notes
- Expose your own API as an interface other plugins can compile against without depending on your internals; register it through
ServicesManagerinonEnable. - An integration that throws when the optional plugin is absent is worse than no integration — null-check, degrade, log once.
PluginEnableEventexists if you truly need "after X enables," butsoftdependcovers almost every case.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
Bukkit, Spigot, Paper, Folia: What You're Actually Running
There is a fifteen-year fork tree underneath every Minecraft server, and most admins copy a jar without knowing what's in it. Here's the whole chain, with the code — including the config key most DAB guides get wrong.
A Minecraft Mod Is a Program. In 2026, Attackers Started Acting Like It.
A Minecraft mod is a Java program that runs with your account's full permissions, and nothing in the game checks what it does.
Minecraft 26.3 Turned the Whitelist On. Your Server Probably Didn't Notice.
A fresh Minecraft 26.3 server now ships with white-list=true, so new servers are closed to strangers from the first start. Existing servers that upgraded kept their old value, which for most of them means still open.
Your Minecraft Server Isn't Slow, It's Misconfigured
Can't keep up! is not a hardware message. It's the server telling you a tick took longer than 50ms, and almost every cause is a default nobody changed. Here's what actually moves MSPT, with the flags that are now wrong and the setting that isn't where every guide says it is.