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
All Methods Static Methods Instance Methods Concrete Methods 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 <O extends NBTComponent<O,B>,B extends NBTComponentBuilder<O,B>>
Bnbt(C context, B builder, O oldComponent)
protected <O extends BuildableComponent<O,B>,B extends ComponentBuilder<O,B>>
OoptionallyRenderChildrenAppendAndBuild(java.util.List<Component> children, B builder, C context)
protected @NotNull Component
renderBlockNbt(@NotNull BlockNBTComponent component, C context)
Renders a block NBT component.protected @NotNull Component
renderEntityNbt(@NotNull EntityNBTComponent component, C context)
Renders an entity NBT component.protected @NotNull Component
renderKeybind(@NotNull KeybindComponent component, C context)
Renders a keybind component.protected @NotNull Component
renderScore(@NotNull ScoreComponent component, C context)
Renders a score component.protected @NotNull Component
renderSelector(@NotNull SelectorComponent component, C context)
Renders a selector component.protected @NotNull Component
renderStorageNbt(@NotNull StorageNBTComponent component, C context)
Renders a storage NBT component.protected @NotNull Component
renderText(@NotNull TextComponent component, C context)
Renders a text component.protected @NotNull Component
renderTranslatable(@NotNull TranslatableComponent component, C context)
Renders a translatable component.protected @Nullable java.text.MessageFormat
translate(@NotNull java.lang.String key, @Nullable java.lang.String fallback, C context)
Gets a message format from a key, fallback string, and context.protected @Nullable java.text.MessageFormat
translate(@NotNull java.lang.String key, C context)
Gets a message format from a key and context.static @NotNull TranslatableComponentRenderer<java.util.Locale>
usingTranslationSource(@NotNull Translator source)
Creates aTranslatableComponentRenderer
using theTranslator
to translate.-
Methods inherited from class net.kyori.adventure.text.renderer.AbstractComponentRenderer
render
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.kyori.adventure.text.renderer.ComponentRenderer
mapContext
-
-
-
-
Method Detail
-
usingTranslationSource
@NotNull public static @NotNull TranslatableComponentRenderer<java.util.Locale> usingTranslationSource(@NotNull @NotNull Translator source)
Creates aTranslatableComponentRenderer
using theTranslator
to translate.Alongside the standard
MessageFormat
-based translation, this will also allow theTranslator
to create aComponent
directly
.- Parameters:
source
- the translation source- Returns:
- the renderer
- Since:
- 4.0.0
-
translate
@Nullable protected @Nullable java.text.MessageFormat translate(@NotNull @NotNull java.lang.String key, @NotNull C context)
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
-
translate
@Nullable protected @Nullable java.text.MessageFormat translate(@NotNull @NotNull java.lang.String key, @Nullable @Nullable java.lang.String fallback, @NotNull C context)
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
null
to skip translation
-
renderBlockNbt
@NotNull protected @NotNull Component renderBlockNbt(@NotNull @NotNull BlockNBTComponent component, @NotNull 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
@NotNull protected @NotNull Component renderEntityNbt(@NotNull @NotNull EntityNBTComponent component, @NotNull 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
@NotNull protected @NotNull Component renderStorageNbt(@NotNull @NotNull StorageNBTComponent component, @NotNull 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 <O extends NBTComponent<O,B>,B extends NBTComponentBuilder<O,B>> B nbt(@NotNull C context, B builder, O oldComponent)
-
renderKeybind
@NotNull protected @NotNull Component renderKeybind(@NotNull @NotNull KeybindComponent component, @NotNull 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
@NotNull protected @NotNull Component renderScore(@NotNull @NotNull ScoreComponent component, @NotNull C context)
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
@NotNull protected @NotNull Component renderSelector(@NotNull @NotNull SelectorComponent component, @NotNull 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
@NotNull protected @NotNull Component renderText(@NotNull @NotNull TextComponent component, @NotNull C context)
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
@NotNull protected @NotNull Component renderTranslatable(@NotNull @NotNull TranslatableComponent component, @NotNull 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(java.util.List<Component> children, B builder, C context)
-
mergeStyle
protected <B extends ComponentBuilder<?,?>> void mergeStyle(Component component, B builder, C context)
-
-