Interface Context


@NonExtendable public 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 @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

      @NotNull @NotNull 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

      @NotNull <T extends Pointered> T targetAsType(@NotNull @NotNull 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

      @NotNull @NotNull Component deserialize(@NotNull @NotNull 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

      @NotNull @NotNull Component deserialize(@NotNull @NotNull String message, @NotNull @NotNull 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

      @NotNull @NotNull Component deserialize(@NotNull @NotNull String message, @NotNull @NotNull TagResolver @NotNull ... 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

      @NotNull @NotNull ParsingException newException(@NotNull @NotNull String message, @NotNull @NotNull 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

      @NotNull @NotNull ParsingException newException(@NotNull @NotNull 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

      @NotNull @NotNull ParsingException newException(@NotNull @NotNull String message, @Nullable @Nullable Throwable cause, @NotNull @NotNull 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