Class HudManager

java.lang.Object
com.hypixel.hytale.server.core.entity.entities.player.hud.HudManager

public class HudManager extends Object
  • Constructor Details

    • HudManager

      public HudManager()
  • Method Details

    • getCustomHud

      @Nullable public CustomUIHud getCustomHud(@Nonnull String key)
      Returns:
      the custom HUD registered under the given key, or null if none
    • getCustomHuds

      @Nonnull public Map<String, CustomUIHud> getCustomHuds()
      Returns:
      an unmodifiable view of all registered custom HUDs, keyed by their identifier
    • getVisibleHudComponents

      @Nonnull public Set<HudComponent> getVisibleHudComponents()
    • setVisibleHudComponents

      public void setVisibleHudComponents(@Nonnull PlayerRef ref, HudComponent... hudComponents)
    • setVisibleHudComponents

      public void setVisibleHudComponents(@Nonnull PlayerRef ref, @Nonnull Set<HudComponent> hudComponents)
    • showHudComponents

      public void showHudComponents(@Nonnull PlayerRef ref, HudComponent... hudComponents)
    • showHudComponents

      public void showHudComponents(@Nonnull PlayerRef ref, @Nonnull Set<HudComponent> hudComponents)
    • hideHudComponents

      public void hideHudComponents(@Nonnull PlayerRef ref, @Nonnull HudComponent... hudComponents)
    • addCustomHud

      public void addCustomHud(@Nonnull PlayerRef ref, @Nonnull CustomUIHud hud)
      Adds or replaces a custom HUD layer. The HUD is keyed by CustomUIHud.getKey(). If a HUD already exists at this key, it is removed first (sending a clear packet to the client).
      Parameters:
      ref - The player reference
      hud - The custom HUD to add
    • removeCustomHud

      public void removeCustomHud(@Nonnull PlayerRef ref, @Nonnull String key)
      Removes a custom HUD layer by key.
      Parameters:
      ref - The player reference
      key - The unique key identifying the HUD layer to remove
    • dev_registerWidget

      public void dev_registerWidget(@Nonnull PlayerRef playerRef, @Nonnull UIHudWidget widget)
      Registers a serverside HUD widget. If a widget with the same ID is already active, the new widget won't be registered and a warning will be logged.

      Part of an upcoming feature that is still in development and not yet ready for production use. Do not use. The API is not final and may change.

      Parameters:
      playerRef - The owning player reference.
      widget - The widget to register.
    • dev_unregisterWidget

      public void dev_unregisterWidget(@Nonnull PlayerRef ref, @Nonnull String id)
      Unregisters the HUD widget with the given ID. No-op if the widget is not registered. If you want to hide the widget instead, use setWidgetVisible() instead.

      Part of an upcoming feature that is still in development and not yet ready for production use. Do not use. The API is not final and may change.

      Parameters:
      ref - The player reference used to send packets.
      id - The widget ID to remove.
    • dev_unregisterWidget

      public void dev_unregisterWidget(@Nonnull PlayerRef ref, @Nonnull UIHudWidget widget)
      Unregisters the HUD widget with the given ID. No-op if the widget is not registered. If you want to hide the widget instead, use setWidgetVisible() instead.

      Part of an upcoming feature that is still in development and not yet ready for production use. Do not use. The API is not final and may change.

      Parameters:
      ref - The player reference used to send packets.
      widget - The widget to remove.
    • dev_setWidgetVisible

      public void dev_setWidgetVisible(@Nonnull PlayerRef playerRef, @Nonnull String id, boolean visible)
      Shows or hides the HUD widget with the given ID. No-op if not registered or already in the requested state.

      Calls UISurface.onShow(Ref, Store) / UISurface.onHide(Ref, Store) at the correct point in the lifecycle: commands emitted by the callback are batched with the visibility packet.

      Part of an upcoming feature that is still in development and not yet ready for production use. Do not use. The API is not final and may change.

      Parameters:
      playerRef - The player reference used to send packets.
      id - The widget ID.
      visible - true to show, false to hide.
    • dev_setWidgetVisible

      public void dev_setWidgetVisible(@Nonnull PlayerRef playerRef, @Nonnull UIHudWidget widget, boolean visible)
      Shows or hides the HUD widget with the given ID. No-op if not registered or already in the requested state.

      Calls UISurface.onShow(Ref, Store) / UISurface.onHide(Ref, Store) at the correct point in the lifecycle: commands emitted by the callback are batched with the visibility packet.

      Part of an upcoming feature that is still in development and not yet ready for production use. Do not use. The API is not final and may change.

      Parameters:
      playerRef - The player reference used to send packets.
      widget - The widget to show or hide.
      visible - true to show, false to hide.
    • dev_handleWidgetCommand

      public void dev_handleWidgetCommand(@Nonnull PlayerRef playerRef, @Nonnull Ref<EntityStore> ref, @Nonnull Store<EntityStore> store, @Nonnull ExecuteServersideHudCommand packet)
      Routes an incoming execute-command packet from the client to the matching widget. Dispatch requires only that the widget is registered. A hidden widget still receives commands, so do not treat hide as access control. Enforce that in the command handler if the action must stay unavailable while the widget is hidden.

      Part of an upcoming feature that is still in development and not yet ready for production use. Do not use. The API is not final and may change.

      Parameters:
      playerRef - The player that owns the widget.
      ref - The entity reference of the player entity.
      store - The entity store for component access.
      packet - The packet received from the client.
    • dev_isWidgetVisible

      public boolean dev_isWidgetVisible(@Nonnull String id)
      Part of an upcoming feature that is still in development and not yet ready for production use. Do not use. The API is not final and may change.
      Returns:
      true if the serverside widget with the given ID is currently visible.
    • getWidgets

      @Nonnull public Map<String, UIHudWidget> getWidgets()
      Returns:
      an unmodifiable view of all registered serverside HUD widgets, keyed by their ID.
    • resetVisibleHudComponents

      public void resetVisibleHudComponents(@Nonnull PlayerRef ref)
      Restores the default visible HUD component set, leaving custom HUD layers untouched.
    • resetHud

      public void resetHud(@Nonnull PlayerRef ref)
    • resetUserInterface

      public void resetUserInterface(@Nonnull PlayerRef ref)
    • sendVisibleHudComponents

      public void sendVisibleHudComponents(@Nonnull PacketHandler packetHandler)
    • toString

      @Nonnull public String toString()
      Overrides:
      toString in class Object