Solved Issue with permissions (again)

Discussion in 'Plugin Development' started by CorrieKay, Dec 5, 2012.

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

    CorrieKay

    I ported my permission system to work with multiple worlds, and to differentiate between them.

    For some reason though, i was able to use permissions specified only for one world, in another world.

    Curious as to why that was happening, i iterated over the permissions attachment info's of the player when their permissions were calculated, and holy mother of god, apparently i am adding like, forty of the same PermissionAttachments to the player.

    I mean, i checked it out myself, and i am doing it correctly. I keep track of which Attachments i attach to players, i make sure to remove it when calculating perms, i re-add a new one, then i calculate permissions (which i did debug too, that part is working as intended)

    But for some reason, their permissions from the last attachment are not getting removed.

    Heres my class

    edit: Oh god, i feel silly. It was reloading the server. My plugin would lose track of the permission attachment, and it would stay on the player. Ive figured it out now.

    edit: read second post

    Edit: unsolved. This i gonna drive me nuts...

    Okay, my permissions system has, as stated, a multiworld system. It also has player specific permissions.

    Heres how it works (open)

    • when the server loads, it grabs a list of groups from the permissions configuration file. Each of these groups has a declared set of permissions for global, and each of the worlds. It creates a permissions set per world that contains FIRST the global permissions (positive, then negative), THEN it adds the world specific permission (again, first positive, then negative).
    • Whenever a players permissions are calculated, the code first removes the previous permission attachment object. It then creates a new one.
    • Next, it grabs the permission set from the specific world requested (for teleporting between worlds, you can supply the next world you'll be in). After those are obtained, it then calculates the players permissions, and overlays them on top of the worlds permissions, overriding whats there (one last time, positive, then negative permissions)
    • After that, it re-registers the permission attachment in a hashmap, so that the next time their permissions need to be calculated, the previous permissions may be discarded.


    Now, the problem i ran into in the OP was that it randomly seemed to give out permissions. Well, it was found that reloading the server was the problem. It lost track of the permissions attachment, and never removed it.

    Then for some reason.. It started giving the permission litterally to anyone. Which was strange, as i had registered the permission as default: false in the plugin.yml. I registered it to op only, and that seemed to fix the problem.

    Well, it seemed to be going fine after i had fixed it (removing permissions on a reload, setting perm to op only) but suddenly, the problem reared its head again. For some reason, removing a personal permission is not working. You can add a personal permission, and it will work, but whenever you
    try to remove it, it wouldnt be removed, and they would still have the permission.

    Strangely enough, during debugging of this, i noticed something EVEN WEIRDER. Whenever you add a personal permission to a player, anyone else in their group also gets that permission when calculating the permissions. This is driving me frigging crazy, and im at my wits end trying to figure this out..

    Can anyone help me? Heres my class.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  2. Offline

    CorrieKay

    bump

    edit: closed, i was editing the groups permission hashmap. Solved by cloning the hashmap. I am a major derp.
     
Thread Status:
Not open for further replies.

Share This Page