Package net.kyori.adventure.text.event
Interface ClickCallback<T extends Audience>
- Type Parameters:
T
- audience type
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A handler for callback click events.
- Since:
- 4.13.0
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Options to configure how a callback can be executed.static interface
A provider for actually producing click callbacks. -
Field Summary
Modifier and TypeFieldDescriptionstatic final Duration
The default lifetime of a callback after creating it, 12 hours.static final int
Indicate that a callback should have unlimited uses. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Perform an action for this event.default @NotNull ClickCallback<T>
Filter audiences that receive this click callback.default @NotNull ClickCallback<T>
Filter audiences that receive this click callback.default @NotNull ClickCallback<T>
requiringPermission
(@NotNull String permission) Require that audiences receiving this callback have a certain permission.default @NotNull ClickCallback<T>
requiringPermission
(@NotNull String permission, @Nullable Consumer<? super Audience> otherwise) Require that audiences receiving this callback have a certain permission.static <W extends Audience,
N extends W>
@NotNull ClickCallback<W>widen
(@NotNull ClickCallback<N> original, @NotNull Class<N> type) Adjust this callback to accept any audience, and perform the appropriate filtering.static <W extends Audience,
N extends W>
@NotNull ClickCallback<W>widen
(@NotNull ClickCallback<N> original, @NotNull Class<N> type, @Nullable Consumer<? super Audience> otherwise) Adjust this callback to accept any audience, and perform the appropriate filtering.
-
Field Details
-
DEFAULT_LIFETIME
The default lifetime of a callback after creating it, 12 hours.- Since:
- 4.13.0
-
UNLIMITED_USES
static final int UNLIMITED_USESIndicate that a callback should have unlimited uses.- Since:
- 4.13.0
- See Also:
-
-
Method Details
-
widen
@CheckReturnValue @Contract(pure=true) @NotNull static <W extends Audience,N extends W> @NotNull ClickCallback<W> widen(@NotNull @NotNull ClickCallback<N> original, @NotNull @NotNull Class<N> type, @Nullable @Nullable Consumer<? super Audience> otherwise) Adjust this callback to accept any audience, and perform the appropriate filtering.- Type Parameters:
W
- the wider typeN
- the narrower type- Parameters:
original
- the original callback of a narrower audience typetype
- the audience type to acceptotherwise
- the action to perform on the audience if it is not of the appropriate type- Returns:
- a new callback
- Since:
- 4.13.0
-
widen
@CheckReturnValue @Contract(pure=true) @NotNull static <W extends Audience,N extends W> @NotNull ClickCallback<W> widen(@NotNull @NotNull ClickCallback<N> original, @NotNull @NotNull Class<N> type) Adjust this callback to accept any audience, and perform the appropriate filtering.No message will be sent if the audience is not of the appropriate type.
- Type Parameters:
W
- the wider typeN
- the narrower type- Parameters:
original
- the original callback of a narrower audience typetype
- the audience type to accept- Returns:
- a new callback
- Since:
- 4.13.0
-
accept
Perform an action for this event.- Parameters:
audience
- the single-user audience who is attempting to execute this callback function.- Since:
- 4.13.0
-
filter
@CheckReturnValue @Contract(pure=true) @NotNull default @NotNull ClickCallback<T> filter(@NotNull @NotNull Predicate<T> filter) Filter audiences that receive this click callback.Actions from audiences that do not match this predicate will be silently ignored.
- Parameters:
filter
- the filter to test audiences with- Returns:
- a filtered callback action
- Since:
- 4.13.0
-
filter
@CheckReturnValue @Contract(pure=true) @NotNull default @NotNull ClickCallback<T> filter(@NotNull @NotNull Predicate<T> filter, @Nullable @Nullable Consumer<? super Audience> otherwise) Filter audiences that receive this click callback.- Parameters:
filter
- the filter to test audiences withotherwise
- the action to perform on the audience if the conditions are not met- Returns:
- a filtered callback action
- Since:
- 4.13.0
-
requiringPermission
@CheckReturnValue @Contract(pure=true) @NotNull default @NotNull ClickCallback<T> requiringPermission(@NotNull @NotNull String permission) Require that audiences receiving this callback have a certain permission.For audiences without permissions information, this test will always fail.
Actions from audiences that do not match this predicate will be silently ignored.
- Parameters:
permission
- the permission to check- Returns:
- a modified callback
- Since:
- 4.13.0
-
requiringPermission
@CheckReturnValue @Contract(pure=true) @NotNull default @NotNull ClickCallback<T> requiringPermission(@NotNull @NotNull String permission, @Nullable @Nullable Consumer<? super Audience> otherwise) Require that audiences receiving this callback have a certain permission.For audiences without permissions information, this test will always fail.
- Parameters:
permission
- the permission to checkotherwise
- the action to perform on the audience if the conditions are not met- Returns:
- a modified callback
- Since:
- 4.13.0
-