Throw an IllegalStateException when trying to register async completions on an unsupported server

This commit is contained in:
jmp 2020-10-04 12:33:02 -07:00 committed by Alexander Söderberg
parent 5a89f98a25
commit 80988ec986

View file

@ -85,8 +85,13 @@ public class PaperCommandManager<C> extends BukkitCommandManager<C> {
/** /**
* Register asynchronous completions. This requires all argument parsers to be thread safe, and it * Register asynchronous completions. This requires all argument parsers to be thread safe, and it
* is up to the caller to guarantee that such is the case * is up to the caller to guarantee that such is the case
*
* @throws IllegalStateException when the server does not support asynchronous completions.
*/ */
public void registerAsynchronousCompletions() { public void registerAsynchronousCompletions() throws IllegalStateException {
if (!this.queryCapability(CloudBukkitCapabilities.ASYNCHRONOUS_COMPLETION)) {
throw new IllegalStateException("Failed to register asynchronous command completion listener.");
}
Bukkit.getServer().getPluginManager().registerEvents(new AsyncCommandSuggestionsListener<>(this), this.getOwningPlugin()); Bukkit.getServer().getPluginManager().registerEvents(new AsyncCommandSuggestionsListener<>(this), this.getOwningPlugin());
} }