geforkt von Mirrors/Velocity
Fix CommandManager method naming so that it is in sync with the 1.1.0 API
Dieser Commit ist enthalten in:
Ursprung
b632431ae9
Commit
3f50964f36
@ -77,7 +77,7 @@ public interface CommandManager {
|
|||||||
* @return a future that may be completed with the result of the command execution.
|
* @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.
|
* Can be completed exceptionally if an exception is thrown during execution.
|
||||||
*/
|
*/
|
||||||
CompletableFuture<Boolean> execute(CommandSource source, String cmdLine);
|
CompletableFuture<Boolean> executeAsync(CommandSource source, String cmdLine);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to asynchronously execute a command from the given {@code 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.
|
* @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.
|
* Can be completed exceptionally if an exception is thrown during execution.
|
||||||
*/
|
*/
|
||||||
CompletableFuture<Boolean> executeImmediately(CommandSource source, String cmdLine);
|
CompletableFuture<Boolean> executeImmediatelyAsync(CommandSource source, String cmdLine);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the given alias is registered on this manager.
|
* Returns whether the given alias is registered on this manager.
|
||||||
|
@ -154,7 +154,7 @@ public class VelocityCommandManager implements CommandManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Boolean> execute(final CommandSource source, final String cmdLine) {
|
public CompletableFuture<Boolean> executeAsync(final CommandSource source, final String cmdLine) {
|
||||||
Preconditions.checkNotNull(source, "source");
|
Preconditions.checkNotNull(source, "source");
|
||||||
Preconditions.checkNotNull(cmdLine, "cmdLine");
|
Preconditions.checkNotNull(cmdLine, "cmdLine");
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ public class VelocityCommandManager implements CommandManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Boolean> executeImmediately(
|
public CompletableFuture<Boolean> executeImmediatelyAsync(
|
||||||
final CommandSource source, final String cmdLine) {
|
final CommandSource source, final String cmdLine) {
|
||||||
Preconditions.checkNotNull(source, "source");
|
Preconditions.checkNotNull(source, "source");
|
||||||
Preconditions.checkNotNull(cmdLine, "cmdLine");
|
Preconditions.checkNotNull(cmdLine, "cmdLine");
|
||||||
|
@ -598,7 +598,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
return CompletableFuture.runAsync(() -> smc.write(Chat.createServerbound("/"
|
return CompletableFuture.runAsync(() -> smc.write(Chat.createServerbound("/"
|
||||||
+ commandToRun)), smc.eventLoop());
|
+ commandToRun)), smc.eventLoop());
|
||||||
} else {
|
} else {
|
||||||
return server.getCommandManager().executeImmediately(player, commandToRun)
|
return server.getCommandManager().executeImmediatelyAsync(player, commandToRun)
|
||||||
.thenAcceptAsync(hasRun -> {
|
.thenAcceptAsync(hasRun -> {
|
||||||
if (!hasRun) {
|
if (!hasRun) {
|
||||||
smc.write(Chat.createServerbound("/" + commandToRun));
|
smc.write(Chat.createServerbound("/" + commandToRun));
|
||||||
|
@ -112,7 +112,7 @@ public final class VelocityConsole extends SimpleTerminalConsole implements Cons
|
|||||||
@Override
|
@Override
|
||||||
protected void runCommand(String command) {
|
protected void runCommand(String command) {
|
||||||
try {
|
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));
|
sendMessage(Component.text("Command not found.", NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -70,8 +70,8 @@ public class CommandManagerTests {
|
|||||||
VelocityCommandManager manager = createManager();
|
VelocityCommandManager manager = createManager();
|
||||||
assertFalse(manager.hasCommand("foo"));
|
assertFalse(manager.hasCommand("foo"));
|
||||||
assertTrue(manager.getDispatcher().getRoot().getChildren().isEmpty());
|
assertTrue(manager.getDispatcher().getRoot().getChildren().isEmpty());
|
||||||
assertFalse(manager.execute(MockCommandSource.INSTANCE, "foo").join());
|
assertFalse(manager.executeAsync(MockCommandSource.INSTANCE, "foo").join());
|
||||||
assertFalse(manager.executeImmediately(MockCommandSource.INSTANCE, "bar").join());
|
assertFalse(manager.executeImmediatelyAsync(MockCommandSource.INSTANCE, "bar").join());
|
||||||
assertTrue(manager.offerSuggestions(MockCommandSource.INSTANCE, "").join().isEmpty());
|
assertTrue(manager.offerSuggestions(MockCommandSource.INSTANCE, "").join().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ public class CommandManagerTests {
|
|||||||
assertTrue(manager.hasCommand("foO"));
|
assertTrue(manager.hasCommand("foO"));
|
||||||
manager.unregister("fOo");
|
manager.unregister("fOo");
|
||||||
assertFalse(manager.hasCommand("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");
|
manager.register("foo", command, "bAr", "BAZ");
|
||||||
assertTrue(manager.hasCommand("bar"));
|
assertTrue(manager.hasCommand("bar"));
|
||||||
@ -168,14 +168,14 @@ public class CommandManagerTests {
|
|||||||
node.addChild(quantityNode);
|
node.addChild(quantityNode);
|
||||||
manager.register(new BrigadierCommand(node));
|
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(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(checkedRequires.compareAndSet(true, false));
|
||||||
assertTrue(executed.get());
|
assertTrue(executed.get());
|
||||||
assertTrue(manager.execute(MockCommandSource.INSTANCE, "buy 9").join(),
|
assertTrue(manager.executeAsync(MockCommandSource.INSTANCE, "buy 9").join(),
|
||||||
"Invalid arg returns false");
|
"Invalid arg returns false");
|
||||||
assertTrue(manager.executeImmediately(MockCommandSource.INSTANCE, "buy 12 bananas")
|
assertTrue(manager.executeImmediatelyAsync(MockCommandSource.INSTANCE, "buy 12 bananas")
|
||||||
.join());
|
.join());
|
||||||
assertTrue(checkedRequires.get());
|
assertTrue(checkedRequires.get());
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ public class CommandManagerTests {
|
|||||||
};
|
};
|
||||||
manager.register("foo", command);
|
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());
|
assertTrue(executed.get());
|
||||||
|
|
||||||
SimpleCommand noPermsCommand = new SimpleCommand() {
|
SimpleCommand noPermsCommand = new SimpleCommand() {
|
||||||
@ -207,8 +207,8 @@ public class CommandManagerTests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
manager.register("dangerous", noPermsCommand, "veryDangerous");
|
manager.register("dangerous", noPermsCommand, "veryDangerous");
|
||||||
assertFalse(manager.execute(MockCommandSource.INSTANCE, "dangerous").join());
|
assertFalse(manager.executeAsync(MockCommandSource.INSTANCE, "dangerous").join());
|
||||||
assertFalse(manager.executeImmediately(MockCommandSource.INSTANCE, "verydangerous 123")
|
assertFalse(manager.executeImmediatelyAsync(MockCommandSource.INSTANCE, "verydangerous 123")
|
||||||
.join());
|
.join());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ public class CommandManagerTests {
|
|||||||
};
|
};
|
||||||
manager.register("sendMe", command);
|
manager.register("sendMe", command);
|
||||||
|
|
||||||
assertTrue(manager.executeImmediately(MockCommandSource.INSTANCE, "sendMe lobby 23")
|
assertTrue(manager.executeImmediatelyAsync(MockCommandSource.INSTANCE, "sendMe lobby 23")
|
||||||
.join());
|
.join());
|
||||||
assertTrue(executed.compareAndSet(true, false));
|
assertTrue(executed.compareAndSet(true, false));
|
||||||
|
|
||||||
@ -239,9 +239,9 @@ public class CommandManagerTests {
|
|||||||
};
|
};
|
||||||
manager.register("noargs", noArgsCommand);
|
manager.register("noargs", noArgsCommand);
|
||||||
|
|
||||||
assertTrue(manager.executeImmediately(MockCommandSource.INSTANCE, "noargs").join());
|
assertTrue(manager.executeImmediatelyAsync(MockCommandSource.INSTANCE, "noargs").join());
|
||||||
assertTrue(executed.get());
|
assertTrue(executed.get());
|
||||||
assertTrue(manager.executeImmediately(MockCommandSource.INSTANCE, "noargs ").join());
|
assertTrue(manager.executeImmediatelyAsync(MockCommandSource.INSTANCE, "noargs ").join());
|
||||||
|
|
||||||
RawCommand noPermsCommand = new RawCommand() {
|
RawCommand noPermsCommand = new RawCommand() {
|
||||||
@Override
|
@Override
|
||||||
@ -256,7 +256,7 @@ public class CommandManagerTests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
manager.register("sendThem", noPermsCommand);
|
manager.register("sendThem", noPermsCommand);
|
||||||
assertFalse(manager.executeImmediately(MockCommandSource.INSTANCE, "sendThem foo")
|
assertFalse(manager.executeImmediatelyAsync(MockCommandSource.INSTANCE, "sendThem foo")
|
||||||
.join());
|
.join());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -421,16 +421,16 @@ public class CommandManagerTests {
|
|||||||
manager.register(meta, command);
|
manager.register(meta, command);
|
||||||
|
|
||||||
expectedArgs.set("notBarOrBaz");
|
expectedArgs.set("notBarOrBaz");
|
||||||
assertTrue(manager.execute(MockCommandSource.INSTANCE, "foo notBarOrBaz").join());
|
assertTrue(manager.executeAsync(MockCommandSource.INSTANCE, "foo notBarOrBaz").join());
|
||||||
assertTrue(executed.compareAndSet(true, false));
|
assertTrue(executed.compareAndSet(true, false));
|
||||||
expectedArgs.set("anotherArg 123");
|
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));
|
assertTrue(executed.compareAndSet(true, false));
|
||||||
expectedArgs.set("bar");
|
expectedArgs.set("bar");
|
||||||
assertTrue(manager.execute(MockCommandSource.INSTANCE, "foo bar").join());
|
assertTrue(manager.executeAsync(MockCommandSource.INSTANCE, "foo bar").join());
|
||||||
assertTrue(executed.compareAndSet(true, false));
|
assertTrue(executed.compareAndSet(true, false));
|
||||||
expectedArgs.set("bar 123");
|
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));
|
assertTrue(executed.compareAndSet(true, false));
|
||||||
|
|
||||||
assertEquals(ImmutableList.of("bar", "baz", "raw"),
|
assertEquals(ImmutableList.of("bar", "baz", "raw"),
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren