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 b8f14fe8e..dd0932677 100644 --- a/api/src/main/java/com/velocitypowered/api/command/CommandManager.java +++ b/api/src/main/java/com/velocitypowered/api/command/CommandManager.java @@ -77,7 +77,7 @@ public interface CommandManager { * @return a future that may be completed with the result of the command execution. * Can be completed exceptionally if an exception is thrown during execution. */ - CompletableFuture execute(CommandSource source, String cmdLine); + CompletableFuture executeAsync(CommandSource source, String cmdLine); /** * Attempts to asynchronously execute a command from the given {@code cmdLine} @@ -88,7 +88,7 @@ public interface CommandManager { * @return a future that may be completed with the result of the command execution. * Can be completed exceptionally if an exception is thrown during execution. */ - CompletableFuture executeImmediately(CommandSource source, String cmdLine); + CompletableFuture executeImmediatelyAsync(CommandSource source, String cmdLine); /** * Returns whether the given alias is registered on this manager. 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 975d26dca..573a1b596 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java @@ -154,7 +154,7 @@ public class VelocityCommandManager implements CommandManager { } @Override - public CompletableFuture execute(final CommandSource source, final String cmdLine) { + public CompletableFuture executeAsync(final CommandSource source, final String cmdLine) { Preconditions.checkNotNull(source, "source"); Preconditions.checkNotNull(cmdLine, "cmdLine"); @@ -168,7 +168,7 @@ public class VelocityCommandManager implements CommandManager { } @Override - public CompletableFuture executeImmediately( + public CompletableFuture executeImmediatelyAsync( final CommandSource source, final String cmdLine) { Preconditions.checkNotNull(source, "source"); Preconditions.checkNotNull(cmdLine, "cmdLine"); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java index 8bf606be6..8ac397500 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java @@ -598,7 +598,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler { return CompletableFuture.runAsync(() -> smc.write(Chat.createServerbound("/" + commandToRun)), smc.eventLoop()); } else { - return server.getCommandManager().executeImmediately(player, commandToRun) + return server.getCommandManager().executeImmediatelyAsync(player, commandToRun) .thenAcceptAsync(hasRun -> { if (!hasRun) { smc.write(Chat.createServerbound("/" + commandToRun)); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java b/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java index 6637fd6f7..97db01d86 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java @@ -112,7 +112,7 @@ public final class VelocityConsole extends SimpleTerminalConsole implements Cons @Override protected void runCommand(String command) { try { - if (!this.server.getCommandManager().execute(this, command).join()) { + if (!this.server.getCommandManager().executeAsync(this, command).join()) { sendMessage(Component.text("Command not found.", NamedTextColor.RED)); } } catch (Exception e) { diff --git a/proxy/src/test/java/com/velocitypowered/proxy/command/CommandManagerTests.java b/proxy/src/test/java/com/velocitypowered/proxy/command/CommandManagerTests.java index c74423ed3..34612ebbc 100644 --- a/proxy/src/test/java/com/velocitypowered/proxy/command/CommandManagerTests.java +++ b/proxy/src/test/java/com/velocitypowered/proxy/command/CommandManagerTests.java @@ -70,8 +70,8 @@ public class CommandManagerTests { VelocityCommandManager manager = createManager(); assertFalse(manager.hasCommand("foo")); assertTrue(manager.getDispatcher().getRoot().getChildren().isEmpty()); - assertFalse(manager.execute(MockCommandSource.INSTANCE, "foo").join()); - assertFalse(manager.executeImmediately(MockCommandSource.INSTANCE, "bar").join()); + assertFalse(manager.executeAsync(MockCommandSource.INSTANCE, "foo").join()); + assertFalse(manager.executeImmediatelyAsync(MockCommandSource.INSTANCE, "bar").join()); assertTrue(manager.offerSuggestions(MockCommandSource.INSTANCE, "").join().isEmpty()); } @@ -111,7 +111,7 @@ public class CommandManagerTests { assertTrue(manager.hasCommand("foO")); manager.unregister("fOo"); assertFalse(manager.hasCommand("foo")); - assertFalse(manager.execute(MockCommandSource.INSTANCE, "foo").join()); + assertFalse(manager.executeAsync(MockCommandSource.INSTANCE, "foo").join()); manager.register("foo", command, "bAr", "BAZ"); assertTrue(manager.hasCommand("bar")); @@ -168,14 +168,14 @@ public class CommandManagerTests { node.addChild(quantityNode); manager.register(new BrigadierCommand(node)); - assertTrue(manager.execute(MockCommandSource.INSTANCE, "buy ").join()); + assertTrue(manager.executeAsync(MockCommandSource.INSTANCE, "buy ").join()); assertTrue(executed.compareAndSet(true, false), "was executed"); - assertTrue(manager.executeImmediately(MockCommandSource.INSTANCE, "buy 14").join()); + assertTrue(manager.executeImmediatelyAsync(MockCommandSource.INSTANCE, "buy 14").join()); assertTrue(checkedRequires.compareAndSet(true, false)); assertTrue(executed.get()); - assertTrue(manager.execute(MockCommandSource.INSTANCE, "buy 9").join(), + assertTrue(manager.executeAsync(MockCommandSource.INSTANCE, "buy 9").join(), "Invalid arg returns false"); - assertTrue(manager.executeImmediately(MockCommandSource.INSTANCE, "buy 12 bananas") + assertTrue(manager.executeImmediatelyAsync(MockCommandSource.INSTANCE, "buy 12 bananas") .join()); assertTrue(checkedRequires.get()); } @@ -191,7 +191,7 @@ public class CommandManagerTests { }; manager.register("foo", command); - assertTrue(manager.execute(MockCommandSource.INSTANCE, "foo bar 254").join()); + assertTrue(manager.executeAsync(MockCommandSource.INSTANCE, "foo bar 254").join()); assertTrue(executed.get()); SimpleCommand noPermsCommand = new SimpleCommand() { @@ -207,8 +207,8 @@ public class CommandManagerTests { }; manager.register("dangerous", noPermsCommand, "veryDangerous"); - assertFalse(manager.execute(MockCommandSource.INSTANCE, "dangerous").join()); - assertFalse(manager.executeImmediately(MockCommandSource.INSTANCE, "verydangerous 123") + assertFalse(manager.executeAsync(MockCommandSource.INSTANCE, "dangerous").join()); + assertFalse(manager.executeImmediatelyAsync(MockCommandSource.INSTANCE, "verydangerous 123") .join()); } @@ -226,7 +226,7 @@ public class CommandManagerTests { }; manager.register("sendMe", command); - assertTrue(manager.executeImmediately(MockCommandSource.INSTANCE, "sendMe lobby 23") + assertTrue(manager.executeImmediatelyAsync(MockCommandSource.INSTANCE, "sendMe lobby 23") .join()); assertTrue(executed.compareAndSet(true, false)); @@ -239,9 +239,9 @@ public class CommandManagerTests { }; manager.register("noargs", noArgsCommand); - assertTrue(manager.executeImmediately(MockCommandSource.INSTANCE, "noargs").join()); + assertTrue(manager.executeImmediatelyAsync(MockCommandSource.INSTANCE, "noargs").join()); assertTrue(executed.get()); - assertTrue(manager.executeImmediately(MockCommandSource.INSTANCE, "noargs ").join()); + assertTrue(manager.executeImmediatelyAsync(MockCommandSource.INSTANCE, "noargs ").join()); RawCommand noPermsCommand = new RawCommand() { @Override @@ -256,7 +256,7 @@ public class CommandManagerTests { }; manager.register("sendThem", noPermsCommand); - assertFalse(manager.executeImmediately(MockCommandSource.INSTANCE, "sendThem foo") + assertFalse(manager.executeImmediatelyAsync(MockCommandSource.INSTANCE, "sendThem foo") .join()); } @@ -421,16 +421,16 @@ public class CommandManagerTests { manager.register(meta, command); expectedArgs.set("notBarOrBaz"); - assertTrue(manager.execute(MockCommandSource.INSTANCE, "foo notBarOrBaz").join()); + assertTrue(manager.executeAsync(MockCommandSource.INSTANCE, "foo notBarOrBaz").join()); assertTrue(executed.compareAndSet(true, false)); expectedArgs.set("anotherArg 123"); - assertTrue(manager.execute(MockCommandSource.INSTANCE, "Foo2 anotherArg 123").join()); + assertTrue(manager.executeAsync(MockCommandSource.INSTANCE, "Foo2 anotherArg 123").join()); assertTrue(executed.compareAndSet(true, false)); expectedArgs.set("bar"); - assertTrue(manager.execute(MockCommandSource.INSTANCE, "foo bar").join()); + assertTrue(manager.executeAsync(MockCommandSource.INSTANCE, "foo bar").join()); assertTrue(executed.compareAndSet(true, false)); expectedArgs.set("bar 123"); - assertTrue(manager.execute(MockCommandSource.INSTANCE, "foo2 bar 123").join()); + assertTrue(manager.executeAsync(MockCommandSource.INSTANCE, "foo2 bar 123").join()); assertTrue(executed.compareAndSet(true, false)); assertEquals(ImmutableList.of("bar", "baz", "raw"),