Solved Get Permission To recalculatePermissibles()

Discussion in 'Spigot Plugin Development' started by Th3_DoC, Feb 20, 2020.

  1. I'm having trouble getting the Permission Class Variable from the String ex.
    Code (Text):

    String str = "minecraft.command.fill"
    PermissionAttachment attachment = player.addAttachment(plugin);
    attachment.setPermission(str, true);
    player.recalculatePermissions;
    Permission permission = str; //This is where I'm having trouble accomplishing my
    //task, a few will return !null but most will return null, even though the permission
    //sets just fine.
    permission.recalculatePermissibles();
     
    Can this be done, am i going about it the wrong way?
    Thanks.

    Here is the method i am using.
    @Param p is for debug only at this point
    @var permission.creativePlayerCommands() is a list of commands like "minecraft.command.fill"
    Code (Text):

    public void checkPermState(Player p) {
        p.sendMessage("Checking Perm State");//debug
        for(String str:permission.creativePlayerCommands()) {
            Permission permission = main.getServer().getPluginManager().getPermission(str);
            p.sendMessage("Permission = " + permission);//debug
            if(permission != null) {
                p.sendMessage("Recalculating Permissibles");//debug
                permission.recalculatePermissibles();
            }
        }
    }
     
     
    #1 Th3_DoC, Feb 20, 2020
    Last edited: Feb 20, 2020
  2. Bump

    Edit: nevermind, if I Instantiate the permission var properly everything works fine lol.

    for those that may find this in the future ;)
    Code (Text):

    public void checkPermState() {
        for(String str:permission.creativePlayerCommands()) {
            Permission permission = new Permission(str);
            permission.recalculatePermissibles();
        }
    }
     
     
    #2 Th3_DoC, Feb 21, 2020
    Last edited: Feb 21, 2020