Skip to the content.

Home

Developer API

Other plugins can drive NovaUI through dev.novaui.api.NovaUIAPI (static methods) and listen to dev.novaui.api.AnimationEndEvent.

Setup

  1. Add NovaUI to your plugin.yml:

    softdepend: [NovaUI]
    
  2. Compile against the NovaUI jar (it is not on a Maven repository). With Gradle:

    dependencies {
        compileOnly files('libs/NovaUI-1.0.0.jar')
    }
    

    Don’t shade NovaUI into your plugin.

  3. Check NovaUIAPI.isAvailable() before using it (false when NovaUI isn’t installed, is locked or isn’t running).

Page names are the page file names (pages/<name>.yml); element ids are the keys under elements:. Call every method on the main server thread. All methods are safe to call when the HUD isn’t running; they then do nothing or return false.

Example

import dev.novaui.api.NovaUIAPI;

if (NovaUIAPI.isAvailable()) {
    NovaUIAPI.open(player, "hud_stats");
    NovaUIAPI.setVariable(player, "kills", "12");                    // use {kills} in any text
    NovaUIAPI.setText(player, "scoreboard", "title", "<gold>Round 3");
    NovaUIAPI.message(player, "<gold>Boss incoming!", 5);             // the event-message bar
    NovaUIAPI.play(player, "anim_fade", () -> player.teleport(spawn)); // runs when the animation ends
    NovaUIAPI.openMenu(player, "profile");
}

NovaUIAPI

Method What it does
boolean isAvailable() true when NovaUI is installed, licensed and running
boolean open(Player, String page) opens a page for the player; false if there is no such page
void close(Player, String page) closes a page for the player
void closeAll(Player) closes every page for the player
boolean isOpen(Player, String page) is that page open for the player
Set<String> openPages(Player) the pages open for the player
List<String> pages() all page names
void setText(Player, String page, String elementId, String text) replaces the text of a text element (or the value of a progress element) for this player only. MiniMessage, & codes, {variables} and %placeholders% work. null puts the page’s own text back
void setVariable(Player, String name, String value) sets {name} for this player (null removes it). Used in texts, values, player names and conditions
void setVariable(Player, String name, String value, int ticks) sets {name} for a while (20 ticks = 1 second); it disappears by itself afterwards
String getVariable(Player, String name) the player’s value of {name}
boolean play(Player, String animation) plays an animation page in the middle of the player’s screen (on top of the HUD). Playing it again restarts it. False when there is no such animation
boolean play(Player, String animation, Runnable onEnd) like play; onEnd runs on the main thread when the animation ends for any reason (finished, stopped, restarted or the player left)
void stop(Player, String animation) stops an animation for the player (null = all of them)
boolean isPlaying(Player, String animation) is that animation playing for the player
void message(Player, String text, int seconds) shows a message in the event-message bar ({message} in a page, e.g. the shipped example_message page) for that many seconds
boolean openMenu(Player, String menu) opens menus/<name>.yml: a dialog screen for Java players, a form for Bedrock players. False if there is no such menu or the player lacks its permission
boolean isBedrock(Player) true for players joining from Bedrock through Geyser + Floodgate
boolean isShown(Player) true once the player’s client has the HUD pack and the HUD is on screen

AnimationEndEvent

Fired on the main thread when a NovaUI animation stops showing for a player.

@EventHandler
public void onAnimationEnd(dev.novaui.api.AnimationEndEvent e) {
    if (e.getAnimation().equals("anim_fade") && e.isCompleted()) {
        e.getPlayer().sendMessage("Welcome!");
    }
}