Class CustomScreen

java.lang.Object
xyz.gmitch215.socketmc.screen.AbstractScreen
xyz.gmitch215.socketmc.screen.CustomScreen
All Implemented Interfaces:
Serializable, Narratable

public final class CustomScreen extends AbstractScreen
Represents a custom screen to be displayed on the client's screen.
See Also:
  • Constructor Details

    • CustomScreen

      public CustomScreen(@NotNull @NotNull Text title)
      Constructs a new screen with the given title.
      Parameters:
      title - the title
  • Method Details

    • getTitleJSON

      public String getTitleJSON()
      Description copied from class: AbstractScreen
      Gets the title of this screen.
      Specified by:
      getTitleJSON in class AbstractScreen
      Returns:
      Title in JSON Format
    • setTitleJSON

      public void setTitleJSON(@NotNull @NotNull String titleJSON)
      Sets the title of this screen.
      Parameters:
      titleJSON - the title in JSON format
    • setTitle

      public void setTitle(@NotNull @NotNull Text title)
      Sets the title of this screen.
      Parameters:
      title - the title
    • getNarrationMessageJSON

      public String getNarrationMessageJSON()
      Description copied from interface: Narratable
      Gets the JSON message that represents the narration of this element. By default, this is the title of the element.
      Specified by:
      getNarrationMessageJSON in interface Narratable
      Overrides:
      getNarrationMessageJSON in class AbstractScreen
      Returns:
      the JSON message
    • setNarrationMessageJSON

      public void setNarrationMessageJSON(@Nullable @Nullable String narrationMessageJSON)
      Sets the narration message of this screen.
      Parameters:
      narrationMessageJSON - the narration message in JSON format
    • setNarrationMessage

      public void setNarrationMessage(@Nullable @Nullable Text narrationMessage)
      Sets the narration message of this screen.
      Parameters:
      narrationMessage - the narration message
    • addChild

      public void addChild(@NotNull @NotNull Positionable child) throws IllegalArgumentException
      Adds a child to this screen.
      Parameters:
      child - the child element
      Throws:
      IllegalArgumentException - if the child is null or if an element already exists at the same position
    • removeChild

      public void removeChild(@NotNull @NotNull Positionable child)
      Removes a child from this screen.
      Parameters:
      child - the child element
    • clearChildren

      public void clearChildren()
      Removes all children from this screen.
    • getChildren

      @NotNull public @NotNull List<Positionable> getChildren()
      Gets an immutable copy of the children in this screen.
      Returns:
      List of Screen Elements
    • getBackground

      @NotNull public @NotNull ScreenBackground getBackground()
      Gets the background of this screen.
      Returns:
      Screen Background
    • setBackground

      public void setBackground(@NotNull @NotNull ScreenBackground background) throws IllegalArgumentException
      Sets the background of this screen.
      Parameters:
      background - Screen Background
      Throws:
      IllegalArgumentException - if the background is null
    • getLayout

      @Nullable public @Nullable Layout getLayout()
      Gets the layout of this screen.
      Returns:
      Layout
    • setLayout

      public void setLayout(@Nullable @Nullable Layout layout)
      Sets the layout of this screen. Setting it to null will not remove the elements from the layout.
      Parameters:
      layout - Layout
    • isCloseableOnEscape

      public boolean isCloseableOnEscape()
      Gets whether this screen can be closed with the escape key.
      Returns:
      true if screen can be closed with escape
    • setCloseableOnEscape

      public void setCloseableOnEscape(boolean closeableOnEscape)
      Sets whether this screen can be closed with the escape key.
      Parameters:
      closeableOnEscape - true if screen can be closed with escape
    • toString

      public String toString()
      Overrides:
      toString in class Object