Search in sources :

Example 1 with VelocityCommandActor

use of revxrsal.commands.velocity.VelocityCommandActor in project Lamp by Revxrsal.

the class VelocitySimpleCommand method execute.

@Override
public void execute(Invocation invocation) {
    CommandSource source = invocation.source();
    VelocityCommandActor actor = new VelocityActor(source, handler.getServer(), handler);
    try {
        ArgumentStack arguments = ArgumentStack.of(invocation.arguments());
        arguments.addFirst(invocation.alias());
        handler.dispatch(actor, arguments);
    } catch (Throwable t) {
        handler.getExceptionHandler().handleException(t, actor);
    }
}
Also used : VelocityCommandActor(revxrsal.commands.velocity.VelocityCommandActor) CommandSource(com.velocitypowered.api.command.CommandSource) ArgumentStack(revxrsal.commands.command.ArgumentStack)

Example 2 with VelocityCommandActor

use of revxrsal.commands.velocity.VelocityCommandActor in project Lamp by Revxrsal.

the class VelocitySimpleCommand method suggest.

@Override
public List<String> suggest(Invocation invocation) {
    try {
        VelocityCommandActor actor = new VelocityActor(invocation.source(), handler.getServer(), handler);
        ArgumentStack arguments;
        if (invocation.arguments().length == 0)
            arguments = ArgumentStack.forAutoCompletion("");
        else
            arguments = ArgumentStack.forAutoCompletion(invocation.arguments());
        arguments.addFirst(invocation.alias());
        return handler.getAutoCompleter().complete(actor, arguments);
    } catch (ArgumentParseException e) {
        return Collections.emptyList();
    }
}
Also used : VelocityCommandActor(revxrsal.commands.velocity.VelocityCommandActor) ArgumentParseException(revxrsal.commands.exception.ArgumentParseException) ArgumentStack(revxrsal.commands.command.ArgumentStack)

Aggregations

ArgumentStack (revxrsal.commands.command.ArgumentStack)2 VelocityCommandActor (revxrsal.commands.velocity.VelocityCommandActor)2 CommandSource (com.velocitypowered.api.command.CommandSource)1 ArgumentParseException (revxrsal.commands.exception.ArgumentParseException)1