Permissions Plugin

Discussion in 'Plugin Development' started by HelGod, Apr 15, 2014.

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

    HelGod

    I am currently creating a permissions plugin which has groups and I am sort of stuck in a dilemma. Every group has an ID (this makes it easier for promote and demote command) and I get the rank based off the ID and not the name. So if a player has the rank VIP and the ID is 2 and I add the rank below that like Member+ with the ID of 2 and the ID of VIP will now be 3 they will be that rank(Member+) instead of VIP. Does anyone have an idea on how I can fix that? I think I would need to convert the player ranks, but it would a pain if I add a lot of ranks.
     
  2. Why reinvent the Wheel? You could just use available Plugins like permissionsex

    And also, I don't understand your Question, could you try to write it as clear as possible?
     
  3. HelGod Is this what you're trying to say?

    You have the following ranks, with the following IDs:

    ID | Rank
    1 | Member
    2 | VIP
    3 | Mod
    4 | Admin

    And you want a way so that you can easily add a new rank VIP+ below mod and above VIP so that the ranks will now be:

    ID | Rank
    1 | Member
    2 | VIP
    3 | VIP+
    4 | Mod
    5 | Admin

    Without having to manually change the IDs?
     
  4. Offline

    HelGod

    AdamQpzm
    Yeah for the first part, but this is my issue

    ID | Rank (Old Ranks)
    1 | Member
    2 | VIP
    3 | Mod
    4 | Admin

    If the player is the rank MOD (ID 3)

    ID | Rank (New Ranks)
    1 | Member
    2 | VIP
    3 | VIP+
    4 | Mod
    5 | Admin

    Now when I add a new rank the player will not be VIP+ because like I said in the OP I get the rank by ID
     
  5. HelGod How do you store the ranks? Show me all the code relating that that, as well as how you store what rank the player currently is.
     
  6. Offline

    HelGod

    @AdamQpzm

    Code:java
    1. ID: 0
    2. permissions:
    3. - essentials.help
    4. Helper:
    5. ID: 1
    6. prefix: '&a&lHelper&r '
    7. permissions:
    8. - essentials.tp
    9. ID: 2
    10. prefix: '&4&lOwner&r '
    11. permissions:
    12. - '*'
    This is my permissions.yml(This is where I get the ranks from)

    and the player's rank is stored in a mysql database

    Database:

    Player | UUID | Rank
    Test | 123456789 | 2
     
  7. HelGod I would make a method that would increment all of the ranks above and equal to the ID you're adding by 1, and would also do the same to the rank in the database.
     
  8. Offline

    BillyGalbreath

    Keep IDs unique. Add a 3rd parameter called "order" or something.

    Code:
    Member:
        ID: 0
        order: 3
    VIP:
        ID: 1
        order: 2
    Mod:
        ID: 2
        order: 1
    Admin:
        ID: 3
        order: 0
    
    Then when you add VIP+ (id 4, order 2) you can restructure the order of them all and the IDs will remain unique.

    Code:
    Member:
        ID: 0
        order: 4
    VIP:
        ID: 1
        order: 3
    Mod:
        ID: 2
        order: 1
    Admin:
        ID: 3
        order: 0
    VIP+:
        ID: 4
        order: 2
    
     
  9. BillyGalbreath From what I understood, though, the problem was that he didn't want to have to manually change all of the above ones each time a new rank was added in the middle. Your order idea would have him still have to do that.
     
  10. Offline

    BillyGalbreath

    From what I see, his concern is that the ID attached to each player would be incorrect after reordering the IDs. My way lets him leave the IDs alone (by reordering a new parameter) so the ID thats attached to each player would still be valid.
     
    AdamQpzm likes this.
  11. Offline

    HelGod

    BillyGalbreath
    I think your method will work fine. I am going to go test it out
     
  12. BillyGalbreath Ah, fair point. Then yes, your method would be easier.
     
Thread Status:
Not open for further replies.

Share This Page