Interface VersionedComponent


public interface VersionedComponent
A multi-version wrapper that supports Kyori Adventure Components and the MiniMessage format.

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 Type
    Method
    Description
    append(@NotNull VersionedComponent other)
    Appends another VersionedComponent to this one, returning a new instance.
    The original instances are not modified.
    @NotNull com.kamikazejam.kamicommon.nms.text.kyori.adventure.text.Component
    Fetches (or Creates) an instance of the internal adventure Component

    Advanced users may use this in order to interact with advanced Adventure component APIs that are shaded.
    @NotNull Inventory
    createInventory(@NotNull InventoryHolder owner, int size)
    Create a new menu with the current message as the title, other arguments are passed as normal.
    @NotNull Inventory
    createInventory(@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 String
    Deprecated.
    Replace with serializePlainText().
    default void
    sendTo(@NotNull Collection<CommandSender> senders)
    Sends the current message component to multiple senders.
    void
    sendTo(@NotNull CommandSender sender)
    Sends the current message component to a sender.
    default void
    sendTo(@NotNull CommandSender... senders)
    Sends the current message component to multiple senders.
    @NotNull String
    Serializes the current message component to a string formatted using legacy ampersand (&) color codes.
    @NotNull String
    Serializes the current message component to a string formatted using legacy section (§) color codes.
    @NotNull String
    Serializes the current message component to a MiniMessage string.
    @NotNull String
    Serializes the current message component to a plain text string using the PlainTextComponentSerializer on the current platform.
  • Method Details

    • sendTo

      void sendTo(@NotNull @NotNull CommandSender sender)
      Sends the current message component to a sender.
    • serializeMiniMessage

      @NotNull @NotNull String serializeMiniMessage()
      Serializes the current message component to a MiniMessage string.
    • serializePlainText

      @NotNull @NotNull String serializePlainText()
      Serializes the current message component to a plain text string using the PlainTextComponentSerializer on the current platform.
    • serializeLegacyAmpersand

      @NotNull @NotNull String serializeLegacyAmpersand()
      Serializes the current message component to a string formatted using legacy ampersand (&) color codes.
    • serializeLegacySection

      @NotNull @NotNull String serializeLegacySection()
      Serializes the current message component to a string formatted using legacy section (§) color codes.
    • plainText

      @Deprecated @NotNull default @NotNull String plainText()
      Deprecated.
      Replace with serializePlainText().
      Serializes the current message component to a plain text string using the PlainTextComponentSerializer on the current platform.
    • createInventory

      @NotNull @NotNull Inventory createInventory(@NotNull @NotNull InventoryHolder owner, int size)
      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)
    • asInternalComponent

      @NotNull @NotNull com.kamikazejam.kamicommon.nms.text.kyori.adventure.text.Component asInternalComponent()
      Fetches (or Creates) an instance of the internal adventure Component

      Advanced users may use this in order to interact with advanced Adventure component APIs that are shaded.
    • append

      @NotNull @NotNull VersionedComponent append(@NotNull @NotNull VersionedComponent other)
      Appends another VersionedComponent to this one, returning a new instance.
      The original instances are not modified.
    • sendTo

      default void sendTo(@NotNull @NotNull CommandSender... senders)
      Sends the current message component to multiple senders.
    • sendTo

      default void sendTo(@NotNull @NotNull Collection<CommandSender> senders)
      Sends the current message component to multiple senders.