use of org.spongepowered.common.command.brigadier.dispatcher.SpongeCommandDispatcher in project SpongeCommon by SpongePowered.
the class SpongeParameterizedCommand method getCachedDispatcher.
private SpongeCommandDispatcher getCachedDispatcher() {
if (this.cachedDispatcher == null) {
if (this.commandManager == null) {
throw new IllegalStateException("Completions cannot be requested for an unregistered parameterized command");
}
this.cachedDispatcher = new SpongeCommandDispatcher(this.commandManager);
this.cachedDispatcher.register(this.buildWithAlias("command"));
}
return this.cachedDispatcher;
}
use of org.spongepowered.common.command.brigadier.dispatcher.SpongeCommandDispatcher in project SpongeCommon by SpongePowered.
the class SpongeParameterizedCommand method complete.
@Override
public List<CommandCompletion> complete(@NonNull final CommandCause cause, final ArgumentReader.@NonNull Mutable arguments) {
final SpongeCommandDispatcher dispatcher = this.getCachedDispatcher();
final String input = arguments.remaining();
final ParseResults<CommandSourceStack> parseResults = dispatcher.parse((StringReader) arguments, (CommandSourceStack) cause);
final Suggestions suggestions = dispatcher.getCompletionSuggestions(parseResults).join();
return suggestions.getList().stream().map(SpongeCommandCompletion::from).collect(Collectors.toList());
}
use of org.spongepowered.common.command.brigadier.dispatcher.SpongeCommandDispatcher in project Sponge by SpongePowered.
the class SpongeParameterizedCommand method complete.
@Override
public List<CommandCompletion> complete(@NonNull final CommandCause cause, final ArgumentReader.@NonNull Mutable arguments) {
final SpongeCommandDispatcher dispatcher = this.getCachedDispatcher();
final String input = arguments.remaining();
final ParseResults<CommandSourceStack> parseResults = dispatcher.parse((StringReader) arguments, (CommandSourceStack) cause);
final Suggestions suggestions = dispatcher.getCompletionSuggestions(parseResults).join();
return suggestions.getList().stream().map(SpongeCommandCompletion::from).collect(Collectors.toList());
}
use of org.spongepowered.common.command.brigadier.dispatcher.SpongeCommandDispatcher in project Sponge by SpongePowered.
the class SpongeParameterizedCommand method getCachedDispatcher.
private SpongeCommandDispatcher getCachedDispatcher() {
if (this.cachedDispatcher == null) {
if (this.commandManager == null) {
throw new IllegalStateException("Completions cannot be requested for an unregistered parameterized command");
}
this.cachedDispatcher = new SpongeCommandDispatcher(this.commandManager);
this.cachedDispatcher.register(this.buildWithAlias("command"));
}
return this.cachedDispatcher;
}
Aggregations