When hasPermission() == false, SimpleCommand classes will only forward the command if no arguments are used. Adding any argument will make the proxy catch it, throwing an error.
Simple PoC:
import com.velocitypowered.api.command.SimpleCommand;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
public class TestCommand implements SimpleCommand {
@Override
public void execute(Invocation invocation) {
invocation.source().sendMessage(Component.text("Invoked!", NamedTextColor.GREEN));
}
@Override
public boolean hasPermission(Invocation invocation) {
// With this, the command should be forwarded to the backend server in any case.
return false;
}
}
// ...
commandManager.register("test", new TestCommand()); // same effect with CommandMeta
Expected result/test -> Forwarded to backend
/test abc -> Forwarded to backend
Actual result/test -> Forwarded to backend
/test abc -> Incorrect argument for command at position 5: test <--[HERE] (in red, Brigadier error)
When hasPermission is changed to return true, the command works as expected for hasPermission() == true. (printing Invoked! with and without args)
Might be related to #369.
When
hasPermission() == false
,SimpleCommand
classes will only forward the command if no arguments are used. Adding any argument will make the proxy catch it, throwing an error.Simple PoC:
Expected result
/test
-> Forwarded to backend/test abc
-> Forwarded to backendActual result
/test
-> Forwarded to backend/test abc
->Incorrect argument for command at position 5: test <--[HERE]
(in red, Brigadier error)When
hasPermission
is changed to returntrue
, the command works as expected forhasPermission() == true
. (printingInvoked!
with and without args)