Class XComponentBuilder

java.lang.Object
org.kingdoms.utils.XComponentBuilder

public final class XComponentBuilder extends Object
  • Field Details

    • MAXIMUM_JSON_CHAT_PACKET_SIZE

      public static final int MAXIMUM_JSON_CHAT_PACKET_SIZE
      The maximum bytes that the ClientboundSystemChatPacket (which has the packet ID of 0x64 = 100) can send which is defined by the void method(PacketDataSerializer packetdataserializer)

      The client will not try to split BaseComponent[] array into separate packets, internally, it just:

      new ClientboundSystemChatPacket(ComponentSerializer.toString(new TextComponent(BaseComponent[])))

      In 1.16 and below the limit seems to be 32767. https://discord.com/channels/429132410748141579/1157040462176202792

      See Also:
    • SUGGESTED_JSON_CHAT_PACKET_SIZE_RENEWAL

      public static final int SUGGESTED_JSON_CHAT_PACKET_SIZE_RENEWAL
      When should we start using a new packet? This will of course fail in rare cases.
      See Also:
  • Constructor Details

    • XComponentBuilder

      public XComponentBuilder(String text)
    • XComponentBuilder

      public XComponentBuilder()
  • Method Details

    • duplicate

      public static net.md_5.bungee.api.chat.TextComponent duplicate(net.md_5.bungee.api.chat.TextComponent component)
    • copyFormatting

      public static void copyFormatting(net.md_5.bungee.api.chat.BaseComponent to, net.md_5.bungee.api.chat.BaseComponent from, net.md_5.bungee.api.chat.ComponentBuilder.FormatRetention retention)
      Because 1.12 doesn't have it.
    • append

      public XComponentBuilder append(net.md_5.bungee.api.chat.BaseComponent component)
    • append

      public XComponentBuilder append(net.md_5.bungee.api.chat.BaseComponent component, net.md_5.bungee.api.chat.ComponentBuilder.FormatRetention retention)
    • newPacket

      public void newPacket()
    • append

      public XComponentBuilder append(String text)
    • append

      public XComponentBuilder append(String text, net.md_5.bungee.api.chat.ComponentBuilder.FormatRetention retention)
    • createSingular

      public net.md_5.bungee.api.chat.BaseComponent[] createSingular()
    • create

      public net.md_5.bungee.api.chat.BaseComponent[][] create()
    • buildTextComponent

      public net.md_5.bungee.api.chat.TextComponent buildTextComponent()
    • fromLegacyText

      @Deprecated public static net.md_5.bungee.api.chat.BaseComponent[] fromLegacyText(String message)
      Deprecated.
      This is here just for the sake of research.
      A modified version of the original method TextComponent.fromLegacyText(String, ChatColor) to avoid the stupid auto URL converter.

      Converts the old formatting system that used ChatColor.COLOR_CHAR into the new json based system.

      Parameters:
      message - the text to convert
      Returns:
      the components needed to print the message to the client
    • resetFormats

      public static void resetFormats(net.md_5.bungee.api.chat.BaseComponent component)