Class PlainText

java.lang.Object
xyz.gmitch215.socketmc.util.render.text.Text
xyz.gmitch215.socketmc.util.render.text.PlainText
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
BukkitText

public class PlainText extends Text
Represents a text element with plain text.
See Also:
  • Field Details

    • text

      protected String text
      The text content for this text element.
    • color

      protected int color
      The color for this text element.
  • Constructor Details

    • PlainText

      public PlainText()
      Constructs a new, empty text element.
    • PlainText

      public PlainText(@NotNull @NotNull String text)
      Constructs a new text element.
      Parameters:
      text - Text Content
    • PlainText

      public PlainText(@NotNull @NotNull String text, @NotNull @NotNull Color color)
      Constructs a new text element.
      Parameters:
      text - Text Content
      color - Color
    • PlainText

      public PlainText(@NotNull @NotNull String text, int color)
      Constructs a new text element.
      Parameters:
      text - Text Content
      color - Color as an ARGB integer
  • Method Details

    • getText

      @NotNull public @NotNull String getText()
      Gets the text content for this text element.
      Returns:
      Text Content
    • setText

      public void setText(@NotNull @NotNull String text) throws IllegalArgumentException
      Sets the text content for this text element.
      Parameters:
      text - Text Content
      Throws:
      IllegalArgumentException - if the text is null
    • 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
    • setColor

      public void setColor(int color)
      Sets the color for this text element.
      Parameters:
      color - Color as an ARGB integer
    • getAlpha

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

      public void setAlpha(int alpha)
      Sets the alpha value for the color in this text element.
      Parameters:
      alpha - Color Alpha
    • 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
    • empty

      @NotNull public static @NotNull PlainText empty()
      Creates a new text element with empty text content.
      Returns:
      Empty Text Element
    • of

      Creates a new text element with the specified text content.
      Parameters:
      text - Text Content
      Returns:
      Text Element