Skip to main content

Installation

Compatibility​

ItemRequirement
ServerPaper or Folia; Spigot support is experimental
Minecraft1.21.4 ~ 26.3. One artifact covers the whole range, no per-version dependencies
JavaThe library is compiled for Java 21; at runtime use the Java version your server build requires
Running on Spigot

Spigot support is still experimental. The examples in this wiki use Paper APIs such as Paper's DataComponentTypes and Adventure's Component; on Spigot, replace them with ItemMeta and the other APIs Spigot provides.

Adding the dependency​

First the repository:

repositories {
maven("https://repo.momirealms.net/snapshots")
}

Then the dependency. Relocate the whole net.momirealms.sparrow.ui package under your own package name. Replace VERSION below with the latest version listed in the README of the GitHub repository, and com.example.myplugin.libraries.sparrow.ui with a package unique to your plugin:

dependencies {
implementation("net.momirealms:sparrow-ui:VERSION")
}

tasks.shadowJar {
relocate("net.momirealms.sparrow.ui", "com.example.myplugin.libraries.sparrow.ui")
}
Relocation is not optional

Sparrow UI installs a reflection proxy into the server class loader, and the proxy's package follows the library's runtime package. Without relocation, any two plugins that bundle Sparrow UI collide on identical class names in the server class loader.

Initialization​

Call setUp once in onEnable and hand the library your plugin instance:

package com.example.myplugin;

import net.momirealms.sparrow.ui.SparrowUI;
import org.bukkit.plugin.java.JavaPlugin;

public final class MyPlugin extends JavaPlugin {

@Override
public void onEnable() {
SparrowUI.getInstance().setUp(this);
}
}

This installs the reflection proxies, creates the window and network managers, starts tracking online players, and binds the library's scheduler to your plugin. Sparrow UI does not infer its owning plugin; using its scheduler, windows, or Signal timers before setUp throws IllegalStateException.

Your plugin has nothing to do on disable. Sparrow UI listens for the plugin disable event itself: it shuts down the window and network managers and stops its scheduler.

Run setUp before touching any Sparrow UI class

Until setUp has finished, do not touch any Sparrow UI class and do not build Items, Panes, or Windows.

NextQuick startFrom an empty plugin to the first menu on screen