Permissions help

Discussion in 'Plugin Development' started by zJanny, Oct 20, 2019.

  1. Offline

    zJanny

    Hello,
    How can i give a player the "Community.King" permission
    when i executed a command like /king ?
    And remove it when i do for example /removeking
     
  2. Offline

    ThePandaPlayer

    Correct me if I'm wrong, but I believe you can grant permissions like this:

    Code:
    PermissionAttachment attachment = new PermissionAttachment(mainPluginClass,PlayerInstance);
    attachment.setPermission("Community.King",true);
    MainPluginClass means an instance of the main class, PlayerInstance being the Player instance you want to give the permission to, and true/false being whether the permission is granted.

    You can also pass a org.bukkit.permission.Permission instance instead of a String for the permission.


    Do yourself a favor and familiarize yourself with the Bukkit JavaDoc. I have no problem answering your questions, but the official JavaDoc documentation is an incredible resource for Bukkit, and rather than spending the time typing up a forum post, a quick search through the JavaDoc can usually answer your questions pretty quickly.
     
  3. Offline

    djbomber36

    If your using a permission plugin you can do
    Code:
    If (player.hasPermission("permission.permission")) {
         //Your Code
    }
    Edit: do you want to make your plugin give a permission to a player, or do you want to do a command that can be executed only if the player has a certain permission?

    Edit2: Sorry just understand your question now. You have to do what Panda said. I recommend read this before doing it https://bukkit.gamepedia.com/Developing_a_permissions_plugin
     
    Last edited: Nov 1, 2019

Share This Page