From 26bf94f08f3c4c25304ad023392f348c1bf85170 Mon Sep 17 00:00:00 2001 From: Leymooo Date: Mon, 27 Apr 2020 13:09:04 +0300 Subject: [PATCH] fix typos, update javadocs --- .../api/command/CommandManager.java | 21 +++++++++++++------ .../event/command/CommandExecuteEvent.java | 4 ++-- .../proxy/command/VelocityCommandManager.java | 8 ++++--- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/api/src/main/java/com/velocitypowered/api/command/CommandManager.java b/api/src/main/java/com/velocitypowered/api/command/CommandManager.java index af200cb74..f29777d6f 100644 --- a/api/src/main/java/com/velocitypowered/api/command/CommandManager.java +++ b/api/src/main/java/com/velocitypowered/api/command/CommandManager.java @@ -36,22 +36,29 @@ public interface CommandManager { void unregister(String alias); /** - * Calls CommandExecuteEvent and attempts to execute a command from the specified {@code cmdLine} - * sync. + * Calls CommandExecuteEvent and attempts to execute a command using the specified {@code cmdLine} + * in a blocking fashion. * * @param source the command's source * @param cmdLine the command to run * @return true if the command was found and executed, false if it was not + * + * @deprecated This method will block current thread during event call and command execution. + * Prefer {@link #executeAsync(CommandSource, String)} instead. */ + @Deprecated boolean execute(CommandSource source, String cmdLine); /** - * Attempts to execute a command from the specified {@code cmdLine} sync - * without calling CommandExecuteEvent. + * Attempts to execute a command using the specified {@code cmdLine} in a blocking fashion without + * calling CommandExecuteEvent. * * @param source the command's source * @param cmdLine the command to run * @return true if the command was found and executed, false if it was not + * + * @deprecated This method will block current thread during event and command execution. + * Prefer {@link #executeImmediatelyAsync(CommandSource, String)} instead. */ boolean executeImmediately(CommandSource source, String cmdLine); @@ -61,7 +68,8 @@ public interface CommandManager { * * @param source the command's source * @param cmdLine the command to run - * @return A future that will be completed with the result of the command execution + * @return A future that will be completed with the result of the command execution. + * Can be completed exceptionally if exception was thrown during execution. */ CompletableFuture executeAsync(CommandSource source, String cmdLine); @@ -71,7 +79,8 @@ public interface CommandManager { * * @param source the command's source * @param cmdLine the command to run - * @return A future that will be completed with the result of the command execution + * @return A future that will be completed with the result of the command execution. + * Can be completed exceptionally if exception was thrown during execution. */ CompletableFuture executeImmediatelyAsync(CommandSource source, String cmdLine); } diff --git a/api/src/main/java/com/velocitypowered/api/event/command/CommandExecuteEvent.java b/api/src/main/java/com/velocitypowered/api/event/command/CommandExecuteEvent.java index f92ed6892..054699568 100644 --- a/api/src/main/java/com/velocitypowered/api/event/command/CommandExecuteEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/command/CommandExecuteEvent.java @@ -18,7 +18,7 @@ public final class CommandExecuteEvent implements ResultedEvent { private CommandResult result; /** - * Constructs a PlayerChatEvent. + * Constructs a CommandExecuteEvent. * @param commandSource the source executing the command * @param command the command being executed without first slash */ @@ -52,7 +52,7 @@ public final class CommandExecuteEvent implements ResultedEvent { @Override public String toString() { - return "PlayerCommmandEvent{" + return "CommandExecuteEvent{" + "commandSource=" + commandSource + ", command=" + command + ", result=" + result diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java b/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java index 3a8a53201..2b3975f1a 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java @@ -64,14 +64,14 @@ public class VelocityCommandManager implements CommandManager { * @return CompletableFuture of event */ public CompletableFuture callCommandEvent(CommandSource source, String cmd) { - Preconditions.checkNotNull(source, "invoker"); + Preconditions.checkNotNull(source, "source"); Preconditions.checkNotNull(cmd, "cmd"); return eventManager.fire(new CommandExecuteEvent(source, cmd)); } @Override public boolean execute(CommandSource source, String cmdLine) { - Preconditions.checkNotNull(source, "invoker"); + Preconditions.checkNotNull(source, "source"); Preconditions.checkNotNull(cmdLine, "cmdLine"); CommandExecuteEvent event = callCommandEvent(source, cmdLine).join(); @@ -86,7 +86,7 @@ public class VelocityCommandManager implements CommandManager { @Override public boolean executeImmediately(CommandSource source, String cmdLine) { - Preconditions.checkNotNull(source, "invoker"); + Preconditions.checkNotNull(source, "source"); Preconditions.checkNotNull(cmdLine, "cmdLine"); String alias = cmdLine; @@ -133,6 +133,8 @@ public class VelocityCommandManager implements CommandManager { @Override public CompletableFuture executeImmediatelyAsync(CommandSource source, String cmdLine) { + Preconditions.checkNotNull(source, "source"); + Preconditions.checkNotNull(cmdLine, "cmdLine"); CompletableFuture result = new CompletableFuture<>(); eventManager.getService().execute(() -> { try {