Class ClickEvent<T extends ClickEvent.Payload>
java.lang.Object
net.kyori.adventure.text.event.ClickEvent<T>
- Type Parameters:
T- the payload type
- All Implemented Interfaces:
ComponentBuilderApplicable, StyleBuilderApplicable
public final class ClickEvent<T extends ClickEvent.Payload>
extends Object
implements StyleBuilderApplicable
A click event.
A click event processes an ClickEvent.Action when clicked on.
- Since:
- 4.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classClickEvent.Action<T extends ClickEvent.Payload>An enumeration of click event actions.static interfaceA payload for a click event. -
Method Summary
Modifier and TypeMethodDescriptionaction()Gets the click event action.static ClickEvent<?> callback(ClickCallback<Audience> function) Create a click event that, when clicked, will schedule a callback function to be executed on the server.static ClickEvent<?> callback(ClickCallback<Audience> function, Consumer<ClickCallback.Options.Builder> optionsBuilder) Create a click event that, when clicked, will schedule a callback function to be executed on the server.static ClickEvent<?> callback(ClickCallback<Audience> function, ClickCallback.Options options) Create a click event that, when clicked, will schedule a callback function to be executed on the server.static ClickEvent<ClickEvent.Payload.Int> changePage(int page) Creates a click event that changes to a page.static <T extends ClickEvent.Payload>
ClickEvent<T> clickEvent(ClickEvent.Action<T> action, T payload) Creates a click event with apayload.static ClickEvent<ClickEvent.Payload.Text> copyToClipboard(String text) Creates a click event that copies text to the clipboard.static ClickEvent<ClickEvent.Payload.Custom> Creates a click event that sends a custom event to the server.static ClickEvent<ClickEvent.Payload.Custom> custom(Key key, @Nullable BinaryTagHolder nbt) Creates a click event that sends a custom event to the server.booleaninthashCode()static ClickEvent<ClickEvent.Payload.Text> Creates a click event that opens a file.static ClickEvent<ClickEvent.Payload.Text> Creates a click event that opens a url.static ClickEvent<ClickEvent.Payload.Text> Creates a click event that opens a url.payload()Gets the payload associated with this click event.static ClickEvent<ClickEvent.Payload.Text> runCommand(String command) Creates a click event that runs a command.static ClickEvent<ClickEvent.Payload.Dialog> showDialog(DialogLike dialog) Creates a click event that shows a dialog.voidstyleApply(Style.Builder style) Applies tostyle.static ClickEvent<ClickEvent.Payload.Text> suggestCommand(String command) Creates a click event that suggests a command.toString()Methods inherited from interface StyleBuilderApplicable
componentBuilderApply
-
Method Details
-
openUrl
Creates 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
-
openUrl
Creates a click event that opens a url.- Parameters:
url- the url to open- Returns:
- a click event
- Since:
- 4.0.0
-
openFile
Creates 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
-
runCommand
Creates a click event that runs a command.- Parameters:
command- the command to run- Returns:
- a click event
- Since:
- 4.0.0
-
suggestCommand
Creates a click event that suggests a command.- Parameters:
command- the command to suggest- Returns:
- a click event
- Since:
- 4.0.0
-
changePage
Creates a click event that changes to a page.- Parameters:
page- the page to change to- Returns:
- a click event
- Since:
- 4.0.0
-
copyToClipboard
Creates 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
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
public static ClickEvent<?> callback(ClickCallback<Audience> function, 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 executeoptions- options to control how the callback will be stored on the server.- Returns:
- a callback click event
- Since:
- 4.13.0
-
callback
public static ClickEvent<?> callback(ClickCallback<Audience> function, Consumer<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 executeoptionsBuilder- function that will be called to configure the click callback options- Returns:
- a callback click event
- Since:
- 4.13.0
-
showDialog
Creates a click event that shows a dialog.- Parameters:
dialog- the dialog- Returns:
- the click event
- Since:
- 4.22.0
-
custom
Creates a click event that sends a custom event to the server.- Parameters:
key- the key identifying the payload- Returns:
- the click event
- Since:
- 5.0.0
-
custom
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 payloadnbt- the nbt data- Returns:
- the click event
- Since:
- 4.23.0
-
clickEvent
public static <T extends ClickEvent.Payload> ClickEvent<T> clickEvent(ClickEvent.Action<T> action, T payload) Creates a click event with apayload.- Type Parameters:
T- the payload type- Parameters:
action- the actionpayload- the payload- Returns:
- a click event
- Throws:
IllegalArgumentException- if the action does not support that payload, or if the payload is not valid for the action- Since:
- 4.25.0
-
action
Gets the click event action.- Returns:
- the click event action
- Since:
- 4.0.0
-
payload
Gets the payload associated with this click event.- Returns:
- the payload
- Since:
- 4.22.0
-
styleApply
Description copied from interface:StyleBuilderApplicableApplies tostyle.- Specified by:
styleApplyin interfaceStyleBuilderApplicable- Parameters:
style- the style builder
-
equals
-
hashCode
-
toString
-