Class InteractiveUI

java.lang.Object
fr.hytale.loader.api.ui.InteractiveUI

public class InteractiveUI extends Object
Simplified interactive UI wrapper that handles codec complexity automatically.

This class provides a simple API for creating interactive UIs with buttons, without needing to understand Hytale's codec system.

Example Usage:

InteractiveUI ui = new InteractiveUI("Pages/MyMenu.ui");

ui.onButtonClick("saveButton", (player, data) -> {
    player.sendMessage("Save button clicked!");
});

player.openInteractiveUI(ui);
Since:
1.0.5
Version:
1.0.6
Author:
HytaleLoader
  • Constructor Details

    • InteractiveUI

      public InteractiveUI(@Nonnull String uiFilePath, @Nonnull InteractiveUI.UILifetime lifetime)
      Creates a new interactive UI.
      Parameters:
      uiFilePath - Path to the UI file (e.g., "Pages/MyUI.ui")
      lifetime - UI lifetime behavior
    • InteractiveUI

      public InteractiveUI(@Nonnull String uiFilePath)
      Creates a new interactive UI with CAN_DISMISS lifetime.
      Parameters:
      uiFilePath - Path to the UI file
  • Method Details

    • onButtonClick

      public InteractiveUI onButtonClick(@Nonnull String buttonId, @Nonnull BiConsumer<Player, InteractiveUI.SimpleEventData> handler)
      Registers a button click handler.
      Parameters:
      buttonId - The button ID from the UI file (e.g., "saveButton" for "#SaveButton")
      handler - Consumer that receives (Player, eventData)
      Returns:
      This InteractiveUI for chaining
    • getUiFilePath

      public String getUiFilePath()
      Gets the UI file path.
      Returns:
      The UI file path
    • getLifetime

      public InteractiveUI.UILifetime getLifetime()
      Gets the UI lifetime.
      Returns:
      The UI lifetime
    • createNativePage

      public com.hypixel.hytale.server.core.entity.entities.player.pages.InteractiveCustomUIPage<InteractiveUI.SimpleEventData> createNativePage(@Nonnull com.hypixel.hytale.server.core.universe.PlayerRef playerRef, @Nonnull Player player)
      Creates the native interactive UI page.
      Parameters:
      playerRef - The player reference
      player - The player wrapper
      Returns:
      The native interactive UI page