Module net.kyori.adventure.api
Package net.kyori.adventure.text
Interface NBTComponent<C extends NBTComponent<C>>
- Type Parameters:
C- component type
- All Superinterfaces:
Buildable<NBTComponentBuilder<C,,?>> BuildableComponent<C,,NBTComponentBuilder<C, ?>> Component,ComponentBuilderApplicable,ComponentLike,HoverEventSource<Component>,StyleGetter,StyleSetter<Component>
- All Known Subinterfaces:
BlockNBTComponent,EntityNBTComponent,StorageNBTComponent
public sealed interface NBTComponent<C extends NBTComponent<C>>
extends BuildableComponent<C,NBTComponentBuilder<C,?>>
permits BlockNBTComponent, EntityNBTComponent, StorageNBTComponent
A component that can display NBT fetched from different locations, optionally trying to interpret the NBT as JSON
using the
net.kyori.adventure.text.serializer.gson.GsonComponentSerializer to convert the JSON to a Component.
Sending interpreted NBT to the chat would be similar to using /tellraw.
This component consists of:
- nbtPath
- a path to specify which parts of the nbt you want displayed(examples).
- interpret
- a boolean telling adventure if the fetched NBT value should be parsed as JSON
- plain
- a boolean telling adventure if the fetched NBT value should be pretty-printed without styling
This component is rendered serverside and can therefore receive platform-defined context. See the documentation for your respective platform for more info
- Since:
- 4.0.0
- Since Minecraft:
- 1.14
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanThe default value forinterpret().static final booleanThe default value forplain().Fields inherited from interface net.kyori.adventure.text.Component
EQUALS, EQUALS_IDENTITY, IS_NOT_EMPTY -
Method Summary
Modifier and TypeMethodDescriptionbooleanGets if we should be interpreting.interpret(boolean interpret) Sets if we should be interpreting.nbtPath()Gets the NBT path.Sets the NBT path.booleanplain()Gets if styling should be removed from pretty-printed NBT.plain(boolean plain) Sets if styling should be removed from pretty-printed NBT.@Nullable ComponentGets the separator.separator(@Nullable ComponentLike separator) Sets the separator.NBTComponentBuilder<C, ? extends NBTComponentBuilder<C, ?>> Create a builder from this component.Methods inherited from interface net.kyori.adventure.text.Component
append, append, append, append, append, appendNewline, appendSpace, applyFallbackStyle, applyFallbackStyle, asComponent, asHoverEvent, children, children, clickEvent, clickEvent, color, color, colorIfAbsent, compact, compact, componentBuilderApply, contains, contains, decorate, decoration, decoration, decoration, decorationIfAbsent, decorations, decorations, font, font, hasDecoration, hasStyling, hoverEvent, hoverEvent, insertion, insertion, iterable, iterable, iterator, iterator, mergeStyle, mergeStyle, mergeStyle, replaceText, replaceText, shadowColor, shadowColor, shadowColorIfAbsent, spliterator, spliterator, style, style, style, style, styleMethods inherited from interface net.kyori.adventure.text.event.HoverEventSource
asHoverEventMethods inherited from interface net.kyori.adventure.text.format.StyleSetter
decorate, decorations
-
Field Details
-
INTERPRET_DEFAULT
static final boolean INTERPRET_DEFAULTThe default value forinterpret().- Since:
- 5.0.0
- See Also:
-
PLAIN_DEFAULT
static final boolean PLAIN_DEFAULTThe default value forplain().- Since:
- 5.0.0
- See Also:
-
-
Method Details
-
nbtPath
String nbtPath()Gets the NBT path.- Returns:
- the NBT path
- Since:
- 4.0.0
-
nbtPath
Sets the NBT path.- Parameters:
nbtPath- the NBT path- Returns:
- an NBT component
- Since:
- 4.0.0
-
interpret
boolean interpret()Gets if we should be interpreting.This cannot be
trueifplain()is alsotrue.- Returns:
- if we should be interpreting
- Since:
- 4.0.0
-
interpret
Sets if we should be interpreting.This cannot be
trueifplain()is alsotrue.- Parameters:
interpret- if we should be interpreting.- Returns:
- an NBT component
- Throws:
IllegalArgumentException- if set totrueandplain()is alsotrue- Since:
- 4.0.0
-
separator
@Nullable Component separator()Gets the separator.- Returns:
- the separator
- Since:
- 4.8.0
-
separator
Sets the separator.- Parameters:
separator- the separator- Returns:
- an NBT component
- Since:
- 4.8.0
-
plain
boolean plain()Gets if styling should be removed from pretty-printed NBT.This cannot be
trueifinterpret()is alsotrue.- Returns:
- if styling should be removed when pretty-printed
- Since:
- 5.0.0
- Since Minecraft:
- 26.1
-
plain
Sets if styling should be removed from pretty-printed NBT.This cannot be
trueifinterpret()is alsotrue.- Parameters:
plain- if styling should be removed when pretty-printed- Returns:
- an NBT component
- Throws:
IllegalArgumentException- if set totrueandinterpret()is alsotrue- Since:
- 5.0.0
- Since Minecraft:
- 26.1
-
toBuilder
NBTComponentBuilder<C,? extends NBTComponentBuilder<C, toBuilder()?>> Description copied from interface:BuildableComponentCreate a builder from this component.- Specified by:
toBuilderin interfaceBuildable<C extends NBTComponent<C>>- Specified by:
toBuilderin interfaceBuildableComponent<C extends NBTComponent<C>,NBTComponentBuilder<C extends NBTComponent<C>, ?>> - Specified by:
toBuilderin interfaceComponent- Returns:
- the builder
-