Class DiscordSerializer
- java.lang.Object
-
- dev.vankka.mcdiscordreserializer.discord.DiscordSerializer
-
public class DiscordSerializer extends java.lang.ObjectDiscordSerializer, for serializing from MinecraftComponents to Discord messages.- Author:
- Vankka
- See Also:
DiscordSerializerOptions,DiscordMarkdownRules
-
-
Field Summary
Fields Modifier and Type Field Description static DiscordSerializerINSTANCEDefault instance of the DiscordSerializer, incase that's all you need.
-
Constructor Summary
Constructors Constructor Description DiscordSerializer()Constructor for creating a serializer, whichDiscordSerializerOptions.defaults()as defaults.DiscordSerializer(@NonNull DiscordSerializerOptions defaultOptions)Constructor for creating a serializer, with the specifiedDiscordSerializerOptionsas defaults.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.UseDiscordSerializer(DiscordSerializerOptions)DiscordSerializerOptions#withKeybindProvider(Function)DiscordSerializerOptions#withTranslationProvider(Function)
-
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.Stringserialize(@NonNull net.kyori.adventure.text.Component component)Serializes aComponentto Discord formatting (markdown) with this serializer'sdefault options.
Useserialize(Component, DiscordSerializerOptions)to fine tune the serialization options.java.lang.Stringserialize(@NonNull net.kyori.adventure.text.Component component, boolean embedLinks)Deprecated.Useserialize(Component, DiscordSerializerOptions)DiscordSerializerOptions#withEmbedLinks(boolean)java.lang.Stringserialize(@NonNull net.kyori.adventure.text.Component component, @NonNull DiscordSerializerOptions serializerOptions)Serializes Component (from a chat message) to Discord formatting (markdown).voidsetKeybindProvider(java.util.function.Function<net.kyori.adventure.text.KeybindComponent,java.lang.String> provider)Deprecated.Use#setDefaultOptions(DiscordSerializerOptions)DiscordSerializerOptions#withKeybindProvider(Function)voidsetTranslationProvider(java.util.function.Function<net.kyori.adventure.text.TranslatableComponent,java.lang.String> provider)Deprecated.Use#setDefaultOptions(DiscordSerializerOptions)DiscordSerializerOptions#withTranslationProvider(Function)
-
-
-
Field Detail
-
INSTANCE
public static final DiscordSerializer INSTANCE
Default instance of the DiscordSerializer, incase that's all you need. UsingDiscordSerializer#setDefaultOptions(DiscordSerializerOptions)is not allowed.
-
-
Constructor Detail
-
DiscordSerializer
public DiscordSerializer()
Constructor for creating a serializer, whichDiscordSerializerOptions.defaults()as defaults.
-
DiscordSerializer
public DiscordSerializer(@NonNull @NonNull DiscordSerializerOptions defaultOptions)Constructor for creating a serializer, with the specifiedDiscordSerializerOptionsas 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.UseDiscordSerializer(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 aComponentto Discord formatting (markdown) with this serializer'sdefault options.
Useserialize(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.Useserialize(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 messageembedLinks- 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 messageserializerOptions- The options to use for this serialization- Returns:
- Discord markdown formatted String
- See Also:
DiscordSerializerOptions.defaults(),DiscordSerializerOptions#DiscordSerializerOptions(boolean, boolean, Function, Function)
-
-