Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimpleCommand fails to forward commands with args #555

Open
roccodev opened this issue Aug 4, 2021 · 1 comment
Open

SimpleCommand fails to forward commands with args #555

roccodev opened this issue Aug 4, 2021 · 1 comment
Labels
type: bug Something isn't working

Comments

@roccodev
Copy link
Contributor

roccodev commented Aug 4, 2021

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)

@roccodev roccodev changed the title SimpleCommand failing to forward commands with args SimpleCommand fails to forward commands with args Aug 4, 2021
@hugmanrique
Copy link
Contributor

hugmanrique commented Aug 4, 2021

This is expected behavior (and as you say is essentially the same as the linked issue) and mimics Brigadier's parsing mechanism.

@4drian3d 4drian3d added the type: bug Something isn't working label Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants