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

Wrong LiteMessages response when 2 commands that overload eachother have dedicated @Permission annotation #522

Open
PenT1x opened this issue Feb 20, 2025 · 0 comments

Comments

@PenT1x
Copy link

PenT1x commented Feb 20, 2025

I have just copied the message from discord here: https://discord.com/channels/896933084983877662/896937021552078899/1337523891404542094

When I have 2 commands that overload each other where they have dedicated @Permision annotation. Then players missing permission that do invalid usage will be shown one of them in LiteMessages.INVALID_USAGE but if they do a valid usage they will be shown LiteMessages.MISSING_PERMISSIONS
These works

@RootCommand
@Permission("crazytestpermission")
public class TestCommand {

    @Execute(name = "test")
    void executeTest(@Context Player player, @Arg("player") Optional<Player> target) {
        player.sendMessage("Test command executed");
        target.ifPresent(value -> value.sendMessage("You have been tested"));
    }

    @Execute(name = "test")
    void executeTest(@Context Player player, @Arg("message") String message) {
        player.sendMessage("Test command executed: " + message);
    }
}

^^ /test
Output: Du har ikke tilladelse til at bruge denne kommando. (This is excepted)

@RootCommand
@Permission("crazytestpermission")
public class TestCommand {

    @Execute(name = "test")
    void executeTest(@Context Player player, @Arg("testPlayer") Player testPlayer, @Arg("player") Optional<Player> target) {
        player.sendMessage("Test command executed");
        target.ifPresent(value -> value.sendMessage("You have been tested"));
    }

    @Execute(name = "test")
    void executeTest(@Context Player player, @Arg("message") String message) {
        player.sendMessage("Test command executed: " + message);
    }
}

^^ /test
Output: Du har ikke tilladelse til at bruge denne kommando. (This is excepted)

@RootCommand
public class TestCommand {

    @Execute(name = "test")
    @Permission("crazytestpermission")
    void executeTest(@Context Player player, @Arg("player") Optional<Player> target) {
        player.sendMessage("Test command executed");
        target.ifPresent(value -> value.sendMessage("You have been tested"));
    }

    @Execute(name = "test")
    @Permission("crazytestpermission")
    void executeTest(@Context Player player, @Arg("message") String message) {
        player.sendMessage("Test command executed: " + message);
    }
}

^^ /test
Output: Du har ikke tilladelse til at bruge denne kommando. (This is excepted)

This doesn't work

@RootCommand
public class TestCommand {

    @Execute(name = "test")
    @Permission("crazytestpermission")
    void executeTest(@Context Player player, @Arg("testPlayer") Player testPlayer, @Arg("player") Optional<Player> target) {
        player.sendMessage("Test command executed");
        target.ifPresent(value -> value.sendMessage("You have been tested"));
    }

    @Execute(name = "test")
    @Permission("crazytestpermission")
    void executeTest(@Context Player player, @Arg("message") String message) {
        player.sendMessage("Test command executed: " + message);
    }
}

^^ /test
Output: Forkert brug. Brug:
/test [player] (This is not excepted)

/test PenT1x
Output: Du har ikke tilladelse til at bruge denne kommando. (This is excepted)

@RootCommand
public class TestCommand {

    @Execute(name = "test")
    @Permission("crazytestpermission")
    void executeTest(@Context Player player, @Arg("testPlayer") Player testPlayer) {
        player.sendMessage("Test command executed");
    }

    @Execute(name = "test")
    @Permission("crazytestpermission")
    void executeTest(@Context Player player, @Arg("message") String message) {
        player.sendMessage("Test command executed: " + message);
    }
}

^^ /test
Output: Forkert brug. Brug:
/test (This is not excepted)

/test PenT1x
Output: Du har ikke tilladelse til at bruge denne kommando. (This is excepted)

And it has nothing with the Optional to do. Only had that there because the command I found this in had.
So I am kinda lost 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant