Class BungeeComponentSerializer

  • All Implemented Interfaces:
    net.kyori.adventure.text.serializer.ComponentSerializer<net.kyori.adventure.text.Component,​net.kyori.adventure.text.Component,​net.md_5.bungee.api.chat.BaseComponent[]>

    public final class BungeeComponentSerializer
    extends Object
    implements net.kyori.adventure.text.serializer.ComponentSerializer<net.kyori.adventure.text.Component,​net.kyori.adventure.text.Component,​net.md_5.bungee.api.chat.BaseComponent[]>
    A component serializer for BungeeCord's BaseComponent.
    Since:
    4.0.0
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      @NotNull net.kyori.adventure.text.Component deserialize​(@NotNull net.md_5.bungee.api.chat.BaseComponent @NotNull [] input)  
      static BungeeComponentSerializer get()
      Gets a component serializer.
      static boolean inject​(com.google.gson.Gson existing)
      Inject Adventure's adapter serializer into an existing Gson instance.
      static boolean isNative()
      Gets whether the component serializer has native support.
      static BungeeComponentSerializer legacy()
      Gets a component serializer, with color downsampling.
      static BungeeComponentSerializer of​(net.kyori.adventure.text.serializer.gson.GsonComponentSerializer serializer, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer legacySerializer)
      Create a component serializer with custom serialization properties.
      @NotNull net.md_5.bungee.api.chat.BaseComponent @NotNull [] serialize​(@NotNull net.kyori.adventure.text.Component component)  
      • Methods inherited from interface net.kyori.adventure.text.serializer.ComponentSerializer

        deseializeOrNull, deserializeOr, deserializeOrNull, serializeOr, serializeOrNull
    • Method Detail

      • isNative

        public static boolean isNative()
        Gets whether the component serializer has native support.

        Even if this is false, the serializer will still work.

        Returns:
        if there is native support
        Since:
        4.0.0
      • get

        public static BungeeComponentSerializer get()
        Gets a component serializer.
        Returns:
        a component serializer
        Since:
        4.0.0
      • legacy

        public static BungeeComponentSerializer legacy()
        Gets a component serializer, with color downsampling.
        Returns:
        a component serializer
        Since:
        4.0.0
      • of

        public static BungeeComponentSerializer of​(net.kyori.adventure.text.serializer.gson.GsonComponentSerializer serializer,
                                                   net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer legacySerializer)
        Create a component serializer with custom serialization properties.
        Parameters:
        serializer - The serializer creating a JSON representation of the component
        legacySerializer - The serializer creating a representation of the component with legacy formatting codes
        Returns:
        a new serializer
        Since:
        4.0.0
      • inject

        public static boolean inject​(com.google.gson.Gson existing)
        Inject Adventure's adapter serializer into an existing Gson instance.

        This is primarily for internal use, but may be useful if interfacing with existing libraries that maintain their own Gson instances.

        Parameters:
        existing - gson instance
        Returns:
        true if injection was successful
        Since:
        4.0.0
      • deserialize

        @NotNull
        public @NotNull net.kyori.adventure.text.Component deserialize​(@NotNull
                                                                       @NotNull net.md_5.bungee.api.chat.BaseComponent @NotNull [] input)
        Specified by:
        deserialize in interface net.kyori.adventure.text.serializer.ComponentSerializer<net.kyori.adventure.text.Component,​net.kyori.adventure.text.Component,​net.md_5.bungee.api.chat.BaseComponent[]>
      • serialize

        @NotNull
        public @NotNull net.md_5.bungee.api.chat.BaseComponent @NotNull [] serialize​(@NotNull
                                                                                     @NotNull net.kyori.adventure.text.Component component)
        Specified by:
        serialize in interface net.kyori.adventure.text.serializer.ComponentSerializer<net.kyori.adventure.text.Component,​net.kyori.adventure.text.Component,​net.md_5.bungee.api.chat.BaseComponent[]>