Documentation Index
Fetch the complete documentation index at: https://mintlify.com/toxicity188/BetterHud/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The HUD API allows you to create, manage, and render HUD elements for players. HUDs are persistent display elements that appear on a player’s screen and update dynamically.
Hud Interface
The Hud interface represents a HUD component in BetterHud.
Package
kr.toxicity.hud.api.hud.Hud
Extends
HudObject - Base interface for all displayable BetterHud elements
Methods
createRenderer
Creates a renderer for this HUD for a specific player.
@NotNull HudComponentSupplier<Hud> createRenderer(@NotNull HudPlayer player)
The target player for whom to create the HUD renderer
return
HudComponentSupplier<Hud>
A component supplier that provides the rendered HUD output for the player
Inherited from HudObject
getName
Gets the internal name/identifier of the HUD.
@NotNull String getName()
The unique identifier for this HUD
isDefault
Checks if this HUD is a default HUD.
True if this is a default HUD, false otherwise
tick
Gets the frame time/update interval for this HUD.
The tick interval for HUD updates
add
Adds this HUD to a player’s display.
default boolean add(@NotNull HudPlayer player)
The player to add this HUD to
True if the HUD was successfully added, false if it was already present
remove
Removes this HUD from a player’s display.
default boolean remove(@NotNull HudPlayer player)
The player to remove this HUD from
True if the HUD was successfully removed, false if it wasn’t present
Usage Examples
Getting a HUD
import kr.toxicity.hud.api.BetterHud;
import kr.toxicity.hud.api.hud.Hud;
// Get HUD manager
var hudManager = BetterHud.inst().getHudManager();
// Get a specific HUD by name
Hud myHud = hudManager.getHud("my_hud");
Adding a HUD to a Player
import kr.toxicity.hud.api.player.HudPlayer;
import kr.toxicity.hud.api.hud.Hud;
import kr.toxicity.hud.api.BetterHud;
import org.bukkit.entity.Player;
public void showHudToPlayer(Player bukkitPlayer, String hudName) {
// Get the HUD player wrapper
HudPlayer hudPlayer = BetterHud.inst().getBootstrap().player(bukkitPlayer.getUniqueId());
if (hudPlayer == null) return;
// Get the HUD
Hud hud = BetterHud.inst().getHudManager().getHud(hudName);
if (hud == null) return;
// Add the HUD to the player
boolean added = hud.add(hudPlayer);
if (added) {
bukkitPlayer.sendMessage("HUD added!");
} else {
bukkitPlayer.sendMessage("HUD already active!");
}
}
Removing a HUD from a Player
public void removeHudFromPlayer(Player bukkitPlayer, String hudName) {
HudPlayer hudPlayer = BetterHud.inst().getBootstrap().player(bukkitPlayer.getUniqueId());
if (hudPlayer == null) return;
Hud hud = BetterHud.inst().getHudManager().getHud(hudName);
if (hud == null) return;
// Remove the HUD from the player
boolean removed = hud.remove(hudPlayer);
if (removed) {
bukkitPlayer.sendMessage("HUD removed!");
}
}
Getting All Active HUDs for a Player
import java.util.Set;
public void listPlayerHuds(Player bukkitPlayer) {
HudPlayer hudPlayer = BetterHud.inst().getBootstrap().player(bukkitPlayer.getUniqueId());
if (hudPlayer == null) return;
// Get all active HUDs
Set<Hud> activeHuds = hudPlayer.getHuds();
bukkitPlayer.sendMessage("Active HUDs: " + activeHuds.size());
for (Hud hud : activeHuds) {
bukkitPlayer.sendMessage("- " + hud.getName());
}
}
Toggling HUD Updates
public void toggleHudUpdates(Player bukkitPlayer) {
HudPlayer hudPlayer = BetterHud.inst().getBootstrap().player(bukkitPlayer.getUniqueId());
if (hudPlayer == null) return;
// Toggle HUD updates on/off
boolean currentState = hudPlayer.isHudEnabled();
hudPlayer.setHudEnabled(!currentState);
bukkitPlayer.sendMessage("HUD updates: " + (currentState ? "disabled" : "enabled"));
}
See Also
- HudObject interface:
kr.toxicity.hud.api.configuration.HudObject
- HudPlayer interface:
kr.toxicity.hud.api.player.HudPlayer
- HudComponentSupplier:
kr.toxicity.hud.api.configuration.HudComponentSupplier