SimpleCommand fails to forward commands with args
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2.3k
- Forks
- 960
- Avg merge
- 5d 10h
- Merged PRs (30d)
- 2
Description
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:
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)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing SimpleCommand, hasPermission(Invocation), and commandManager.register("test", new TestCommand()) through the command handling and forwarding path. Reproduce the provided /test and /test abc cases with permission denied, then verify that both forms are forwarded to the backend without the Brigadier argument error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100