Package net.kyori.adventure.text.event
Class ClickEvent
java.lang.Object
net.kyori.adventure.text.event.ClickEvent
- All Implemented Interfaces:
- ComponentBuilderApplicable,- StyleBuilderApplicable,- net.kyori.examination.Examinable
public final class ClickEvent
extends Object
implements net.kyori.examination.Examinable, StyleBuilderApplicable
A click event.
 
A click event processes an ClickEvent.Action when clicked on.
- Since:
- 4.0.0
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic enumAn enumeration of click event actions.static interfaceA payload for a click event.
- 
Method SummaryModifier and TypeMethodDescription@NotNull ClickEvent.Actionaction()Gets the click event action.static @NotNull ClickEventcallback(@NotNull ClickCallback<Audience> function) Create a click event that, when clicked, will schedule a callback function to be executed on the server.static @NotNull ClickEventcallback(@NotNull ClickCallback<Audience> function, @NotNull Consumer<@NotNull ClickCallback.Options.Builder> optionsBuilder) Create a click event that, when clicked, will schedule a callback function to be executed on the server.static @NotNull ClickEventcallback(@NotNull ClickCallback<Audience> function, @NotNull ClickCallback.Options options) Create a click event that, when clicked, will schedule a callback function to be executed on the server.static @NotNull ClickEventchangePage(int page) Creates a click event that changes to a page.static @NotNull ClickEventchangePage(@NotNull String page) Deprecated.static @NotNull ClickEventclickEvent(@NotNull ClickEvent.Action action, @NotNull String value) Deprecated.For removal since 4.22.0, not all actions support string payloads.static @NotNull ClickEventclickEvent(@NotNull ClickEvent.Action action, @NotNull ClickEvent.Payload payload) Creates a click event with apayload.static @NotNull ClickEventcopyToClipboard(@NotNull String text) Creates a click event that copies text to the clipboard.static @NotNull ClickEventDeprecated.For removal since 4.23.0, payloads hold NBT data, usecustom(Key, BinaryTagHolder)instead.static @NotNull ClickEventcustom(@NotNull Key key, @NotNull BinaryTagHolder nbt) Creates a click event that sends a custom event to the server.boolean@NotNull Stream<? extends net.kyori.examination.ExaminableProperty>inthashCode()static @NotNull ClickEventCreates a click event that opens a file.static @NotNull ClickEventCreates a click event that opens a url.static @NotNull ClickEventCreates a click event that opens a url.@NotNull ClickEvent.Payloadpayload()Gets the payload associated with this click event.static @NotNull ClickEventrunCommand(@NotNull String command) Creates a click event that runs a command.static @NotNull ClickEventshowDialog(@NotNull DialogLike dialog) Creates a click event that shows a dialog.voidstyleApply(@NotNull Style.Builder style) Applies tostyle.static @NotNull ClickEventsuggestCommand(@NotNull String command) Creates a click event that suggests a command.toString()@NotNull Stringvalue()Deprecated.For removal since 4.22.0, click events can hold more than just strings, seepayload()Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.kyori.examination.ExaminableexaminableName, examineMethods inherited from interface net.kyori.adventure.text.format.StyleBuilderApplicablecomponentBuilderApply
- 
Method Details- 
openUrlCreates a click event that opens a url.Since Minecraft: Java Edition 1.21.5 the url will fail to parse if not a http://orhttps://scheme.- Parameters:
- url- the url to open
- Returns:
- a click event
- Since:
- 4.0.0
 
- 
openUrlCreates a click event that opens a url.- Parameters:
- url- the url to open
- Returns:
- a click event
- Since:
- 4.0.0
 
- 
openFileCreates a click event that opens a file.This action is not readable, and may only be used locally on the client. - Parameters:
- file- the file to open
- Returns:
- a click event
- Since:
- 4.0.0
 
- 
runCommandCreates a click event that runs a command.- Parameters:
- command- the command to run
- Returns:
- a click event
- Since:
- 4.0.0
 
- 
suggestCommandCreates a click event that suggests a command.- Parameters:
- command- the command to suggest
- Returns:
- a click event
- Since:
- 4.0.0
 
- 
changePageDeprecated.For removal since 4.22.0, pages are integers, usechangePage(int)Creates a click event that changes to a page.- Parameters:
- page- the page to change to
- Returns:
- a click event
- Throws:
- IllegalArgumentException- if the page cannot be represented as an integer using
- Since:
- 4.0.0
 
- 
changePageCreates a click event that changes to a page.- Parameters:
- page- the page to change to
- Returns:
- a click event
- Since:
- 4.0.0
 
- 
copyToClipboardCreates a click event that copies text to the clipboard.- Parameters:
- text- the text to copy to the clipboard
- Returns:
- a click event
- Since:
- 4.0.0
- Since Minecraft:
- 1.15
 
- 
callback@NotNull public static @NotNull ClickEvent callback(@NotNull @NotNull ClickCallback<Audience> function) Create a click event that, when clicked, will schedule a callback function to be executed on the server.By default, this will be a single-use function that expires after the value of ClickCallback.DEFAULT_LIFETIME.- Parameters:
- function- the function to execute
- Returns:
- a callback click event
- Since:
- 4.13.0
 
- 
callback@NotNull public static @NotNull ClickEvent callback(@NotNull @NotNull ClickCallback<Audience> function, @NotNull ClickCallback.Options options) Create a click event that, when clicked, will schedule a callback function to be executed on the server.- Parameters:
- function- the function to execute
- options- options to control how the callback will be stored on the server.
- Returns:
- a callback click event
- Since:
- 4.13.0
 
- 
callback@NotNull public static @NotNull ClickEvent callback(@NotNull @NotNull ClickCallback<Audience> function, @NotNull @NotNull Consumer<@NotNull ClickCallback.Options.Builder> optionsBuilder) Create a click event that, when clicked, will schedule a callback function to be executed on the server.- Parameters:
- function- the function to execute
- optionsBuilder- function that will be called to configure the click callback options
- Returns:
- a callback click event
- Since:
- 4.13.0
 
- 
showDialogCreates a click event that shows a dialog.- Parameters:
- dialog- the dialog
- Returns:
- the click event
- Since:
- 4.22.0
 
- 
custom@Deprecated @NotNull public static @NotNull ClickEvent custom(@NotNull @NotNull Key key, @NotNull @NotNull String data) Deprecated.For removal since 4.23.0, payloads hold NBT data, usecustom(Key, BinaryTagHolder)instead. This method will create NBT usingBinaryTagHolder.binaryTagHolder(String).Creates a click event sends a custom event to the server.- Parameters:
- key- the key
- data- the data
- Returns:
- the click event
- Since:
- 4.22.0
 
- 
custom@NotNull public static @NotNull ClickEvent custom(@NotNull @NotNull Key key, @NotNull @NotNull BinaryTagHolder nbt) Creates a click event that sends a custom event to the server.See BinaryTagHolder.binaryTagHolder(String)for a simple way to create NBT from SNBT. For simple use cases, you can use plain strings directly as SNBT.- Parameters:
- key- the key identifying the payload
- nbt- the nbt data
- Returns:
- the click event
- Since:
- 4.23.0
 
- 
clickEvent@Deprecated @NotNull public static @NotNull ClickEvent clickEvent(@NotNull @NotNull ClickEvent.Action action, @NotNull @NotNull String value) Deprecated.For removal since 4.22.0, not all actions support string payloads. UseclickEvent(Action, Payload)or the event-specific methods.Creates a click event with astring payload.- Parameters:
- action- the action
- value- the value
- Returns:
- a click event
- Throws:
- IllegalArgumentException- if the action does not support a string payload
- Since:
- 4.0.0
 
- 
clickEvent@NotNull public static @NotNull ClickEvent clickEvent(@NotNull @NotNull ClickEvent.Action action, @NotNull @NotNull ClickEvent.Payload payload) Creates a click event with apayload.- Parameters:
- action- the action
- payload- the payload
- Returns:
- a click event
- Throws:
- IllegalArgumentException- if the action does not support that payload
- Since:
- 4.25.0
 
- 
actionGets the click event action.- Returns:
- the click event action
- Since:
- 4.0.0
 
- 
valueDeprecated.For removal since 4.22.0, click events can hold more than just strings, seepayload()Gets the click event value if the payload is astring payload.- Returns:
- the click event value
- Throws:
- IllegalStateException- if the payload is not a string payload
- Since:
- 4.0.0
 
- 
payloadGets the payload associated with this click event.- Returns:
- the payload
- Since:
- 4.22.0
 
- 
styleApplyDescription copied from interface:StyleBuilderApplicableApplies tostyle.- Specified by:
- styleApplyin interface- StyleBuilderApplicable
- Parameters:
- style- the style builder
 
- 
equals
- 
hashCodepublic int hashCode()
- 
examinableProperties@NotNull public @NotNull Stream<? extends net.kyori.examination.ExaminableProperty> examinableProperties()- Specified by:
- examinablePropertiesin interface- net.kyori.examination.Examinable
 
- 
toString
 
- 
changePage(int)