Interface Arg
- All Known Implementing Classes:
Arg.Localized, Arg.Moment, Arg.Numeric, Arg.Unparsed
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:
number(String, Number):<n>uses the locale's default number format;<n:'#,##0.00'>is aDecimalFormatpattern with the locale's symbols;<n:'de-DE':'#,##0.00'>names the locale explicitly (Adventure's two-argument form);<n:choice:'0#no items|1#one item|1<<n> items'>selects text with aChoiceFormatpattern, and the selected text is parsed as MiniMessage with the same arguments, so<n>inside it prints the formatted number.time(String, TemporalAccessor):<t>uses the locale's MEDIUM style for the fields the value has (date and time, date only, or time only);<t:'d MMMM yyyy'>is aDateTimeFormatterpattern applied with the render locale. AnInstantis shown in the server's default zone (ZoneId.systemDefault()at render time).string(String, String)andtext(String, Text)take no format argument.
:, <, > 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 ClassesModifier and TypeInterfaceDescriptionstatic final recordDeferred localized text.static final recordA date/time argument.static final recordA number argument.static final recordA plain-text argument. -
Method Summary
Modifier and TypeMethodDescriptionstatic ArgShorthand fortext(name, Text.literal(value)).name()Returns the tag name, matching[a-z0-9_-]+.static ArgReturns a number formatted with the target locale unless the translation specifies a pattern.static ArgReturns a literal string argument; MiniMessage tags in its value are never interpreted.static ArgReturns deferred text, rendered in the enclosing message's locale.static Argtime(String name, TemporalAccessor value) A date/time argument.private static voidvalidateName(String name)
-
Method Details
-
name
String name()Returns the tag name, matching[a-z0-9_-]+. -
string
-
number
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
A date/time argument. Accepted values:Instant(shown inZoneId.systemDefault()at render time),ZonedDateTimeandOffsetDateTime(shown in their own zone or offset),LocalDateTime,LocalDateandLocalTime; any otherTemporalAccessoris formatted as is. A format that needs a field the value lacks never throws (see the class documentation). The value must be immutable. -
text
-
component
-
validateName
-