Interface VersionedComponent
This wrapper facilitates sending this wrapped component despite server version differences. (See
sendTo(CommandSender))On older servers, it likely sends via BaseComponents, while on newer servers it can use the native adventure api.
This wrapper attempts to use the native adventure api on newer servers, but falls back to using an internal shaded copy of adventure if the server does not support it natively.
-
Method Summary
Modifier and TypeMethodDescription@NotNull VersionedComponentappend(@NotNull VersionedComponent other) Appends another VersionedComponent to this one, returning a new instance.
The original instances are not modified.default @NotNull VersionedComponentclick(@NotNull ClickAction action, @NotNull String value) Returns a copy of this component with a click behaviour attached.@NotNull InventorycreateInventory(@NotNull InventoryHolder owner, int size) Create a new menu with the current message as the title, other arguments are passed as normal.@NotNull InventorycreateInventory(@NotNull InventoryHolder owner, @NotNull InventoryType type) Create a new menu with the current message as the title, other arguments are passed as normal.default @NotNull VersionedComponentdecorate(@NotNull TextDecoration decoration, boolean value) Returns a copy of this component with a style flag explicitly set.default @NotNull VersionedComponenthover(@NotNull VersionedComponent tooltip) Returns a copy of this component with hover text attached.default @NotNull VersionedComponentReturns a copy of this component whose hover shows the given item, with its name, lore and enchantments as a player would see them in an inventory.default @NotNull StringDeprecated.default voidsendTo(@NotNull Collection<CommandSender> senders) Sends the current message component to multiple senders.voidsendTo(@NotNull CommandSender sender) Sends the current message component to a sender.default voidsendTo(@NotNull CommandSender... senders) Sends the current message component to multiple senders.@NotNull StringSerializes to the JSON representation Minecraft itself uses for components.@NotNull StringSerializes the current message component to a string formatted using legacy ampersand (&) color codes.@NotNull StringSerializes the current message component to a string formatted using legacy section (§) color codes.@NotNull StringSerializes the current message component to a MiniMessage string.@NotNull StringSerializes the current message component to a plain text string using the PlainTextComponentSerializer on the current platform.
-
Method Details
-
sendTo
Sends the current message component to a sender. -
serializeMiniMessage
Serializes the current message component to a MiniMessage string. -
serializePlainText
Serializes the current message component to a plain text string using the PlainTextComponentSerializer on the current platform. -
serializeLegacyAmpersand
Serializes the current message component to a string formatted using legacy ampersand (&) color codes. -
serializeLegacySection
Serializes the current message component to a string formatted using legacy section (§) color codes. -
plainText
Deprecated.Replace withserializePlainText().Serializes the current message component to a plain text string using the PlainTextComponentSerializer on the current platform. -
createInventory
Create a new menu with the current message as the title, other arguments are passed as normal.- Parameters:
owner- The inventory holder for this inventory. (inherited from Bukkit.createInventory)size- The size of the inventory. (inherited from Bukkit.createInventory)
-
createInventory
@NotNull @NotNull Inventory createInventory(@NotNull @NotNull InventoryHolder owner, @NotNull @NotNull InventoryType type) Create a new menu with the current message as the title, other arguments are passed as normal.- Parameters:
owner- The inventory holder for this inventory. (inherited from Bukkit.createInventory)type- The type of the inventory. (inherited from Bukkit.createInventory)
-
serializeJson
Serializes to the JSON representation Minecraft itself uses for components.This replaced
asInternalComponent(), removed 2026-08-30. That method handed back the relocated Adventure component, and once the relocated package is hidden from consumers it was unusable by construction: a caller cannot name the type, cannot declare a variable for it, and cannot cast it to anything. Assuming it is the server's own Adventure is wrong even on modern versions, because it is the shaded copy.JSON and MiniMessage carry the same information in a form callers can actually hold. On 1.21.4 and up,
ModernVersionedComponent#asNativeComponent()returns the server's real Adventure component, which is nameable and is the right escape hatch there. -
append
Appends another VersionedComponent to this one, returning a new instance.
The original instances are not modified. -
click
@NotNull default @NotNull VersionedComponent click(@NotNull @NotNull ClickAction action, @NotNull @NotNull String value) Returns a copy of this component with a click behaviour attached.Use this rather than reaching for Adventure directly to call its
clickEvent. Anything outside theversions/*modules that names the shaded Adventure copy pins it onto every server, including the modern ones that have Adventure natively and do not need it.- Parameters:
action- what the click doesvalue- the command or URL the action applies to, without a leading slash for commands- Throws:
UnsupportedOperationException- if this server version cannot express the action; seeClickAction.COPY_TO_CLIPBOARD
-
hover
Returns a copy of this component with hover text attached.- Parameters:
tooltip- the component shown on hover
-
hoverItem
Returns a copy of this component whose hover shows the given item, with its name, lore and enchantments as a player would see them in an inventory.Supported on every version from 1.8. Servers from 1.18.2 build the hover from their own Adventure; below that the item's id, count and
tagcompound are read from NMS and assembled into the same hover.On 1.8 through 1.12 the hover carries the item's
tagcompound, so the name, lore and enchantments survive while the top-levelDamagefield does not. An item whose variant or durability lives inDamage, such as coloured wool or a worn tool, therefore hovers as the undamaged base item. This is the shape of Adventure's item hover, which holds an id, a count and a tag and has nowhere to putDamage. From 1.13 onward the variant is part of the id and durability moved intotag, so nothing is lost.- Parameters:
item- the item shown on hover- Throws:
IllegalArgumentException- if the item is air, which has no item to show
-
decorate
@NotNull default @NotNull VersionedComponent decorate(@NotNull @NotNull TextDecoration decoration, boolean value) Returns a copy of this component with a style flag explicitly set.Minecraft italicises custom item names and lore by default, and this library suppresses that where the caller left italic unset, so no call is needed before writing a component into
ItemMeta. PassITALICwithtrueto ask for italics there anyway. -
sendTo
Sends the current message component to multiple senders. -
sendTo
Sends the current message component to multiple senders.
-
serializePlainText().