Class ChatTypeBuilder

java.lang.Object
fr.fidorial.chat.ChatTypeBuilder

public final class ChatTypeBuilder extends Object
Fluent builder for ChatTypeDefinition.
Since:
0.1.0
  • Method Details

    • key

      @Contract("_ -> this") public ChatTypeBuilder key(Key key)
      Parameters:
      key - the namespaced identifier of the chat type
      Returns:
      this builder
    • chat

      @Contract("_ -> this") public ChatTypeBuilder chat(ChatTypeDecoration chat)
      Parameters:
      chat - how the message is shown in the chat log
      Returns:
      this builder
    • chat

      @Contract("_ -> this") public ChatTypeBuilder chat(Consumer<ChatTypeDecoration.Builder> configurer)
      Configures the chat-log decoration in place, starting from what is already set.
      Parameters:
      configurer - callback receiving a pre-filled decoration builder
      Returns:
      this builder
    • narration

      @Contract("_ -> this") public ChatTypeBuilder narration(ChatTypeDecoration narration)
      Parameters:
      narration - how the message is read out for narration/accessibility
      Returns:
      this builder
    • narration

      @Contract("_ -> this") public ChatTypeBuilder narration(Consumer<ChatTypeDecoration.Builder> configurer)
      Configures the narration decoration in place, starting from what is already set.
      Parameters:
      configurer - callback receiving a pre-filled decoration builder
      Returns:
      this builder
    • sameForBoth

      @Contract("_, _ -> this") public ChatTypeBuilder sameForBoth(String translationKey, List<String> parameters)
      Shorthand: sets both chat(ChatTypeDecoration) and narration(ChatTypeDecoration) to identical decorations built from translationKey and parameters, with no style.

      Matches vanilla's emote_command chat type, which narrates itself the same way it's shown in chat.

      Parameters:
      translationKey - the translation key used to format the message, supporting placeholders
      parameters - which named slots are substituted into the translation, in order
      Returns:
      this builder
      API Note:
      the translation key is resolved purely client-side using language files from resource packs; fallbacks to plaintext with resolved placeholders when it can't be found.
    • build

      @Contract(value="-> new", pure=true) public ChatTypeDefinition build()
      Returns the immutable definition described by this builder.
      Returns:
      the immutable definition described by this builder