Interface Messages
- All Known Implementing Classes:
ModuleMessages
@NonExtendable
public interface Messages
Thread-safe message rendering, callable from any thread. Modules and external plugins with
bundled catalogues receive a view bound to their own namespace. External plugins without a
bundled catalogue inherit the framework instance without a namespace guarantee. All views can
render explicit keys from any published namespace.
Lookup order: requested exactly, requested language; fallback() exactly, fallback() language;
source language exactly, source language's language; then the key itself. Each candidate is tried
exactly and then by language only; a candidate equal to an earlier one is skipped.
An absent catalogue or key never throws and logs one WARNING per (key, requested locale) pair.
For argument formatting syntax: see Arg.
-
Method Summary
Modifier and TypeMethodDescriptionvoidforEachRecipient(net.kyori.adventure.audience.Audience audience, Text text, BiConsumer<? super net.kyori.adventure.audience.Audience, ? super net.kyori.adventure.text.Component> action) Expands a forwarding audience withAudience.forEachAudience(java.util.function.Consumer)and invokes the action once per leaf recipient with text rendered in that recipient's locale.booleanisDefined(MessageKey key, Locale locale) Returns whether the exact locale or its language defines the key, without fallback.ReturnsMessageKey.of(namespace(), path).Returns this instance's module namespace, orultitoolsfor the framework.default net.kyori.adventure.text.Componentrender(MessageKey key, Locale locale, Arg... args) Shorthand forrender(Text.of(key, args), locale).default net.kyori.adventure.text.Componentrender(MessageKey key, net.kyori.adventure.audience.Audience viewer, Arg... args) Shorthand forrender(Text.of(key, args), viewer).net.kyori.adventure.text.ComponentRenders in the requested locale; never throws for a missing key or translation.net.kyori.adventure.text.ComponentRenders using the viewer'sresolved locale.default voidsend(net.kyori.adventure.audience.Audience audience, MessageKey key, Arg... args) Shorthand forsend(audience, Text.of(key, args)).default voidSends chat text in each recipient's resolved locale.default voidsendActionBar(net.kyori.adventure.audience.Audience audience, Text text) Sends action-bar text in each recipient's resolved locale.net.kyori.adventure.text.ComponentReturns text for a shared object (entity name, text display or shared boss bar).
-
Method Details
-
namespace
String namespace()Returns this instance's module namespace, orultitoolsfor the framework. -
key
ReturnsMessageKey.of(namespace(), path). -
render
-
render
Renders using the viewer'sresolved locale. -
render
Shorthand forrender(Text.of(key, args), locale). -
render
default net.kyori.adventure.text.Component render(MessageKey key, net.kyori.adventure.audience.Audience viewer, Arg... args) Shorthand forrender(Text.of(key, args), viewer). -
forEachRecipient
void forEachRecipient(net.kyori.adventure.audience.Audience audience, Text text, BiConsumer<? super net.kyori.adventure.audience.Audience, ? super net.kyori.adventure.text.Component> action) Expands a forwarding audience withAudience.forEachAudience(java.util.function.Consumer)and invokes the action once per leaf recipient with text rendered in that recipient's locale. Never invokes the action for the forwarding audience itself. Expanding the server audience is safe from any thread: Paper iterates a copy-on-write snapshot of the online players, so a player who joins during the call may be skipped and one who quits during the call may still be passed to the action, where sending is a no-op. -
send
Sends chat text in each recipient's resolved locale. -
send
Shorthand forsend(audience, Text.of(key, args)). -
sendActionBar
Sends action-bar text in each recipient's resolved locale. -
isDefined
Returns whether the exact locale or its language defines the key, without fallback.
-