Interface Context


public sealed interface Context
Parser context for use within transformations.

This allows operating recursive parses, for cases where messages may include parse-specific tags.

Since:
4.10.0
  • Method Details

    • target

      @Nullable Pointered target()
      The target of the parse context, if provided. Can be used for tags that provide information relating to the target of the resulting message.
      Returns:
      the target, if provided
      Since:
      4.17.0
    • targetOrThrow

      Pointered targetOrThrow()
      The target of the parse context. Can be used for tags that provide information relating to the target of the resulting message.

      If the caller did not provide a target, a parse exception is thrown with a default message.

      Returns:
      the target, if provided
      Since:
      4.17.0
    • targetAsType

      <T extends Pointered> T targetAsType(Class<T> targetClass)
      The target of the parse context, casted to a provided type. Can be used for tags that provide information relating to the target of the resulting message.

      If the caller did not provide a target, or the target is not of the provided type, a parse exception is thrown with a default message.

      Type Parameters:
      T - the required type
      Parameters:
      targetClass - the class of the required type
      Returns:
      the target
      Since:
      4.17.0
    • deserialize

      Component deserialize(String message)
      Deserializes a MiniMessage string using all the settings of this context.
      Parameters:
      message - the message to parse
      Returns:
      the parsed message
      Since:
      4.10.0
    • deserialize

      Component deserialize(String message, TagResolver resolver)
      Deserializes a MiniMessage string using all the settings of this context.
      Parameters:
      message - the message to parse
      resolver - additional tag resolver, added to all other resolvers in this parse, but taking priority in the event of a name overlap
      Returns:
      the parsed message
      Since:
      4.10.0
    • deserialize

      Component deserialize(String message, TagResolver... resolvers)
      Deserializes a MiniMessage string using all the settings of this context.
      Parameters:
      message - the message to parse
      resolvers - additional tag resolvers, added to all other resolvers in this parse, but taking priority in the event of a name overlap
      Returns:
      the parsed message
      Since:
      4.10.0
    • newException

      ParsingException newException(String message, ArgumentQueue tags)
      Create a new parsing exception.
      Parameters:
      message - a detail message describing the error
      tags - the tag parts which caused the error
      Returns:
      the new parsing exception
      Since:
      4.10.0
    • newException

      ParsingException newException(String message)
      Create a new parsing exception without reference to a specific location.
      Parameters:
      message - a detail message describing the error
      Returns:
      the new parsing exception
      Since:
      4.10.0
    • newException

      ParsingException newException(String message, @Nullable Throwable cause, ArgumentQueue args)
      Create a new parsing exception.
      Parameters:
      message - a detail message describing the error
      cause - the cause
      args - arguments that caused the errors
      Returns:
      the new parsing exception
      Since:
      4.10.0
    • emitVirtuals

      boolean emitVirtuals()
      Dictates if transformations may emit virtual components or not.
      Returns:
      the boolean flag, true if transformations may emit virtuals, false otherwise.
      Since:
      4.19.0