Class DiscordSerializer

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static DiscordSerializer INSTANCE
      Default instance of the DiscordSerializer, incase that's all you need.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      java.util.function.Function<net.kyori.adventure.text.KeybindComponent,​java.lang.String> getKeybindProvider()
      Deprecated.
      Use #getDefaultOptions() DiscordSerializerOptions#getKeybindProvider()
      java.util.function.Function<net.kyori.adventure.text.TranslatableComponent,​java.lang.String> getTranslationProvider()
      Deprecated.
      Use #getDefaultOptions() DiscordSerializerOptions#getTranslationProvider()
      java.lang.String serialize​(@NonNull net.kyori.adventure.text.Component component)
      Serializes a Component to Discord formatting (markdown) with this serializer's default options.
      Use serialize(Component, DiscordSerializerOptions) to fine tune the serialization options.
      java.lang.String serialize​(@NonNull net.kyori.adventure.text.Component component, boolean embedLinks)
      Deprecated.
      Use serialize(Component, DiscordSerializerOptions) DiscordSerializerOptions#withEmbedLinks(boolean)
      java.lang.String serialize​(@NonNull net.kyori.adventure.text.Component component, @NonNull DiscordSerializerOptions serializerOptions)
      Serializes Component (from a chat message) to Discord formatting (markdown).
      void setKeybindProvider​(java.util.function.Function<net.kyori.adventure.text.KeybindComponent,​java.lang.String> provider)
      Deprecated.
      Use #setDefaultOptions(DiscordSerializerOptions) DiscordSerializerOptions#withKeybindProvider(Function)
      void setTranslationProvider​(java.util.function.Function<net.kyori.adventure.text.TranslatableComponent,​java.lang.String> provider)
      Deprecated.
      Use #setDefaultOptions(DiscordSerializerOptions) DiscordSerializerOptions#withTranslationProvider(Function)
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • INSTANCE

        public static final DiscordSerializer INSTANCE
        Default instance of the DiscordSerializer, incase that's all you need. Using DiscordSerializer#setDefaultOptions(DiscordSerializerOptions) is not allowed.
    • Constructor Detail

      • DiscordSerializer

        public DiscordSerializer​(@NonNull
                                 @NonNull DiscordSerializerOptions defaultOptions)
        Constructor for creating a serializer, with the specified DiscordSerializerOptions as defaults.
        Parameters:
        defaultOptions - the default serializer options (can be overridden on serialize)
        See Also:
        DiscordSerializerOptions.defaults(), DiscordSerializerOptions#DiscordSerializerOptions(boolean, boolean, Function, Function)
      • DiscordSerializer

        @Deprecated
        public DiscordSerializer​(java.util.function.Function<net.kyori.adventure.text.KeybindComponent,​java.lang.String> keybindProvider,
                                 java.util.function.Function<net.kyori.adventure.text.TranslatableComponent,​java.lang.String> translationProvider)
        Deprecated.
        Use DiscordSerializer(DiscordSerializerOptions) DiscordSerializerOptions#withKeybindProvider(Function) DiscordSerializerOptions#withTranslationProvider(Function)
        Constructor fore creating a serializer with translations provided with arguments.
        Parameters:
        keybindProvider - The keybind provider.
        translationProvider - The translation provider.
    • Method Detail

      • getKeybindProvider

        @Deprecated
        public java.util.function.Function<net.kyori.adventure.text.KeybindComponent,​java.lang.String> getKeybindProvider()
        Deprecated.
        Use #getDefaultOptions() DiscordSerializerOptions#getKeybindProvider()
        Returns the keybind provider for this serializer.
        Returns:
        keybind provider, a KeybindComponent to String function
      • setKeybindProvider

        @Deprecated
        public void setKeybindProvider​(java.util.function.Function<net.kyori.adventure.text.KeybindComponent,​java.lang.String> provider)
        Deprecated.
        Use #setDefaultOptions(DiscordSerializerOptions) DiscordSerializerOptions#withKeybindProvider(Function)
        Sets the keybind provider for this serializer.
        Parameters:
        provider - a KeybindComponent to String function
      • getTranslationProvider

        @Deprecated
        public java.util.function.Function<net.kyori.adventure.text.TranslatableComponent,​java.lang.String> getTranslationProvider()
        Deprecated.
        Use #getDefaultOptions() DiscordSerializerOptions#getTranslationProvider()
        Returns the translation provider for this serializer.
        Returns:
        keybind provider, a TranslatableComponent to String function
      • setTranslationProvider

        @Deprecated
        public void setTranslationProvider​(java.util.function.Function<net.kyori.adventure.text.TranslatableComponent,​java.lang.String> provider)
        Deprecated.
        Use #setDefaultOptions(DiscordSerializerOptions) DiscordSerializerOptions#withTranslationProvider(Function)
        Sets the translation provider for this serializer.
        Parameters:
        provider - a TranslationComponent to String function
      • serialize

        public java.lang.String serialize​(@NonNull
                                          @NonNull net.kyori.adventure.text.Component component)
        Serializes a Component to Discord formatting (markdown) with this serializer's default options.
        Use serialize(Component, DiscordSerializerOptions) to fine tune the serialization options.
        Parameters:
        component - The text component from a Minecraft chat message
        Returns:
        Discord markdown formatted String
      • serialize

        @Deprecated
        public java.lang.String serialize​(@NonNull
                                          @NonNull net.kyori.adventure.text.Component component,
                                          boolean embedLinks)
        Deprecated.
        Use serialize(Component, DiscordSerializerOptions) DiscordSerializerOptions#withEmbedLinks(boolean)
        Serializes a Component (from a chat message) to Discord formatting (markdown).
        Parameters:
        component - The text component from a Minecraft chat message
        embedLinks - Makes messages format as [message content](url) when there is a open_url clickEvent (for embeds)
        Returns:
        Discord markdown formatted String
      • serialize

        public java.lang.String serialize​(@NonNull
                                          @NonNull net.kyori.adventure.text.Component component,
                                          @NonNull
                                          @NonNull DiscordSerializerOptions serializerOptions)
        Serializes Component (from a chat message) to Discord formatting (markdown).
        Parameters:
        component - The text component from a Minecraft chat message
        serializerOptions - The options to use for this serialization
        Returns:
        Discord markdown formatted String
        See Also:
        DiscordSerializerOptions.defaults(), DiscordSerializerOptions#DiscordSerializerOptions(boolean, boolean, Function, Function)