Giving players permissions

Discussion in 'Plugin Development' started by DaanSander, Feb 15, 2015.

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

    DaanSander

    Hello i am trying to create a permission plugin biut i dont know how to give players custom permissions can somebody please explain that maybe to me



    sorry for bad english
     
  2. Offline

    JPG2000

    Check out this guide here for giving player permissions, and use the hasPermission(String permission) method to check if a player has a permission.
     
  3. Offline

    DaanSander

    Alright i know now how to give permissions but where do i need to give them in a playerjoinevent orr in a runtasktimer?
     
  4. i'd put it in the PlayerJoinEvent and you should set it for every online player in case of a reload
     
  5. Offline

    DaanSander

    @sn1cko when i try to give the permissions it wont work
    code:
    Code:
    @EventHandler(priority = EventPriority.MONITOR)
        public void onPlayerJoinWithoutRank(PlayerJoinEvent e) {
            Player p = (Player) e.getPlayer();
            //if(!HMCEssentials.plugin.getConfig().contains(String.valueOf(p.getUniqueId()))) {
            //HMCEssentials.Normal.add(p.getUniqueId());
            // HMCEssentials.plugin.saveConfig();
            //loadConfig();
            if (HMCEssentials.plugin.getConfig().getConfigurationSection(p.getName()) == null) {
                try {
                    HMCEssentials.plugin.getConfig().createSection(p.getName() + ".group" + ".user-id");
                    HMCEssentials.plugin.getConfig().set(".user-id", p.getUniqueId());
                    HMCEssentials.plugin.getConfig().set(p.getName() + ".group", "default");
                    HMCEssentials.plugin.saveConfig();
                } catch (NullPointerException ex) {
                    ex.printStackTrace();
                    p.sendMessage("§4§lAn error has occurred while adding you to the permission file a log has been send to the developer!");
                }
                try {
                    PermissionAttachment attachment = p.addAttachment(HMCEssentials.plugin);
                    attachment.setPermission("HMCEssentials.fly", true);
                }catch (NullPointerException nul) {
                    nul.printStackTrace();
                }
    
            }
            //Bukkit.getLogger().info("Registered player" + p.getName());
            //settings.getPfile().set("Default", p.getName());
            //Bukkit.getLogger().info("Registered player" + p.getName());
        }
    no stacktraces or anything
     
  6. i don't really get what you're trying to do whit this code haha but you should check for
    Code:
    HMCEssentials.plugin.getConfig().getString(p.getName() + ".group") == null
    
    cause if you get no error you should check it by creating else statements
     
  7. Offline

    DaanSander

    @sn1cko but how can i set the players permissions?
     
  8. Offline

    teej107

  9. Offline

    DaanSander

    @teej107 thx but what is the permission for all the permissions??
     
  10. Offline

    teej107

  11. Offline

    DaanSander

    No the permission node like bukkit.*
     
  12. Offline

    1Rogue

    For starters there is no '*' node

    Secondly, aliases such as mypermissions.* are manually mapped in the plugin.yml (or via dynamic loading at runtime).
     
Thread Status:
Not open for further replies.

Share This Page