Interface MiniMessage

All Superinterfaces:
ComponentDecoder<String,Component>, ComponentEncoder<Component,String>, ComponentSerializer<Component,Component,String>

public interface MiniMessage extends ComponentSerializer<Component,Component,String>
MiniMessage is a textual representation of components.

This class allows you to serialize and deserialize them, strip or escape them.

Since:
4.10.0
  • Method Details

    • miniMessage

      @NotNull static @NotNull MiniMessage miniMessage()
      Gets a simple instance with default settings.
      Returns:
      a simple instance
      Since:
      4.10.0
    • escapeTags

      @NotNull @NotNull String escapeTags(@NotNull @NotNull String input)
      Escapes all known tags in the input message, so that they are ignored in deserialization.

      Useful for untrusted input.

      Only globally known tags will be escaped. Use the overload that takes a TagResolver if any custom tags should be handled.

      Parameters:
      input - the input message, with potential tags
      Returns:
      the output, with escaped tags
      Since:
      4.10.0
    • escapeTags

      @NotNull @NotNull String escapeTags(@NotNull @NotNull String input, @NotNull @NotNull TagResolver tagResolver)
      Escapes all known tags in the input message, so that they are ignored in deserialization.

      Useful for untrusted input.

      Parameters:
      input - the input message, with potential tags
      tagResolver - the tag resolver for any additional tags to handle
      Returns:
      the output, with escaped tags
      Since:
      4.10.0
    • escapeTags

      @NotNull default @NotNull String escapeTags(@NotNull @NotNull String input, @NotNull @NotNull TagResolver... tagResolvers)
      Escapes all known tags in the input message, so that they are ignored in deserialization.

      Useful for untrusted input.

      Parameters:
      input - the input message, with potential tags
      tagResolvers - a series of tag resolvers to apply extra tags from, last specified taking priority
      Returns:
      the output, with escaped tags
      Since:
      4.10.0
    • stripTags

      @NotNull @NotNull String stripTags(@NotNull @NotNull String input)
      Removes all supported tags in the input message.

      Useful for untrusted input.

      Only globally known tags will be stripped. Use the overload that takes a TagResolver if any custom tags should be handled.

      Parameters:
      input - the input message, with potential tags
      Returns:
      the output, without tags
      Since:
      4.10.0
    • stripTags

      @NotNull @NotNull String stripTags(@NotNull @NotNull String input, @NotNull @NotNull TagResolver tagResolver)
      Removes all known tags in the input message, so that they are ignored in deserialization.

      Useful for untrusted input.

      Parameters:
      input - the input message, with tags
      tagResolver - the tag resolver for any additional tags to handle
      Returns:
      the output, without tags
      Since:
      4.10.0
    • stripTags

      @NotNull default @NotNull String stripTags(@NotNull @NotNull String input, @NotNull @NotNull TagResolver... tagResolvers)
      Removes all known tags in the input message, so that they are ignored in deserialization.

      Useful for untrusted input.

      Parameters:
      input - the input message, with tags
      tagResolvers - a series of tag resolvers to apply extra tags from, last specified taking priority
      Returns:
      the output, without tags
      Since:
      4.10.0
    • deserialize

      @NotNull @NotNull Component deserialize(@NotNull @NotNull String input, @NotNull @NotNull Pointered target)
      Deserializes a string into a component, with a target.
      Parameters:
      input - the input string
      target - the target of the deserialization
      Returns:
      the output component
      Since:
      4.17.0
    • deserialize

      @NotNull @NotNull Component deserialize(@NotNull @NotNull String input, @NotNull @NotNull TagResolver tagResolver)
      Deserializes a string into a component, with a tag resolver to parse tags of the form <key>.

      Tags will be resolved from the resolver parameter before the resolver provided in the builder is used.

      Parameters:
      input - the input string
      tagResolver - the tag resolver for any additional tags to handle
      Returns:
      the output component
      Since:
      4.10.0
    • deserialize

      @NotNull @NotNull Component deserialize(@NotNull @NotNull String input, @NotNull @NotNull Pointered target, @NotNull @NotNull TagResolver tagResolver)
      Deserializes a string into a component, with a tag resolver to parse tags of the form <key> and a target.

      Tags will be resolved from the resolver parameter before the resolver provided in the builder is used.

      Parameters:
      input - the input string
      target - the target of the deserialization
      tagResolver - the tag resolver for any additional tags to handle
      Returns:
      the output component
      Since:
      4.17.0
    • deserialize

      @NotNull default @NotNull Component deserialize(@NotNull @NotNull String input, @NotNull @NotNull TagResolver... tagResolvers)
      Deserializes a string into a component, with tag resolvers to parse tags of the form <key>.

      Tags will be resolved from the resolver parameters before the resolver provided in the builder is used.

      Parameters:
      input - the input string
      tagResolvers - a series of tag resolvers to apply extra tags from, last specified taking priority
      Returns:
      the output component
      Since:
      4.10.0
    • deserialize

      @NotNull default @NotNull Component deserialize(@NotNull @NotNull String input, @NotNull @NotNull Pointered target, @NotNull @NotNull TagResolver... tagResolvers)
      Deserializes a string into a component, with tag resolvers to parse tags of the form <key> and a target.

      Tags will be resolved from the resolver parameters before the resolver provided in the builder is used.

      Parameters:
      input - the input string
      target - the target of the deserialization
      tagResolvers - a series of tag resolvers to apply extra tags from, last specified taking priority
      Returns:
      the output component
      Since:
      4.17.0
    • deserializeToTree

      @NotNull Node.Root deserializeToTree(@NotNull @NotNull String input)
      Deserializes a string into a tree of parsed elements. This is intended for inspecting the output of the parser for debugging purposes.
      Parameters:
      input - the input string
      Returns:
      the root of the resulting tree
      Since:
      4.10.0
    • deserializeToTree

      @NotNull Node.Root deserializeToTree(@NotNull @NotNull String input, @NotNull @NotNull Pointered target)
      Deserializes a string into a tree of parsed elements, with a target. This is intended for inspecting the output of the parser for debugging purposes.
      Parameters:
      input - the input string
      target - the target of the deserialization
      Returns:
      the root of the resulting tree
      Since:
      4.17.0
    • deserializeToTree

      @NotNull Node.Root deserializeToTree(@NotNull @NotNull String input, @NotNull @NotNull TagResolver tagResolver)
      Deserializes a string into a tree of parsed elements, with a tag resolver to parse tags of the form <key>. This is intended for inspecting the output of the parser for debugging purposes.

      Tags will be resolved from the resolver parameter before the resolver provided in the builder is used.

      Parameters:
      input - the input string
      tagResolver - the tag resolver for any additional tags to handle
      Returns:
      the root of the resulting tree
      Since:
      4.10.0
    • deserializeToTree

      @NotNull Node.Root deserializeToTree(@NotNull @NotNull String input, @NotNull @NotNull Pointered target, @NotNull @NotNull TagResolver tagResolver)
      Deserializes a string into a tree of parsed elements, with a tag resolver to parse tags of the form <key> and a target. This is intended for inspecting the output of the parser for debugging purposes.

      Tags will be resolved from the resolver parameter before the resolver provided in the builder is used.

      Parameters:
      input - the input string
      target - the target of the deserialization
      tagResolver - the tag resolver for any additional tags to handle
      Returns:
      the root of the resulting tree
      Since:
      4.17.0
    • deserializeToTree

      default @NotNull Node.Root deserializeToTree(@NotNull @NotNull String input, @NotNull @NotNull TagResolver... tagResolvers)
      Deserializes a string into a tree of parsed elements, with a tag resolver to parse tags of the form <key>. This is intended for inspecting the output of the parser for debugging purposes.

      Tags will be resolved from the resolver parameter before the resolver provided in the builder is used.

      Parameters:
      input - the input string
      tagResolvers - a series of tag resolvers to apply extra tags from, last specified taking priority
      Returns:
      the root of the resulting tree
      Since:
      4.10.0
    • deserializeToTree

      default @NotNull Node.Root deserializeToTree(@NotNull @NotNull String input, @NotNull @NotNull Pointered target, @NotNull @NotNull TagResolver... tagResolvers)
      Deserializes a string into a tree of parsed elements, with a tag resolver to parse tags of the form <key>. This is intended for inspecting the output of the parser for debugging purposes.

      Tags will be resolved from the resolver parameter before the resolver provided in the builder is used.

      Parameters:
      input - the input string
      target - the target of the deserialization
      tagResolvers - a series of tag resolvers to apply extra tags from, last specified taking priority
      Returns:
      the root of the resulting tree
      Since:
      4.17.0
    • strict

      boolean strict()
      Returns if this MiniMessage instance is in strict mode.
      Returns:
      if the instance is in strict mode
      Since:
      4.15.0
      See Also:
    • tags

      @NotNull @NotNull TagResolver tags()
      Returns the base tag resolver of this MiniMessage instance.
      Returns:
      the base tag resolver
      Since:
      4.15.0
    • builder

      static MiniMessage.Builder builder()
      Creates a new MiniMessage.Builder.
      Returns:
      a builder
      Since:
      4.10.0