Class TranslatableComponentRenderer<C>
java.lang.Object
net.kyori.adventure.text.renderer.AbstractComponentRenderer<C>
net.kyori.adventure.text.renderer.TranslatableComponentRenderer<C>
- Type Parameters:
C
- the context type, usuallyLocale
.
- All Implemented Interfaces:
ComponentRenderer<C>
public abstract class TranslatableComponentRenderer<C> extends AbstractComponentRenderer<C>
A component renderer that does server-side translation rendering.
- Since:
- 4.0.0
-
Constructor Summary
Constructors Constructor Description TranslatableComponentRenderer()
-
Method Summary
Modifier and Type Method Description protected <B extends ComponentBuilder<?, ?>>
voidmergeStyle(Component component, B builder, C context)
protected <O extends BuildableComponent<O, B>, B extends ComponentBuilder<O, B>>
OmergeStyleAndOptionallyDeepRender(Component component, B builder, C context)
protected static <C extends NBTComponent<C, B>, B extends NBTComponentBuilder<C, B>>
Bnbt(B builder, C oldComponent)
protected <O extends BuildableComponent<O, B>, B extends ComponentBuilder<O, B>>
OoptionallyRenderChildrenAppendAndBuild(List<Component> children, B builder, C context)
protected @NonNull Component
renderBlockNbt(@NonNull BlockNBTComponent component, @NonNull C context)
Renders a block NBT component.protected @NonNull Component
renderEntityNbt(@NonNull EntityNBTComponent component, @NonNull C context)
Renders an entity NBT component.protected @NonNull Component
renderKeybind(@NonNull KeybindComponent component, @NonNull C context)
Renders a keybind component.protected @NonNull Component
renderScore(@NonNull ScoreComponent component, @NonNull C context)
Renders a score component.protected @NonNull Component
renderSelector(@NonNull SelectorComponent component, @NonNull C context)
Renders a selector component.protected @NonNull Component
renderStorageNbt(@NonNull StorageNBTComponent component, @NonNull C context)
Renders a storage NBT component.protected @NonNull Component
renderText(@NonNull TextComponent component, @NonNull C context)
Renders a text component.protected @NonNull Component
renderTranslatable(@NonNull TranslatableComponent component, @NonNull C context)
Renders a translatable component.protected abstract @Nullable MessageFormat
translate(@NonNull String key, @NonNull C context)
Gets a message format from a key and context.static @NonNull TranslatableComponentRenderer<Locale>
usingTranslationSource(@NonNull Translator source)
Creates aTranslatableComponentRenderer
using theTranslator
to translate.
-
Constructor Details
-
TranslatableComponentRenderer
public TranslatableComponentRenderer()
-
-
Method Details
-
usingTranslationSource
public static @NonNull TranslatableComponentRenderer<Locale> usingTranslationSource(@NonNull Translator source)Creates aTranslatableComponentRenderer
using theTranslator
to translate.- Parameters:
source
- the translation source- Returns:
- the renderer
- Since:
- 4.0.0
-
translate
Gets a message format from a key and context.- Parameters:
key
- a translation keycontext
- a context- Returns:
- a message format or
null
to skip translation
-
renderBlockNbt
protected @NonNull Component renderBlockNbt(@NonNull BlockNBTComponent component, @NonNull C context)Description copied from class:AbstractComponentRenderer
Renders a block NBT component.- Specified by:
renderBlockNbt
in classAbstractComponentRenderer<C>
- Parameters:
component
- the componentcontext
- the context- Returns:
- the rendered component
-
renderEntityNbt
protected @NonNull Component renderEntityNbt(@NonNull EntityNBTComponent component, @NonNull C context)Description copied from class:AbstractComponentRenderer
Renders an entity NBT component.- Specified by:
renderEntityNbt
in classAbstractComponentRenderer<C>
- Parameters:
component
- the componentcontext
- the context- Returns:
- the rendered component
-
renderStorageNbt
protected @NonNull Component renderStorageNbt(@NonNull StorageNBTComponent component, @NonNull C context)Description copied from class:AbstractComponentRenderer
Renders a storage NBT component.- Specified by:
renderStorageNbt
in classAbstractComponentRenderer<C>
- Parameters:
component
- the componentcontext
- the context- Returns:
- the rendered component
-
nbt
protected static <C extends NBTComponent<C, B>, B extends NBTComponentBuilder<C, B>> B nbt(B builder, C oldComponent) -
renderKeybind
protected @NonNull Component renderKeybind(@NonNull KeybindComponent component, @NonNull C context)Description copied from class:AbstractComponentRenderer
Renders a keybind component.- Specified by:
renderKeybind
in classAbstractComponentRenderer<C>
- Parameters:
component
- the componentcontext
- the context- Returns:
- the rendered component
-
renderScore
Description copied from class:AbstractComponentRenderer
Renders a score component.- Specified by:
renderScore
in classAbstractComponentRenderer<C>
- Parameters:
component
- the componentcontext
- the context- Returns:
- the rendered component
-
renderSelector
protected @NonNull Component renderSelector(@NonNull SelectorComponent component, @NonNull C context)Description copied from class:AbstractComponentRenderer
Renders a selector component.- Specified by:
renderSelector
in classAbstractComponentRenderer<C>
- Parameters:
component
- the componentcontext
- the context- Returns:
- the rendered component
-
renderText
Description copied from class:AbstractComponentRenderer
Renders a text component.- Specified by:
renderText
in classAbstractComponentRenderer<C>
- Parameters:
component
- the componentcontext
- the context- Returns:
- the rendered component
-
renderTranslatable
protected @NonNull Component renderTranslatable(@NonNull TranslatableComponent component, @NonNull C context)Description copied from class:AbstractComponentRenderer
Renders a translatable component.- Specified by:
renderTranslatable
in classAbstractComponentRenderer<C>
- Parameters:
component
- the componentcontext
- the context- Returns:
- the rendered component
-
mergeStyleAndOptionallyDeepRender
protected <O extends BuildableComponent<O, B>, B extends ComponentBuilder<O, B>> O mergeStyleAndOptionallyDeepRender(Component component, B builder, C context) -
optionallyRenderChildrenAppendAndBuild
protected <O extends BuildableComponent<O, B>, B extends ComponentBuilder<O, B>> O optionallyRenderChildrenAppendAndBuild(List<Component> children, B builder, C context) -
mergeStyle
protected <B extends ComponentBuilder<?, ?>> void mergeStyle(Component component, B builder, C context)
-