Class SpigotText

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

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

    Fields
    Modifier and Type
    Field
    Description
    protected int
    The alpha value for the color in this text element.
    protected net.md_5.bungee.api.chat.BaseComponent
    The text content for this text element.

    Fields inherited from class xyz.gmitch215.socketmc.util.render.text.Text

    dropShadow, FONT_HEIGHT
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new, empty text element.
    SpigotText(@NotNull net.md_5.bungee.api.chat.BaseComponent component)
    Constructs a new text element.
    SpigotText(@NotNull net.md_5.bungee.api.chat.BaseComponent component, int alpha)
    Constructs a new text element.
  • Method Summary

    Modifier and Type
    Method
    Description
    from(@NotNull net.md_5.bungee.api.chat.BaseComponent component)
    Constructs a new text element with the given text content.
    int
    Gets the alpha value for the color in this text element.
    int
    Gets the color as an ARGB integer.
    @NotNull net.md_5.bungee.api.chat.BaseComponent
    Gets the text content for this text element.
    void
    setAlpha(int alpha)
    Sets the alpha value for the color in this text element.
    void
    setComponent(@NotNull net.md_5.bungee.api.chat.BaseComponent component)
    Sets the text content for this text element.
    Serializes this text element to a JSON string compatible with the Minecraft Component format.

    Methods inherited from class xyz.gmitch215.socketmc.util.render.text.Text

    isDropShadow, setDropShadow

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • component

      protected net.md_5.bungee.api.chat.BaseComponent component
      The text content for this text element.
    • alpha

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

    • SpigotText

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

      public SpigotText(@NotNull @NotNull net.md_5.bungee.api.chat.BaseComponent component)
      Constructs a new text element.
      Parameters:
      component - Component for Text
    • SpigotText

      public SpigotText(@NotNull @NotNull net.md_5.bungee.api.chat.BaseComponent component, int alpha) throws IllegalArgumentException
      Constructs a new text element.
      Parameters:
      component - Component for Text
      alpha - Color Alpha Value
      Throws:
      IllegalArgumentException - if component is null or the alpha value is not between 0 and 255
  • Method Details

    • getComponent

      @NotNull public @NotNull net.md_5.bungee.api.chat.BaseComponent getComponent()
      Gets the text content for this text element.
      Returns:
      Text Content
    • setComponent

      public void setComponent(@NotNull @NotNull net.md_5.bungee.api.chat.BaseComponent 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 SpigotText from(@NotNull @NotNull net.md_5.bungee.api.chat.BaseComponent component)
      Constructs a new text element with the given text content.
      Parameters:
      component - Text Component
      Returns:
      Text Element