Using It In A Mod

Using It In A Mod

The magicutils.consumer-* plugins wire MagicUtils into your own module. Instead of declaring dependencies, shadow config, and run tasks by hand, you apply one plugin per platform module and describe what you need in magicutilsConsumer { }.

Apply The Plugin

Each platform module applies the matching consumer plugin. It brings in java-library, the shadow plugin, and the MagicUtils target/repository conventions:

The plugin version is declared once in pluginManagement (see Overview), so the module just applies it by id:

kotlin
plugins {    id("magicutils.consumer-bukkit")}magicutilsConsumer {    // Defaults to the `magicutils_version` gradle property, else this project's    // version. Set it explicitly to pin a MagicUtils release.    magicutilsVersion.set("1.22.0")    // Modules to pull in. api(...) exposes them to dependents; implementation(...)    // keeps them internal.    implementation("config", "commands", "lang")}

The consumer plugin per platform:

  • magicutils.consumer-bukkit
  • magicutils.consumer-fabric
  • magicutils.consumer-velocity
  • magicutils.consumer-bungee
  • magicutils.consumer-neoforge

Embedded vs Shared

embedMagicUtils (default true) controls whether MagicUtils is shaded into your artifact or expected as a separate install on the server:

kotlin
magicutilsConsumer {    // false: depend on a shared MagicUtils bundle installed on the server    // (magicutils-bukkit-bundle / magicutils-fabric-bundle), don't shade it in.    embedMagicUtils.set(false)}

You can also set it from the command line or gradle.properties with -Pmagicutils_embed=false. See Installation for the embedded vs shared trade-off.

Selecting Modules

Declare the MagicUtils modules your code needs. The plugin resolves them to the right coordinates for the active target:

kotlin
magicutilsConsumer {    // Exposed to anything that depends on this module.    api("config")    // Internal to this module only.    implementation("commands", "lang", "http-client")    // Extra third-party libraries to bundle alongside MagicUtils.    bundledLibraries("com.squareup.okhttp3:okhttp:4.12.0")}

Multi-Target In A Consumer

Because the consumer applies magicutils.target, your own module is also target-aware. Build or run it against a specific target with -Ptarget:

bash
./gradlew build -Ptarget=mc262

This is what lets one mod source tree ship against several Minecraft versions, which is the point of building on build-logic.

Optional Dev Server

Opt into a run task with devServer { }. Conventions cover the common case, so devServer() with no body is enough to get a Paper/Folia/Fabric/Velocity runner:

kotlin
magicutilsConsumer {    implementation("commands")    devServer {        // All optional — these are the defaults.        port.set(25565)        onlineMode.set(false)        folia.set(true)        motd.set("{pluginName} {platform} dev")        // Pull test-time dependencies from Modrinth into the dev server.        modrinth("placeholderapi") { }    }}

That registers the platform's run task (runPaper, runFolia, runFabric, runVelocity), covered in Dev Server & Smoke.