Package com.destroystokyo.paper.event.server

# Class AsyncTabCompleteEvent

java.lang.Object
org.bukkit.event.Event
com.destroystokyo.paper.event.server.AsyncTabCompleteEvent

All Implemented Interfaces:
  `Cancellable`

public class AsyncTabCompleteEvent extends Event implements Cancellable
Allows plugins to compute tab completion results asynchronously. If this event provides completions, then the standard synchronous process will not be fired to populate the results. However, the synchronous TabCompleteEvent will fire with the Async results. Only 1 process will be allowed to provide completions, the Async Event, or the standard process.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static interface`
`AsyncTabCompleteEvent.Completion`
A rich tab completion, consisting of a string suggestion, and a nullable `Component` tooltip.

## Nested classes/interfaces inherited from class org.bukkit.event.Event

`Event.Result`

## Constructor Summary

Constructors
Constructor
Description
`AsyncTabCompleteEvent(@NotNull CommandSender sender, @NotNull String buffer, boolean isCommand, @Nullable Location loc)`
`AsyncTabCompleteEvent(@NotNull CommandSender sender, @NotNull List<String> completions, @NotNull String buffer, boolean isCommand, @Nullable Location loc)`
Deprecated.

## Method Summary

Modifier and Type
Method
Description
`@NotNull List<AsyncTabCompleteEvent.Completion>`
`completions()`
The list of `completions` which will be offered to the sender, in order.
`void`
`completions(@NotNull List<AsyncTabCompleteEvent.Completion> newCompletions)`
Set the `completions` offered, overriding any already set.
`@NotNull String`
`getBuffer()`
Return the entire buffer which formed the basis of this completion.
`@NotNull List<String>`
`getCompletions()`
The list of completions which will be offered to the sender, in order.
`static @NotNull HandlerList`
`getHandlerList()`
`@NotNull HandlerList`
`getHandlers()`
`@Nullable Location`
`getLocation()`
`@NotNull CommandSender`
`getSender()`
Get the sender completing this command.
`boolean`
`isCancelled()`
Gets the cancellation state of this event.
`boolean`
`isCommand()`
`boolean`
`isHandled()`
If true, the standard process of calling `Command.tabComplete(CommandSender, String, String[])` or current player names will not be called.
`void`
`setCancelled(boolean cancelled)`
Will provide no completions, and will not fire the synchronous process
`void`
`setCompletions(@NotNull List<String> completions)`
Set the completions offered, overriding any already set.
`void`
`setHandled(boolean handled)`
Sets whether or not to consider the completion request handled.

### Methods inherited from class org.bukkit.event.Event

`callEvent, getEventName, isAsynchronous`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### AsyncTabCompleteEvent

public AsyncTabCompleteEvent(@NotNull @NotNull CommandSender sender, @NotNull @NotNull String buffer, boolean isCommand, @Nullable @Nullable Location loc)

### AsyncTabCompleteEvent

@Deprecated public AsyncTabCompleteEvent(@NotNull @NotNull CommandSender sender, @NotNull @NotNull List<String> completions, @NotNull @NotNull String buffer, boolean isCommand, @Nullable @Nullable Location loc)
Deprecated.

## Method Details

### getSender

@NotNull public @NotNull CommandSender getSender()
Get the sender completing this command.

Returns:
  the `CommandSender` instance

### getCompletions

@NotNull public @NotNull List<String> getCompletions()
The list of completions which will be offered to the sender, in order. This list is mutable and reflects what will be offered. If this collection is not empty after the event is fired, then the standard process of calling `Command.tabComplete(CommandSender, String, String[])` or current player names will not be called.

Returns:
  a list of offered completions

### setCompletions

public void setCompletions(@NotNull @NotNull List<String> completions)
Set the completions offered, overriding any already set. If this collection is not empty after the event is fired, then the standard process of calling `Command.tabComplete(CommandSender, String, String[])` or current player names will not be called. The passed collection will be cloned to a new List. You must call {`getCompletions()`} to mutate from here

Parameters:
  `completions` - the new completions

### completions

@NotNull public @NotNull List<AsyncTabCompleteEvent.Completion> completions()
The list of `completions` which will be offered to the sender, in order. This list is mutable and reflects what will be offered.

If this collection is not empty after the event is fired, then the standard process of calling `Command.tabComplete(CommandSender, String, String[])` or current player names will not be called.

Returns:
  a list of offered completions

### completions

public void completions(@NotNull @NotNull List<AsyncTabCompleteEvent.Completion> newCompletions)
Set the `completions` offered, overriding any already set. If this collection is not empty after the event is fired, then the standard process of calling `Command.tabComplete(CommandSender, String, String[])` or current player names will not be called.

The passed collection will be cloned to a new List. You must call {`completions()`} to mutate from here

Parameters:
  `newCompletions` - the new completions

### getBuffer

@NotNull public @NotNull String getBuffer()
Return the entire buffer which formed the basis of this completion.

Returns:
  command buffer, as entered

### isCommand

public boolean isCommand()

Returns:
  True if it is a command being tab completed, false if it is a chat message.

### getLocation

@Nullable public @Nullable Location getLocation()

Returns:
  The position looked at by the sender, or null if none

### isHandled

public boolean isHandled()
If true, the standard process of calling `Command.tabComplete(CommandSender, String, String[])` or current player names will not be called.

Returns:
  Is completions considered handled. Always true if completions is not empty.

### setHandled

public void setHandled(boolean handled)
Sets whether or not to consider the completion request handled. If true, the standard process of calling `Command.tabComplete(CommandSender, String, String[])` or current player names will not be called.

Parameters:
  `handled` - if this completion should be marked as being handled

### isCancelled

public boolean isCancelled()
Description copied from interface: `Cancellable`
Gets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins

Specified by:
  `isCancelled` in interface `Cancellable`
Returns:
  true if this event is cancelled

### setCancelled

public void setCancelled(boolean cancelled)
Will provide no completions, and will not fire the synchronous process

Specified by:
  `setCancelled` in interface `Cancellable`
Parameters:
  `cancelled` - true if you wish to cancel this event

### getHandlers

@NotNull public @NotNull HandlerList getHandlers()

Specified by:
  `getHandlers` in class `Event`

### getHandlerList

@NotNull public static @NotNull HandlerList getHandlerList()