PermissionAttachment failing to register after reloading

Discussion in 'Plugin Development' started by TerroDoor, Jun 22, 2020.

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

    TerroDoor

    I have permission attachments save to a configuration with the player uuid as the key, the permission is also loaded in the onEnable and this all works. however if reloaded with an active permission and I remove a permission that exists it gets removed but doesn’t register ingame, I use the .hasPermission(“perm.build”) to cancel building yet it doesn’t cancel it.


    Sent from my iPhone using Tapatalk
     
  2. Offline

    Lightcaster5

    Sounds like you need to reload your instance of the configuration. Do you have something like this?
    Code:
    public static FileConfiguration config;
    
    public void onEnable() {
        MainClass.config = getConfig();
    }
     
  3. Offline

    KarimAKL

    @Lightcaster5, @TerroDoor contacted me through PMs (before this thread was created) about this issue.

    A saved FileConfiguration instance is a good guess but, it seems the problem was that a player keeps their PermissionAttachments through reloads and thus had two PermissionAttachment instances while only the second one was changed.

    The solution was simply removing the attachment in the onDisable and adding a new one in the onEnable.
     
    Lightcaster5 likes this.
Thread Status:
Not open for further replies.

Share This Page