add permission

Discussion in 'Plugin Development' started by mcgamer99, May 28, 2012.

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

    mcgamer99

    How I set that when a player do a command, give it a permission?
    And how I set the opposite (when a player do a command remove a permission from he)?
     
  2. Offline

    ZeusAllMighty11

    PHP:
        public boolean onCommand(CommandSender senderCommand commandString labelString[] args) {
            if(
    command.getName().equalsIgnoreCase("yourcommand") && s.hasPermission("your.perm.here")){ // If typed command is your command and has permission
            
    Player s = (Player)sender// defines player s as the person doing command
    // do stuff
            
    }
            return 
    true;
     
  3. Code:java
    1. Permissible perm;
    2.  
    3. //Ading permissions:
    4. PermissionAttachment permInfo = perm.addAttachment(plugin, permission, value);
    5.  
    6. // Removing permissions
    7. perm.removeAttachment(permInfo);
     
  4. Offline

    mcgamer99


    I want to add a permission not check if a player has a permission
     
  5. Offline

    messageofdeath

    PHP:
    getServer().getPluginManager().addPermission(new Permission("perm.here"));
     
  6. Offline

    Wundark

    I am still a little confused on what you are trying to achieve. Here is what I can interpret.

    You are trying to add a Permision Node to a Player when they do a certain command.

    Code:
    public void addPermission(String player, String permissionNode)
    {
        ru.tehkode.permissions.bukkit.PermissionsEx.getUser(player).addPermission(permissionNode);
    }
     
    public void removePermission(String player, String permissionNode)
    {
        ru.tehkode.permissions.bukkit.PermissionsEx.getUser(player).removePermission(permissionNode);
    }
     
  7. Wundark Your code just works with PermissionsEx. Better use Vault or even better bukkits API (like ferrybig still suggested... BTW: A player is a Permissible: player.addAttachment(plugin, "your.permission", boolean); ).
     
Thread Status:
Not open for further replies.

Share This Page