fix brigadier suggestions with the '/execute' command, fix running cloud commands with '/execute' on fabric

This commit is contained in:
jmp 2021-02-06 18:04:16 -08:00 committed by Jason
parent 8db87744d9
commit f16cafda3f
2 changed files with 6 additions and 8 deletions

View file

@ -617,8 +617,12 @@ public final class CloudBrigadierManager<C, S> {
final @NonNull SuggestionsBuilder builder
) {
final CommandContext<C> commandContext;
String command = builder.getInput();
if (this.brigadierCommandSenderMapper == null || senderContext == null) {
commandContext = this.dummyContextProvider.get();
if (command.startsWith("/") /* Minecraft specific */) {
command = command.substring(1);
}
} else {
final C cloudSender = this.brigadierCommandSenderMapper.apply(senderContext.getSource());
commandContext = new CommandContext<>(
@ -626,11 +630,7 @@ public final class CloudBrigadierManager<C, S> {
cloudSender,
this.commandManager
);
}
String command = builder.getInput();
if (command.startsWith("/") /* Minecraft specific */) {
command = command.substring(1);
command = command.substring(senderContext.getLastChild().getNodes().get(0).getRange().getStart());
}
/* Remove namespace */

View file

@ -79,9 +79,7 @@ final class FabricExecutor<C, S extends CommandSource> implements Command<S> {
@Override
public int run(final @NonNull CommandContext<S> ctx) {
final S source = ctx.getSource();
final String input = ctx.getInput().startsWith("/")
? ctx.getInput().substring(1)
: ctx.getInput();
final String input = ctx.getInput().substring(ctx.getLastChild().getNodes().get(0).getRange().getStart());
final C sender = this.manager.getCommandSourceMapper().apply(source);
this.manager.executeCommand(sender, input).whenComplete(this.getResultConsumer(source, sender));
return com.mojang.brigadier.Command.SINGLE_SUCCESS;