Module net.kyori.adventure.api
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>
A component renderer that does server-side translation rendering.
- Since:
- 4.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new translatable component renderer. -
Method Summary
Modifier and TypeMethodDescriptionprotected <B extends ComponentBuilder<?,?>>
voidmergeStyle(Component component, B builder, C context) protected <O extends Component,B extends ComponentBuilder<O, B>>
OmergeStyleAndOptionallyDeepRender(Component component, B builder, C context) protected <O extends NBTComponent<O>,B extends NBTComponentBuilder<O, B>>
Bprotected ComponentoptionallyRenderChildrenAndStyle(Component component, C context) protected <O extends Component,B extends ComponentBuilder<O, B>>
OoptionallyRenderChildrenAppendAndBuild(List<Component> children, B builder, C context) protected ComponentrenderBlockNbt(BlockNBTComponent component, C context) Renders a block NBT component.protected ComponentrenderEntityNbt(EntityNBTComponent component, C context) Renders an entity NBT component.protected ComponentrenderKeybind(KeybindComponent component, C context) Renders a keybind component.protected ComponentrenderObject(ObjectComponent component, C context) Renders an object component.protected ComponentrenderScore(ScoreComponent component, C context) Renders a score component.protected ComponentrenderSelector(SelectorComponent component, C context) Renders a selector component.protected ComponentrenderStorageNbt(StorageNBTComponent component, C context) Renders a storage NBT component.protected ComponentrenderText(TextComponent component, C context) Renders a text component.protected ComponentrenderTranslatable(TranslatableComponent component, C context) Renders a translatable component.protected ComponentrenderTranslatableInner(TranslatableComponent component, C context) protected @Nullable MessageFormatGets a message format from a key and context.protected @Nullable MessageFormatGets a message format from a key, fallback string, and context.static TranslatableComponentRenderer<Locale> usingTranslationSource(Translator source) Creates aTranslatableComponentRendererusing theTranslatorto translate.Methods inherited from class net.kyori.adventure.text.renderer.AbstractComponentRenderer
render, render, renderVirtualMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.kyori.adventure.text.renderer.ComponentRenderer
mapContext
-
Constructor Details
-
TranslatableComponentRenderer
public TranslatableComponentRenderer()Constructs a new translatable component renderer.- Since:
- 4.0.0
-
-
Method Details
-
usingTranslationSource
Creates aTranslatableComponentRendererusing theTranslatorto translate.Alongside the standard
MessageFormat-based translation, this will also allow theTranslatorto create aComponentdirectly.- 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
nullto skip translation
-
translate
Gets a message format from a key, fallback string, and context.- Parameters:
key- a translation keyfallback- the fallback stringcontext- a context- Returns:
- a message format or
nullto skip translation
-
renderBlockNbt
Description copied from class:AbstractComponentRendererRenders a block NBT component.- Specified by:
renderBlockNbtin classAbstractComponentRenderer<C>- Parameters:
component- the componentcontext- the context- Returns:
- the rendered component
-
renderEntityNbt
Description copied from class:AbstractComponentRendererRenders an entity NBT component.- Specified by:
renderEntityNbtin classAbstractComponentRenderer<C>- Parameters:
component- the componentcontext- the context- Returns:
- the rendered component
-
renderStorageNbt
Description copied from class:AbstractComponentRendererRenders a storage NBT component.- Specified by:
renderStorageNbtin classAbstractComponentRenderer<C>- Parameters:
component- the componentcontext- the context- Returns:
- the rendered component
-
nbt
protected <O extends NBTComponent<O>,B extends NBTComponentBuilder<O, B nbtB>> (C context, B builder, O oldComponent) -
renderKeybind
Description copied from class:AbstractComponentRendererRenders a keybind component.- Specified by:
renderKeybindin classAbstractComponentRenderer<C>- Parameters:
component- the componentcontext- the context- Returns:
- the rendered component
-
renderScore
Description copied from class:AbstractComponentRendererRenders a score component.- Specified by:
renderScorein classAbstractComponentRenderer<C>- Parameters:
component- the componentcontext- the context- Returns:
- the rendered component
-
renderSelector
Description copied from class:AbstractComponentRendererRenders a selector component.- Specified by:
renderSelectorin classAbstractComponentRenderer<C>- Parameters:
component- the componentcontext- the context- Returns:
- the rendered component
-
renderText
Description copied from class:AbstractComponentRendererRenders a text component.- Specified by:
renderTextin classAbstractComponentRenderer<C>- Parameters:
component- the componentcontext- the context- Returns:
- the rendered component
-
renderObject
Description copied from class:AbstractComponentRendererRenders an object component.- Specified by:
renderObjectin classAbstractComponentRenderer<C>- Parameters:
component- the componentcontext- the context- Returns:
- the rendered component
-
renderTranslatable
Description copied from class:AbstractComponentRendererRenders a translatable component.- Specified by:
renderTranslatablein classAbstractComponentRenderer<C>- Parameters:
component- the componentcontext- the context- Returns:
- the rendered component
-
renderTranslatableInner
-
optionallyRenderChildrenAndStyle
-
mergeStyleAndOptionallyDeepRender
protected <O extends Component,B extends ComponentBuilder<O, O mergeStyleAndOptionallyDeepRenderB>> (Component component, B builder, C context) -
optionallyRenderChildrenAppendAndBuild
protected <O extends Component,B extends ComponentBuilder<O, O optionallyRenderChildrenAppendAndBuildB>> (List<Component> children, B builder, C context) -
mergeStyle
protected <B extends ComponentBuilder<?,?>> void mergeStyle(Component component, B builder, C context)
-