NEED Help with Permissions

Discussion in 'Bukkit Help' started by Paulus_De_Gross, Jun 14, 2020.

  1. Offline

    Paulus_De_Gross

    Hi Guys, i need help, how do i give a Player permissions through a command, which i have created, i have put my current code below, and i am playing and coding in 1.15.2, thank you fopr your help in advance!

    Code:
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.permissions.PermissionAttachment;
    
    import de.me.challengeprojectplugin.main.Main;
    
    public class GetPerms implements CommandExecutor{
    
        public Main plugin;
      
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
          
            if(sender instanceof Player) {
              
                Player p = (Player) sender;
                    if(args.length == 0) {
                  
                        PermissionAttachment attachment = p.addAttachment(plugin);
                        attachment.setPermission("test", true);
                      
                    }
            }
            return false;
        }
    }
     
    Last edited by a moderator: Jun 14, 2020
  2. Online

    timtower Moderator Moderator

Share This Page