Solved Give player permission for command?

Discussion in 'Spigot Plugin Development' started by moosecanoes, Jun 11, 2016.

  1. I can't give the normal player access to the commands in my plugin like most plugins do. Everytime they try to do my commands, they get the error message for permission that I coded.

    I set default: true on each command, and that didn't work either. The command work fine with OP's.

    Do I have to use a permission plugin just to give someone a permission to use my command?
  2. When you perform a command, it will trigger the onCommand method. In there it's your job to make sure that a player is performing the command, in case of that you only want players to do it. and you should also check if that command sender actually has the permission for the command is you want a permission for it.
    You can check for a permission by using the .hasPermission(String) method in the CommandSender class.
    If you have a separate way of checking if somebody may perform a command, then you can use that. You aren't forced to check if a player has a permission.
    For permissions, it's best to use a permission plugin to give players permissions.
  3. If you set the permission option in the plugin.yml it checks permission for you. I believe the op is asking how to give players permission for the command without having to install a permissions plugin.

    @moosecanoes Did you make the separate 'permissions' section in your plugin.yml? Putting 'default: true' under the command in the commands section won't work.

  4. I set it up like I should, I'm just confused on how I let the player have permission by default.

    So in my main command function I do this...

    And in my plugin.yml i have this...


    description:An example command



    permission-message:You don't have the levelup permission!

    But I don't know how to give a player the permission without having to install permissions plugin.
  5. Documentation:

    Look into "permissions". It works a bit like "commands" but it is a seperate section, so don't put your permissions under "commands".

    Code (Text):

        description: A description (not required)
        default: true
    Edit: adding "default: true" (as shown in the example) will give everyone this permission by default.
  6. Okay nevermind your correct, not setting a permission in plugin.yml is how you do it.

    I had to remove some player.hasPermission() checks because there was an error on one of them being null after I removed the permission.

    I will have to consider whether they need permissions for each command.
  7. Use this instead

    Code (Text):
    if (command.getName().equalsIgnoreCase("command")) {
      //Do stuff
    Using label doesn't allow for aliases.
  8. Yeah i have the same problem i have the plugins GFly and essentials ive been trying to get commands to work i even added group manager and set perms in game for the player i wanted to have the perms but it still said he didnt have perms to use the commands

    im new to server stuff and could really use help