Installation
Compatibilityâ
| Item | Requirement |
|---|---|
| Server | Paper or Folia; Spigot support is experimental |
| Minecraft | 1.21.4 ~ 26.3. One artifact covers the whole range, no per-version dependencies |
| Java | The library is compiled for Java 21; at runtime use the Java version your server build requires |
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:
- Gradle Kotlin
- Gradle Groovy
- Maven
repositories {
maven("https://repo.momirealms.net/snapshots")
}
repositories {
maven { url = 'https://repo.momirealms.net/snapshots' }
}
<repositories>
<repository>
<id>momirealms</id>
<url>https://repo.momirealms.net/snapshots</url>
</repository>
</repositories>
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:
- Gradle Kotlin
- Gradle Groovy
- Maven
dependencies {
implementation("net.momirealms:sparrow-ui:VERSION")
}
tasks.shadowJar {
relocate("net.momirealms.sparrow.ui", "com.example.myplugin.libraries.sparrow.ui")
}
dependencies {
implementation 'net.momirealms:sparrow-ui:VERSION'
}
shadowJar {
relocate 'net.momirealms.sparrow.ui', 'com.example.myplugin.libraries.sparrow.ui'
}
<dependency>
<groupId>net.momirealms</groupId>
<artifactId>sparrow-ui</artifactId>
<version>VERSION</version>
</dependency>
<!-- inside <configuration> of maven-shade-plugin -->
<relocations>
<relocation>
<pattern>net.momirealms.sparrow.ui</pattern>
<shadedPattern>com.example.myplugin.libraries.sparrow.ui</shadedPattern>
</relocation>
</relocations>
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.
Until setUp has finished, do not touch any Sparrow UI class and do not build Items, Panes, or Windows.