Class HoverEvent<V>

java.lang.Object
net.kyori.adventure.text.event.HoverEvent<V>
Type Parameters:
V - the value type
All Implemented Interfaces:
ComponentBuilderApplicable, HoverEventSource<V>, StyleBuilderApplicable, net.kyori.examination.Examinable

public final class HoverEvent<V>
extends Object
implements net.kyori.examination.Examinable, HoverEventSource<V>, StyleBuilderApplicable
A hover event.

A hover event displays a component when hovered over by a mouse on the client.

Since:
4.0.0
  • Method Details

    • showText

      @NotNull public static @NotNull HoverEvent<Component> showText​(@NotNull @NotNull ComponentLike text)
      Creates a hover event that shows text on hover.
      Parameters:
      text - the text to show on hover
      Returns:
      a hover event
      Since:
      4.2.0
    • showText

      @NotNull public static @NotNull HoverEvent<Component> showText​(@NotNull @NotNull Component text)
      Creates a hover event that shows text on hover.
      Parameters:
      text - the text to show on hover
      Returns:
      a hover event
      Since:
      4.0.0
    • showItem

      @NotNull public static @NotNull HoverEvent<HoverEvent.ShowItem> showItem​(@NotNull @NotNull net.kyori.adventure.key.Key item, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int count)
      Creates a hover event that shows an item on hover.
      Parameters:
      item - the item
      count - the count
      Returns:
      a hover event
      Since:
      4.0.0
    • showItem

      @NotNull public static @NotNull HoverEvent<HoverEvent.ShowItem> showItem​(@NotNull @NotNull net.kyori.adventure.key.Keyed item, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int count)
      Creates a hover event that shows an item on hover.
      Parameters:
      item - the item
      count - the count
      Returns:
      a hover event
      Since:
      4.6.0
    • showItem

      @NotNull public static @NotNull HoverEvent<HoverEvent.ShowItem> showItem​(@NotNull @NotNull net.kyori.adventure.key.Key item, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int count, @Nullable @Nullable BinaryTagHolder nbt)
      Creates a hover event that shows an item on hover.
      Parameters:
      item - the item
      count - the count
      nbt - the nbt
      Returns:
      a hover event
      Since:
      4.0.0
    • showItem

      @NotNull public static @NotNull HoverEvent<HoverEvent.ShowItem> showItem​(@NotNull @NotNull net.kyori.adventure.key.Keyed item, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int count, @Nullable @Nullable BinaryTagHolder nbt)
      Creates a hover event that shows an item on hover.
      Parameters:
      item - the item
      count - the count
      nbt - the nbt
      Returns:
      a hover event
      Since:
      4.6.0
    • showItem

      @NotNull public static @NotNull HoverEvent<HoverEvent.ShowItem> showItem​(@NotNull @NotNull HoverEvent.ShowItem item)
      Creates a hover event that shows an item on hover.
      Parameters:
      item - the item to show on hover
      Returns:
      a hover event
      Since:
      4.0.0
    • showEntity

      @NotNull public static @NotNull HoverEvent<HoverEvent.ShowEntity> showEntity​(@NotNull @NotNull net.kyori.adventure.key.Key type, @NotNull @NotNull UUID id)
      Creates a hover event that show information about an entity on hover.

      In the official Minecraft: Java Edition client, no information will be shown unless the "Advanced tooltips" debug option is enabled.

      Parameters:
      type - the type
      id - the id
      Returns:
      a ShowEntity
      Since:
      4.0.0
    • showEntity

      @NotNull public static @NotNull HoverEvent<HoverEvent.ShowEntity> showEntity​(@NotNull @NotNull net.kyori.adventure.key.Keyed type, @NotNull @NotNull UUID id)
      Creates a hover event that show information about an entity on hover.

      In the official Minecraft: Java Edition client, no information will be shown unless the "Advanced tooltips" debug option is enabled.

      Parameters:
      type - the type
      id - the id
      Returns:
      a ShowEntity
      Since:
      4.6.0
    • showEntity

      @NotNull public static @NotNull HoverEvent<HoverEvent.ShowEntity> showEntity​(@NotNull @NotNull net.kyori.adventure.key.Key type, @NotNull @NotNull UUID id, @Nullable @Nullable Component name)
      Creates a hover event that show information about an entity on hover.

      In the official Minecraft: Java Edition client, no information will be shown unless the "Advanced tooltips" debug option is enabled.

      Parameters:
      type - the type
      id - the id
      name - the name
      Returns:
      a ShowEntity
      Since:
      4.0.0
    • showEntity

      @NotNull public static @NotNull HoverEvent<HoverEvent.ShowEntity> showEntity​(@NotNull @NotNull net.kyori.adventure.key.Keyed type, @NotNull @NotNull UUID id, @Nullable @Nullable Component name)
      Creates a hover event that show information about an entity on hover.

      In the official Minecraft: Java Edition client, no information will be shown unless the "Advanced tooltips" debug option is enabled.

      Parameters:
      type - the type
      id - the id
      name - the name
      Returns:
      a ShowEntity
      Since:
      4.6.0
    • showEntity

      @NotNull public static @NotNull HoverEvent<HoverEvent.ShowEntity> showEntity​(@NotNull @NotNull HoverEvent.ShowEntity entity)
      Creates a hover event that show information about an entity on hover.

      In the official Minecraft: Java Edition client, no information will be shown unless the "Advanced tooltips" debug option is enabled.

      Parameters:
      entity - the entity to show on hover
      Returns:
      a hover event
      Since:
      4.0.0
    • hoverEvent

      @NotNull public static <V> @NotNull HoverEvent<V> hoverEvent​(@NotNull @NotNull HoverEvent.Action<V> action, @NotNull V value)
      Creates a hover event.
      Type Parameters:
      V - the value type
      Parameters:
      action - the action
      value - the value
      Returns:
      a click event
      Since:
      4.0.0
    • action

      @NotNull public @NotNull HoverEvent.Action<V> action()
      Gets the hover event action.
      Returns:
      the hover event action
      Since:
      4.0.0
    • value

      @NotNull public V value()
      Gets the hover event value.
      Returns:
      the hover event value
      Since:
      4.0.0
    • value

      @NotNull public @NotNull HoverEvent<V> value​(@NotNull V value)
      Sets the hover event value.
      Parameters:
      value - the hover event value
      Returns:
      a hover event
      Since:
      4.0.0
    • withRenderedValue

      @NotNull public <C> @NotNull HoverEvent<V> withRenderedValue​(@NotNull @NotNull ComponentRenderer<C> renderer, @NotNull C context)
      Returns a hover event with the value rendered using renderer when possible.
      Type Parameters:
      C - the context type
      Parameters:
      renderer - the renderer
      context - the render context
      Returns:
      a hover event
      Since:
      4.0.0
    • asHoverEvent

      @NotNull public @NotNull HoverEvent<V> asHoverEvent()
      Description copied from interface: HoverEventSource
      Represent this object as a hover event.
      Specified by:
      asHoverEvent in interface HoverEventSource<V>
      Returns:
      a hover event
    • asHoverEvent

      @NotNull public @NotNull HoverEvent<V> asHoverEvent​(@NotNull @NotNull UnaryOperator<V> op)
      Description copied from interface: HoverEventSource
      Creates a hover event with value derived from this object.

      The event value will be passed through the provided callback to allow transforming the original value of the event.

      Specified by:
      asHoverEvent in interface HoverEventSource<V>
      Parameters:
      op - transformation on value
      Returns:
      a hover event
    • styleApply

      public void styleApply​(@NotNull Style.Builder style)
      Description copied from interface: StyleBuilderApplicable
      Applies to style.
      Specified by:
      styleApply in interface StyleBuilderApplicable
      Parameters:
      style - the style builder
    • equals

      public boolean equals​(@Nullable @Nullable Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • examinableProperties

      @NotNull public @NotNull Stream<? extends net.kyori.examination.ExaminableProperty> examinableProperties()
      Specified by:
      examinableProperties in interface net.kyori.examination.Examinable
    • toString

      public String toString()
      Overrides:
      toString in class Object