1.18.2 [Paper] Console has no permission to execute Command

Discussion in 'Plugin Development' started by Crafter_Y, Jul 9, 2022.

Thread Status:
Not open for further replies.
  1. Offline

    Crafter_Y

    When I register a command in my plugin.yml:
    Code:
    ...
    commands:
      b:
        description: Ban a Player from the server
        aliases: [ban]
        permission: paradubsch.ban
        permission-message: 'Du benötigst die Berechtigung paradubsch.ban um jemandem einen Ban zuzuweisen!'
        usage: "/ban <User> <Duration> <Reason>"
    ...
    permissions:
      paradubsch.ban:
        description: "Erlaubt Spielern einen Ban zu geben"
        default: false
    register it in my JavaPlugin and set up this CommandExecutor:
    Code:
    public class BanCommand implements TabCompleter, CommandExecutor {
        @Override
        public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
            if (!Expect.minArgs(1, args)) {
                MessageAdapter.sendMessage(sender, Message.Error.CMD_PLAYER_NOT_PROVIDED);
                return true;
            }
            ...
        }
        ...
    }
    and then try to execute it from the console via:
    Code:
    b
    it gives me the no-permission message: 'Du benötigst die Berechtigung paradubsch.ban um jemandem einen Ban zuzuweisen!' that i defined above.

    Why it is behaving like that and how can a execute my commands defined in my plugin in the console?
     
  2. Offline

    timtower Administrator Administrator Moderator

    @Crafter_Y What else is in that onCommand? Anything to handle the permissions?
     
  3. Offline

    Crafter_Y

    no, there isnt as far as i can tell:

    Code:
    public class BanCommand implements TabCompleter, CommandExecutor {
        @Override
        public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
            if (!Expect.minArgs(1, args)) {
                MessageAdapter.sendMessage(sender, Message.Error.CMD_PLAYER_NOT_PROVIDED);
                return true;
            }
    
            switch (args[0]) {
                case "list": {
                    break;
                }
                case "edit": {
                    break;
                }
                case "delete": {
                    deleteBan(sender, args);
                    break;
                }
                default: banPlayer(sender, args);
            }
    
            return true;
        }
    ...
    }
    the permissions for this command are only handled by the plugin.yml
     
  4. Offline

    timtower Administrator Administrator Moderator

    @Crafter_Y Then I find it impressive that the console can't run it.
    Console has all permissions.
    Might be wise to check with paper then.
     
Thread Status:
Not open for further replies.

Share This Page