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.
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?
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?
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
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.
@AdamQpzm Code:java Member:ID: 0permissions:- essentials.helpHelper:ID: 1prefix: '&a&lHelper&r 'permissions:- essentials.tpOwner:ID: 2prefix: '&4&lOwner&r 'permissions:- '*' 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
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.
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
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.
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.