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 Type
    Method
    Description
    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 with Audience.forEachAudience(java.util.function.Consumer) and invokes the action once per leaf recipient with text rendered in that recipient's locale.
    boolean
    isDefined(MessageKey key, Locale locale)
    Returns whether the exact locale or its language defines the key, without fallback.
    key(String path)
    Returns MessageKey.of(namespace(), path).
    Returns this instance's module namespace, or ultitools for the framework.
    default net.kyori.adventure.text.Component
    render(MessageKey key, Locale locale, Arg... args)
    Shorthand for render(Text.of(key, args), locale).
    default net.kyori.adventure.text.Component
    render(MessageKey key, net.kyori.adventure.audience.Audience viewer, Arg... args)
    Shorthand for render(Text.of(key, args), viewer).
    net.kyori.adventure.text.Component
    render(Text text, Locale locale)
    Renders in the requested locale; never throws for a missing key or translation.
    net.kyori.adventure.text.Component
    render(Text text, net.kyori.adventure.audience.Audience viewer)
    Renders using the viewer's resolved locale.
    default void
    send(net.kyori.adventure.audience.Audience audience, MessageKey key, Arg... args)
    Shorthand for send(audience, Text.of(key, args)).
    default void
    send(net.kyori.adventure.audience.Audience audience, Text text)
    Sends chat text in each recipient's resolved locale.
    default void
    sendActionBar(net.kyori.adventure.audience.Audience audience, Text text)
    Sends action-bar text in each recipient's resolved locale.
    net.kyori.adventure.text.Component
    shared(Text text)
    Returns text for a shared object (entity name, text display or shared boss bar).
  • Method Details

    • namespace

      String namespace()
      Returns this instance's module namespace, or ultitools for the framework.
    • key

      MessageKey key(String path)
      Returns MessageKey.of(namespace(), path).
    • render

      net.kyori.adventure.text.Component render(Text text, Locale locale)
      Renders in the requested locale; never throws for a missing key or translation.
    • render

      net.kyori.adventure.text.Component render(Text text, net.kyori.adventure.audience.Audience viewer)
      Renders using the viewer's resolved locale.
    • render

      default net.kyori.adventure.text.Component render(MessageKey key, Locale locale, Arg... args)
      Shorthand for render(Text.of(key, args), locale).
    • render

      default net.kyori.adventure.text.Component render(MessageKey key, net.kyori.adventure.audience.Audience viewer, Arg... args)
      Shorthand for render(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 with Audience.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

      default void send(net.kyori.adventure.audience.Audience audience, Text text)
      Sends chat text in each recipient's resolved locale.
    • send

      default void send(net.kyori.adventure.audience.Audience audience, MessageKey key, Arg... args)
      Shorthand for send(audience, Text.of(key, args)).
    • sendActionBar

      default void sendActionBar(net.kyori.adventure.audience.Audience audience, Text text)
      Sends action-bar text in each recipient's resolved locale.
    • shared

      net.kyori.adventure.text.Component shared(Text text)
      Returns text for a shared object (entity name, text display or shared boss bar). In auto mode a translated text becomes a translatable component for Paper's per-client rendering; in forced mode it is rendered server-side in the forced locale. Per-player overrides cannot apply to shared objects. Literal text remains literal. In auto mode the translatable component's fallback is the plain text rendered under LocaleResolver.fallback(), with arguments formatted in that fallback locale.
    • isDefined

      boolean isDefined(MessageKey key, Locale locale)
      Returns whether the exact locale or its language defines the key, without fallback.