geforkt von Mirrors/Velocity
fix typos, update javadocs
Dieser Commit ist enthalten in:
Ursprung
c0b8e9d646
Commit
26bf94f08f
@ -36,22 +36,29 @@ public interface CommandManager {
|
|||||||
void unregister(String alias);
|
void unregister(String alias);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls CommandExecuteEvent and attempts to execute a command from the specified {@code cmdLine}
|
* Calls CommandExecuteEvent and attempts to execute a command using the specified {@code cmdLine}
|
||||||
* sync.
|
* in a blocking fashion.
|
||||||
*
|
*
|
||||||
* @param source the command's source
|
* @param source the command's source
|
||||||
* @param cmdLine the command to run
|
* @param cmdLine the command to run
|
||||||
* @return true if the command was found and executed, false if it was not
|
* @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);
|
boolean execute(CommandSource source, String cmdLine);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to execute a command from the specified {@code cmdLine} sync
|
* Attempts to execute a command using the specified {@code cmdLine} in a blocking fashion without
|
||||||
* without calling CommandExecuteEvent.
|
* calling CommandExecuteEvent.
|
||||||
*
|
*
|
||||||
* @param source the command's source
|
* @param source the command's source
|
||||||
* @param cmdLine the command to run
|
* @param cmdLine the command to run
|
||||||
* @return true if the command was found and executed, false if it was not
|
* @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);
|
boolean executeImmediately(CommandSource source, String cmdLine);
|
||||||
|
|
||||||
@ -61,7 +68,8 @@ public interface CommandManager {
|
|||||||
*
|
*
|
||||||
* @param source the command's source
|
* @param source the command's source
|
||||||
* @param cmdLine the command to run
|
* @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<Boolean> executeAsync(CommandSource source, String cmdLine);
|
CompletableFuture<Boolean> executeAsync(CommandSource source, String cmdLine);
|
||||||
|
|
||||||
@ -71,7 +79,8 @@ public interface CommandManager {
|
|||||||
*
|
*
|
||||||
* @param source the command's source
|
* @param source the command's source
|
||||||
* @param cmdLine the command to run
|
* @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<Boolean> executeImmediatelyAsync(CommandSource source, String cmdLine);
|
CompletableFuture<Boolean> executeImmediatelyAsync(CommandSource source, String cmdLine);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ public final class CommandExecuteEvent implements ResultedEvent<CommandResult> {
|
|||||||
private CommandResult result;
|
private CommandResult result;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a PlayerChatEvent.
|
* Constructs a CommandExecuteEvent.
|
||||||
* @param commandSource the source executing the command
|
* @param commandSource the source executing the command
|
||||||
* @param command the command being executed without first slash
|
* @param command the command being executed without first slash
|
||||||
*/
|
*/
|
||||||
@ -52,7 +52,7 @@ public final class CommandExecuteEvent implements ResultedEvent<CommandResult> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "PlayerCommmandEvent{"
|
return "CommandExecuteEvent{"
|
||||||
+ "commandSource=" + commandSource
|
+ "commandSource=" + commandSource
|
||||||
+ ", command=" + command
|
+ ", command=" + command
|
||||||
+ ", result=" + result
|
+ ", result=" + result
|
||||||
|
@ -64,14 +64,14 @@ public class VelocityCommandManager implements CommandManager {
|
|||||||
* @return CompletableFuture of event
|
* @return CompletableFuture of event
|
||||||
*/
|
*/
|
||||||
public CompletableFuture<CommandExecuteEvent> callCommandEvent(CommandSource source, String cmd) {
|
public CompletableFuture<CommandExecuteEvent> callCommandEvent(CommandSource source, String cmd) {
|
||||||
Preconditions.checkNotNull(source, "invoker");
|
Preconditions.checkNotNull(source, "source");
|
||||||
Preconditions.checkNotNull(cmd, "cmd");
|
Preconditions.checkNotNull(cmd, "cmd");
|
||||||
return eventManager.fire(new CommandExecuteEvent(source, cmd));
|
return eventManager.fire(new CommandExecuteEvent(source, cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(CommandSource source, String cmdLine) {
|
public boolean execute(CommandSource source, String cmdLine) {
|
||||||
Preconditions.checkNotNull(source, "invoker");
|
Preconditions.checkNotNull(source, "source");
|
||||||
Preconditions.checkNotNull(cmdLine, "cmdLine");
|
Preconditions.checkNotNull(cmdLine, "cmdLine");
|
||||||
|
|
||||||
CommandExecuteEvent event = callCommandEvent(source, cmdLine).join();
|
CommandExecuteEvent event = callCommandEvent(source, cmdLine).join();
|
||||||
@ -86,7 +86,7 @@ public class VelocityCommandManager implements CommandManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeImmediately(CommandSource source, String cmdLine) {
|
public boolean executeImmediately(CommandSource source, String cmdLine) {
|
||||||
Preconditions.checkNotNull(source, "invoker");
|
Preconditions.checkNotNull(source, "source");
|
||||||
Preconditions.checkNotNull(cmdLine, "cmdLine");
|
Preconditions.checkNotNull(cmdLine, "cmdLine");
|
||||||
|
|
||||||
String alias = cmdLine;
|
String alias = cmdLine;
|
||||||
@ -133,6 +133,8 @@ public class VelocityCommandManager implements CommandManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Boolean> executeImmediatelyAsync(CommandSource source, String cmdLine) {
|
public CompletableFuture<Boolean> executeImmediatelyAsync(CommandSource source, String cmdLine) {
|
||||||
|
Preconditions.checkNotNull(source, "source");
|
||||||
|
Preconditions.checkNotNull(cmdLine, "cmdLine");
|
||||||
CompletableFuture<Boolean> result = new CompletableFuture<>();
|
CompletableFuture<Boolean> result = new CompletableFuture<>();
|
||||||
eventManager.getService().execute(() -> {
|
eventManager.getService().execute(() -> {
|
||||||
try {
|
try {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren