Skip to main content

Introduction

The BetterHud API provides a comprehensive interface for developers to interact with and extend BetterHud’s functionality. The API is designed to be multiplatform, supporting Bukkit, Fabric, and Velocity servers. Maven Central Version

API Architecture

BetterHud’s API is structured in two layers:

Standard API

The standard-api module (BetterHud-standard-api) contains platform-independent interfaces and functionality. This is the core API that all platforms share. Main Entry Points:
  • BetterHudAPI - The starting point for accessing the API
  • BetterHud - The main interface containing all functionality
Key Managers:
  • PlaceholderManager - Manage custom placeholders
  • PopupManager - Control popup displays
  • HudManager - Manage HUD elements
  • CompassManager - Handle compass markers and tracking
  • PlayerManager - Player-specific operations
  • DatabaseManager - Database interactions
  • ConfigManager - Configuration management
  • TriggerManager - Event trigger handling
  • ListenerManager - Custom event listeners
  • ShaderManager - Shader effects
  • TextManager - Text rendering and formatting

Platform-Specific APIs

Platform APIs extend the standard API with platform-specific functionality:
  • bukkit-api - Bukkit/Spigot/Paper specific features
  • fabric-api - Fabric server mod specific features
  • velocity-api - Velocity proxy specific features

Getting Started

To access the BetterHud API in your code:
import kr.toxicity.hud.api.BetterHud;
import kr.toxicity.hud.api.BetterHudAPI;

// Get the main BetterHud instance
BetterHud api = BetterHudAPI.inst();

// Alternative method (legacy support)
BetterHud api = BetterHud.getInstance();

Core Concepts

Namespacing

BetterHud uses Adventure’s Key system for namespacing:
String namespace = BetterHud.DEFAULT_NAMESPACE; // "betterhud"
Key defaultKey = api.getDefaultKey();

Manager Access

All functionality is accessed through specialized managers:
// Access different managers
var placeholderManager = api.getPlaceholderManager();
var popupManager = api.getPopupManager();
var hudManager = api.getHudManager();
var compassManager = api.getCompassManager();
var playerManager = api.getPlayerManager();

Reload Handling

BetterHud supports dynamic reloading with various flags:
import kr.toxicity.hud.api.plugin.ReloadState;
import kr.toxicity.hud.api.plugin.ReloadFlagType;

// Trigger a reload
ReloadState result = api.reload(ReloadFlagType.values());

// Check reload status
boolean isReloading = api.isOnReload();

// Add custom reload tasks
api.addReloadStartTask(() -> {
    // Execute when reload starts
});

api.addReloadEndTask(state -> {
    // Execute when reload ends
    // Access reload state information
});

Resource Loading

BetterHud provides utilities for loading plugin resources:
import java.io.File;

// Load assets to a directory
api.loadAssets("textures", new File("./target"));

// Load assets with custom handling
api.loadAssets("textures", (path, stream) -> {
    // Process each resource file
});

Dependencies

Adventure API

BetterHud uses Kyori Adventure for text components and cross-platform compatibility:
  • Adventure API version: 4.26.1
  • Platform version: 4.4.1
  • Examination version: 1.3.0

BetterCommand

Maven Central Version BetterHud uses the BetterCommand library for multi-platform command support. Include it in your dependencies when working with commands.

Example Projects

Official example implementations:

API Stability

The BetterHud API follows semantic versioning. Methods marked with @ApiStatus.Internal are for internal use only and should not be used by external plugins.

Next Steps

Installation

Learn how to add BetterHud API to your project

Build docs developers (and LLMs) love