Class ChatTypeBuilder
java.lang.Object
fr.fidorial.chat.ChatTypeBuilder
Fluent builder for
ChatTypeDefinition.- Since:
- 0.1.0
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Returns the immutable definition described by this builder.chat(ChatTypeDecoration chat) chat(Consumer<ChatTypeDecoration.Builder> configurer) Configures the chat-log decoration in place, starting from what is already set.narration(ChatTypeDecoration narration) narration(Consumer<ChatTypeDecoration.Builder> configurer) Configures the narration decoration in place, starting from what is already set.sameForBoth(String translationKey, List<String> parameters) Shorthand: sets bothchat(ChatTypeDecoration)andnarration(ChatTypeDecoration)to identical decorations built fromtranslationKeyandparameters, with no style.
-
Method Details
-
key
- Parameters:
key- the namespaced identifier of the chat type- Returns:
- this builder
-
chat
- Parameters:
chat- how the message is shown in the chat log- Returns:
- this builder
-
chat
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
- 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 bothchat(ChatTypeDecoration)andnarration(ChatTypeDecoration)to identical decorations built fromtranslationKeyandparameters, with no style.Matches vanilla's
emote_commandchat type, which narrates itself the same way it's shown in chat.- Parameters:
translationKey- the translation key used to format the message, supporting placeholdersparameters- 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
Returns the immutable definition described by this builder.- Returns:
- the immutable definition described by this builder
-