API and events
Add softdepend: [mcHUD] to your plugin.yml. Call the API from the main thread.
McHudAPI api = McHudAPI.get(); // or Bukkit.getServicesManager().load(McHudAPI.class)
if (api != null) {
api.setValue(player, "quest_title", "Slay the Warden"); // {value:quest_title}
api.setGlobalValue("event_name", "Summer Cup");
api.toast(player, "<gold>Achievement unlocked", 80); // ticks
api.feed(player, "<green>+5 coins", 160);
api.showTemporaryWidget(player, "boss-warning", 100); // a widget with temporary: true
api.setTheme(player, "neon");
}| Method | What it does |
|---|---|
setValue(player, key, value) | Custom value for a player; null removes it. |
setGlobalValue(key, value), getValue(player, key) | Value for everyone; read a value. |
toast(player, text, ticks) | Show the toast widget. |
feed(player, text, ticks) | Add a feed line. |
showTemporaryWidget(player, id, ticks) | Show a widget marked temporary: true. |
setWidgetHidden(player, id, hidden) | The same switch as the player menu. |
setTheme(player, id) | Choose a theme (empty = server default). Returns false if unknown, not allowed or cancelled. |
getTheme(player), getThemes() | Current theme, all theme ids. |
pause(player, ticks) | Stop drawing for a while (cutscenes, other plugins' action bars). |
setEnabled(player, enabled) | The player's own HUD switch. |
Events#
HudPublishEvent: after a publish or rollback;getChangedThemes().HudThemeChangeEvent(cancellable): before a player's theme choice changes;getFrom(),getTo(),setTo().HudToastEvent(cancellable): before a toast or feed line is queued; the text can be changed;isFeed().