Remove remaining deprecated APIs
This commit is contained in:
@@ -130,13 +130,7 @@ public class VelocityCommandManager implements CommandManager {
|
||||
return eventManager.fire(new CommandExecuteEvent(source, cmdLine));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(final CommandSource source, final String cmdLine) {
|
||||
return executeAsync(source, cmdLine).join();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeImmediately(final CommandSource source, final String cmdLine) {
|
||||
private boolean executeImmediately0(final CommandSource source, final String cmdLine) {
|
||||
Preconditions.checkNotNull(source, "source");
|
||||
Preconditions.checkNotNull(cmdLine, "cmdLine");
|
||||
|
||||
@@ -160,27 +154,27 @@ public class VelocityCommandManager implements CommandManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> executeAsync(final CommandSource source, final String cmdLine) {
|
||||
public CompletableFuture<Boolean> execute(final CommandSource source, final String cmdLine) {
|
||||
Preconditions.checkNotNull(source, "source");
|
||||
Preconditions.checkNotNull(cmdLine, "cmdLine");
|
||||
|
||||
return callCommandEvent(source, cmdLine).thenApply(event -> {
|
||||
return callCommandEvent(source, cmdLine).thenApplyAsync(event -> {
|
||||
CommandResult commandResult = event.getResult();
|
||||
if (commandResult.isForwardToServer() || !commandResult.isAllowed()) {
|
||||
return false;
|
||||
}
|
||||
return executeImmediately(source, commandResult.getCommand().orElse(event.getCommand()));
|
||||
});
|
||||
return executeImmediately0(source, commandResult.getCommand().orElse(event.getCommand()));
|
||||
}, eventManager.getService());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> executeImmediatelyAsync(
|
||||
public CompletableFuture<Boolean> executeImmediately(
|
||||
final CommandSource source, final String cmdLine) {
|
||||
Preconditions.checkNotNull(source, "source");
|
||||
Preconditions.checkNotNull(cmdLine, "cmdLine");
|
||||
|
||||
return CompletableFuture.supplyAsync(
|
||||
() -> executeImmediately(source, cmdLine), eventManager.getService());
|
||||
() -> executeImmediately0(source, cmdLine), eventManager.getService());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -598,7 +598,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
return CompletableFuture.runAsync(() -> smc.write(Chat.createServerbound("/"
|
||||
+ commandToRun)), smc.eventLoop());
|
||||
} else {
|
||||
return server.getCommandManager().executeImmediatelyAsync(player, commandToRun)
|
||||
return server.getCommandManager().executeImmediately(player, commandToRun)
|
||||
.thenAcceptAsync(hasRun -> {
|
||||
if (!hasRun) {
|
||||
smc.write(Chat.createServerbound("/" + commandToRun));
|
||||
|
@@ -27,6 +27,7 @@ import com.velocitypowered.proxy.VelocityServer;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.format.TextColor;
|
||||
import net.minecrell.terminalconsole.SimpleTerminalConsole;
|
||||
@@ -119,8 +120,8 @@ public final class VelocityConsole extends SimpleTerminalConsole implements Cons
|
||||
@Override
|
||||
protected void runCommand(String command) {
|
||||
try {
|
||||
if (!this.server.getCommandManager().execute(this, command)) {
|
||||
sendMessage(TextComponent.of("Command not found.", TextColor.RED));
|
||||
if (!this.server.getCommandManager().execute(this, command).join()) {
|
||||
sendMessage(Component.text("Command not found.", NamedTextColor.RED));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("An error occurred while running this command.", e);
|
||||
|
Reference in New Issue
Block a user