How to import any jar, library or API into your Minecraft plugin. Works for premium plugins, open source plugins, libraries, any repositories etc.
Even if the author of the plugin doesn’t provide an API, I will show you a hack to import the plugin jar as a system path dependency.
In this episode, we’re going to cover:
- Amazing diagram — You’ll see my diagram carefully crafted after hours of hard work…
- “libraries” in plugin.yml — How to import any library using Spigot’s 1.16+ feature in plugin.yml from Maven Central (i.e. Jsoup library).
- Importing by “provided” scope — How to import plugins that give away a Maven/Gradle repository (i.e. Vault, WorldEdit, Essentials).
- Importing by “compile” scope and repackaging (deep) — How to copy a library’s source code into your plugin if it can’t be loaded into plugins/ folder and repackage it to avoid conflicts if multiple plugins use the same library (i.e. EffectsLib, NBT-API)
- Importing by “systemPath” scope — Dealing with stubborn plugins (i.e. our own one Boss) who don’t provide a repository AND are not a library, so you need to hook into the jar directly. Hacky but cool.
Source Codes:
Links mentioned:
- EffectsLib — A cool library to add animated particle effects into Minecraft.
- EffectsLib example — Where I got the particle effect shown in the video intro from.
- Jsoup — The HTML parser we used in the video to read websites.
- Boss™ — The custom monsters plugin I use to spawn Giants.
- VaultAPI — The Vault API page with Maven importing instructions and usage.
- Using “depend” and “softdepend” in plugin.yml – NOT mentioned in the video but important in case you need your plugin to load before, or force it to load after yours.
- Maven Central — A big repository you can use in plugin.yml under “libraries”.
Note that you need to make the server have a copy of its source code, as well as import the source code into your IntelliJ/Eclipse so you can use it. Watch the video for full explainer.
Important: Using “depend” and “softdepend”
I forgot to cover this in the video above.
In case you are getting warning log messages “this plugin is not using depend or softdepend” in the console when calling another plugin’s API, or you need to force the other plugin to load before yours (or after), Bukkit has a solution for you.
Simply write “depend” or “softdepend” keys to plugin.yml with a list of plugins you depend on. The “depend” will not load your plugin if any of the mentioned plugins are missing, whereas softdepend will load it regardless. Both will make your plugin load after these plugins.
See this link for the official Paper documentation on this feature.
Example:
depend: [Vault, WorldEdit]
softdepend: [Boss, ChatControlRed]
Learn To Make Minecraft Plugins
Creating Minecraft plugins can be confusing, with most YouTube tutorials being painfully outdated, disorganized and offering no live support.
If you want to learn from the best and create truly customized plugins, see Project Orion. This is a full training tried and tested by 2,000+ people showing you step-by-step how to make plugins (minigames, custom mobs, antipiracy, dungeons, claims etc.) and much more!
You’ll get 2x/weekly 1:1 calls to review your code and get your questions answered, plus a 1,900+ community on Discord and our private portal, covered by 30-day guarantee. It’s just so much better experience than any blog post or video since I can pour my time and heart into it and teach you 100X faster than any free YouTube tutorial can. Click here to learn more!