diff options
author | Aikar <[email protected]> | 2020-05-02 14:17:17 -0400 |
---|---|---|
committer | Aikar <[email protected]> | 2020-05-02 14:17:17 -0400 |
commit | 0dd1907568f6ffc8a8d2637eced972e829e56a7a (patch) | |
tree | ffafc35acdc71fee50c57cbee72036449bf1b2d6 /Paper-MojangAPI | |
parent | a9e20e5f626ed541f2cfb1f1237bf428cc406bb7 (diff) | |
download | Paper-0dd1907568f6ffc8a8d2637eced972e829e56a7a.tar.gz Paper-0dd1907568f6ffc8a8d2637eced972e829e56a7a.zip |
AsyncSendPlayerSuggestionsEvent Brigadier Event
Going to be used for ACF to be able to send Tooltips to client :)
This is after completions are calculated, to control what is sent to the client.
Diffstat (limited to 'Paper-MojangAPI')
-rw-r--r-- | Paper-MojangAPI/src/main/java/com/destroystokyo/paper/event/brigadier/AsyncSendPlayerSuggestionsEvent.java | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/Paper-MojangAPI/src/main/java/com/destroystokyo/paper/event/brigadier/AsyncSendPlayerSuggestionsEvent.java b/Paper-MojangAPI/src/main/java/com/destroystokyo/paper/event/brigadier/AsyncSendPlayerSuggestionsEvent.java new file mode 100644 index 0000000000..dbdb72984b --- /dev/null +++ b/Paper-MojangAPI/src/main/java/com/destroystokyo/paper/event/brigadier/AsyncSendPlayerSuggestionsEvent.java @@ -0,0 +1,77 @@ +package com.destroystokyo.paper.event.brigadier; + +import com.mojang.brigadier.suggestion.Suggestions; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; +import org.jetbrains.annotations.NotNull; + +/** + * Called when sending Suggestions to the client. Will be called asynchronously if a plugin + * marks the AsyncTabComplete event handled asynchronously, otherwise called synchronously. + */ +public class AsyncSendPlayerSuggestionsEvent extends PlayerEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled = false; + + private Suggestions suggestions; + private final String buffer; + + public AsyncSendPlayerSuggestionsEvent(Player player, Suggestions suggestions, String buffer) { + super(player, !Bukkit.isPrimaryThread()); + this.suggestions = suggestions; + this.buffer = buffer; + } + + /** + * @return The input buffer sent to request these suggestions + */ + public String getBuffer() { + return buffer; + } + + /** + * @return The suggestions being sent to client + */ + public Suggestions getSuggestions() { + return suggestions; + } + + /** + * @param suggestions The suggestions to be sent to client if need to change them + */ + public void setSuggestions(Suggestions suggestions) { + this.suggestions = suggestions; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isCancelled() { + return this.cancelled; + } + + /** + * Cancels sending suggestions to the client + * {@inheritDoc} + */ + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + + @NotNull + public HandlerList getHandlers() { + return handlers; + } + + @NotNull + public static HandlerList getHandlerList() { + return handlers; + } +} |