Class WindowManager

java.lang.Object
com.hypixel.hytale.server.core.entity.entities.player.windows.WindowManager

public class WindowManager extends Object
A manager for managing active windows for a player, such as crafting benches and chest containers.
  • Constructor Details

    • WindowManager

      public WindowManager()
  • Method Details

    • init

      public void init(@Nonnull PlayerRef playerRef)
      Called to set the player ref associated with this window manager.
      Parameters:
      playerRef - The player ref of the associated player.
    • clientOpenWindow

      @Nullable public UpdateWindow clientOpenWindow(@Nonnull Ref<EntityStore> ref, @Nonnull Window window, @Nonnull Store<EntityStore> store)
      Called to open a given inventory window via this manager.
      Parameters:
      ref - The entity store reference of the player opening the window.
      window - The window instance to open.
      store - The entity store of the player opening the window.
      Returns:
      an UpdateWindow packet to be sent to the client, or null if the window failed to open.
    • openWindow

      @Nullable public OpenWindow openWindow(@Nonnull Ref<EntityStore> ref, @Nonnull Window window, @Nonnull Store<EntityStore> store)
      Called to open a specific window instance via this manager.
      Parameters:
      ref - The entity store reference of the player opening the window.
      window - The window instance to be opened.
      store - The entity store of the player opening the window.
      Returns:
      an OpenWindow packet to be sent to the client.
    • openWindows

      @Nullable public List<OpenWindow> openWindows(@Nonnull Ref<EntityStore> ref, @Nonnull Store<EntityStore> store, @Nonnull Window... windows)
      Called to open the given collection of windows via this window manager.
      Parameters:
      ref - The entity store reference of the player opening the windows.
      store - The entity store of the player opening the windows.
      windows - The collection of windows to be opened.
      Returns:
      a list of OpenWindow packets to send to the client.
    • setWindow

      public void setWindow(int id, @Nonnull Window window)
      Called to set the current active window, from the given ID and window instance.
      Parameters:
      id - The ID of the window.
      window - The window instance to set.
    • getWindow

      @Nullable public Window getWindow(int id)
      Called to fetch a specific window instance from the given ID.
      Parameters:
      id - The unique ID of the window to fetch.
      Returns:
      the Window instance, or null if non exist.
    • getWindows

      @Nonnull public List<Window> getWindows()
      Called to fetch a collection of all active windows.
      Returns:
      a new list of active Window instances.
    • updateWindow

      public void updateWindow(@Nonnull Window window)
      Called to send a window update packet to the associated client player.
      Parameters:
      window - The Window instance to send to the client player.
    • closeWindow

      @Nonnull public Window closeWindow(@Nonnull Ref<EntityStore> ref, int id, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Called to close the window affiliated with the given ID.
      Parameters:
      ref - The entity store reference of the player closing the window.
      id - The unique ID of the window to close.
      componentAccessor - The entity store of the player closing the window.
      Returns:
      the window that has been closed.
    • closeAllWindows

      public void closeAllWindows(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Called to close all windows associated with this manager.
      Parameters:
      ref - The entity reference of the affiliated entity.
      componentAccessor - The ComponentAccessor<EntityStore> for component access.
    • markWindowChanged

      public void markWindowChanged(int id)
      Called to mark a specific window as dirty and needing synced.
      Parameters:
      id - The unique ID of the window.
    • updateWindows

      public void updateWindows()
      Called to update each window associated with this manager.
    • validateWindows

      public void validateWindows(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Called to validate all windows associated with this manager.
    • closeAndRemoveAll

      public static <W extends Window> void closeAndRemoveAll(@Nonnull Map<UUID,W> windows)
      Called to close and remove all windows from the provided map of windows.
      Type Parameters:
      W - Window class type.
      Parameters:
      windows - Given map of windows to close and remove.
    • toString

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