PaperMC / PaperMC/Velocity

SimpleCommand fails to forward commands with args

Open
#555 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stale
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.