Interface Arg

All Known Implementing Classes:
Arg.Localized, Arg.Moment, Arg.Numeric, Arg.Unparsed

public sealed interface Arg permits Arg.Unparsed, Arg.Numeric, Arg.Moment, Arg.Localized
A named message argument. A translation is a MiniMessage string that refers to arguments by name: "Welcome, <player>!". Positional arguments are not supported. An argument name takes precedence over a built-in MiniMessage tag of the same name (<newline>, <score>, ...).

Formatting is chosen by the translation, in the render locale:

Quote a pattern that contains :, <, > or a quote; quoting is always allowed. There is no boolean choice and no CLDR plural category in 7.0; a later minor may add argument kinds.

A format the engine cannot apply (a malformed pattern, an unknown keyword, a field the value does not have) never makes rendering throw: the value is shown in its kind's default format for the render locale (or String.valueOf(value) if even that fails), and one WARNING is logged per (message key, locale, argument name).

The set of permitted subtypes may grow in a 7.x minor release. Code outside the framework must not switch over it exhaustively without a default branch.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
    Deferred localized text.
    static final record 
    A date/time argument.
    static final record 
    A number argument.
    static final record 
    A plain-text argument.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Arg
    component(String name, net.kyori.adventure.text.ComponentLike value)
    Shorthand for text(name, Text.literal(value)).
    Returns the tag name, matching [a-z0-9_-]+.
    static Arg
    number(String name, Number value)
    Returns a number formatted with the target locale unless the translation specifies a pattern.
    static Arg
    string(String name, String value)
    Returns a literal string argument; MiniMessage tags in its value are never interpreted.
    static Arg
    text(String name, Text value)
    Returns deferred text, rendered in the enclosing message's locale.
    static Arg
    A date/time argument.
    private static void
     
  • Method Details

    • name

      String name()
      Returns the tag name, matching [a-z0-9_-]+.
    • string

      static Arg string(String name, String value)
      Returns a literal string argument; MiniMessage tags in its value are never interpreted.
    • number

      static Arg number(String name, Number value)
      Returns a number formatted with the target locale unless the translation specifies a pattern. The value must be immutable (use Integer, Long, Double, BigDecimal ...); a mutable Number such as AtomicInteger makes equal texts unequal later and changes what renders.
    • time

      static Arg time(String name, TemporalAccessor value)
      A date/time argument. Accepted values: Instant (shown in ZoneId.systemDefault() at render time), ZonedDateTime and OffsetDateTime (shown in their own zone or offset), LocalDateTime, LocalDate and LocalTime; any other TemporalAccessor is formatted as is. A format that needs a field the value lacks never throws (see the class documentation). The value must be immutable.
    • text

      static Arg text(String name, Text value)
      Returns deferred text, rendered in the enclosing message's locale.
    • component

      static Arg component(String name, net.kyori.adventure.text.ComponentLike value)
      Shorthand for text(name, Text.literal(value)).
    • validateName

      private static void validateName(String name)