Class PaperText

java.lang.Object
xyz.gmitch215.socketmc.util.render.text.Text
xyz.gmitch215.socketmc.util.render.text.PaperText
All Implemented Interfaces:
Serializable

public final class PaperText extends Text
Represents a text element to be displayed on the client's screen, built by a Component.
See Also:
  • Field Details

    • component

      protected Component component
      The text content for this text element.
    • alpha

      protected int alpha
      The alpha value for the color in this text element.
  • Constructor Details

  • Method Details

    • getComponent

      @NotNull public @NotNull Component getComponent()
      Gets the text content for this text element.
      Returns:
      Text Content
    • setComponent

      public void setComponent(@NotNull @NotNull Component component) throws IllegalArgumentException
      Sets the text content for this text element.
      Parameters:
      component - Text Component
      Throws:
      IllegalArgumentException - if the text is null
    • getAlpha

      public int getAlpha()
      Gets the alpha value for the color in this text element.
      Returns:
      Alpha Value
    • setAlpha

      public void setAlpha(int alpha) throws IllegalArgumentException
      Sets the alpha value for the color in this text element.
      Parameters:
      alpha - Alpha Value
      Throws:
      IllegalArgumentException - if the alpha value is not between 0 and 255
    • getColor

      public int getColor()
      Description copied from class: Text
      Gets the color as an ARGB integer.
      Specified by:
      getColor in class Text
      Returns:
      String Color
    • toJSON

      public String toJSON()
      Description copied from class: Text
      Serializes this text element to a JSON string compatible with the Minecraft Component format.
      Specified by:
      toJSON in class Text
      Returns:
      JSON String
    • from

      @NotNull public static @NotNull PaperText from(@NotNull @NotNull Component component)
      Creates a new text element from a component.
      Parameters:
      component - Component for Text
      Returns:
      Text Element