AsyncTabCompleteEvent

Let plugins be able to control tab completion of commands and chat async.

This will be useful for frameworks like ACF so we can define async safe completion handlers,
and avoid going to main for tab completions.

Especially useful if you need to query a database in order to obtain the results for tab
completion, such as offline players.

Also adds isCommand and getLocation to the sync TabCompleteEvent

Co-authored-by: Aikar <aikar@aikar.co>
This commit is contained in:
Jason Penilla
2017-11-26 13:19:58 -05:00
parent eb20b0b160
commit ed76af5637
3 changed files with 179 additions and 70 deletions

View File

@@ -2297,7 +2297,7 @@ public final class CraftServer implements Server {
offers = this.tabCompleteChat(player, message);
}
TabCompleteEvent tabEvent = new TabCompleteEvent(player, message, offers);
TabCompleteEvent tabEvent = new TabCompleteEvent(player, message, offers, message.startsWith("/") || forceCommand, pos != null ? io.papermc.paper.util.MCUtil.toLocation(((CraftWorld) player.getWorld()).getHandle(), BlockPos.containing(pos)) : null); // Paper - AsyncTabCompleteEvent
this.getPluginManager().callEvent(tabEvent);
return tabEvent.isCancelled() ? Collections.EMPTY_LIST : tabEvent.getCompletions();